aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2014-11-05 12:29:58 -0500
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2014-11-05 12:29:58 -0500
commitc483c50817e8accd0d5052d41d00869330193175 (patch)
treeb79aa201d973180fe1d868befb6602c68d2758f3 /io.c
parent6a9d48365f5044b64a6c270760808d17d475ca4b (diff)
downloadegawk-c483c50817e8accd0d5052d41d00869330193175.tar.gz
egawk-c483c50817e8accd0d5052d41d00869330193175.tar.bz2
egawk-c483c50817e8accd0d5052d41d00869330193175.zip
If getline fails due to a retryable I/O error, return -2 without closing the file only if PROCINFO[<name>, "RETRY"] is configured.
Diffstat (limited to 'io.c')
-rw-r--r--io.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/io.c b/io.c
index 5692a519..6d816da7 100644
--- a/io.c
+++ b/io.c
@@ -3425,6 +3425,13 @@ find_longest_terminator:
return REC_OK;
}
+/* return true if PROCINFO[<filename>, "RETRY"] exists */
+static inline int
+retryable(IOBUF *iop)
+{
+ return PROCINFO_node && in_PROCINFO(iop->public.name, "RETRY", NULL);
+}
+
/* Does the I/O error indicate that the operation should be retried later? */
static inline int
@@ -3500,7 +3507,7 @@ get_a_record(char **out, /* pointer to pointer to data */
return EOF;
} else if (iop->count == -1) {
*errcode = errno;
- if (errno_io_retry())
+ if (errno_io_retry() && retryable(iop))
return -2;
iop->flag |= IOP_AT_EOF;
return EOF;
@@ -3576,7 +3583,7 @@ get_a_record(char **out, /* pointer to pointer to data */
iop->count = iop->public.read_func(iop->public.fd, iop->dataend, amt_to_read);
if (iop->count == -1) {
*errcode = errno;
- if (errno_io_retry())
+ if (errno_io_retry() && retryable(iop))
return -2;
iop->flag |= IOP_AT_EOF;
break;