gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, select, updated. gawk-4.1.0-938-gc483c50


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, select, updated. gawk-4.1.0-938-gc483c50
Date: Wed, 05 Nov 2014 17:31:01 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, select has been updated
       via  c483c50817e8accd0d5052d41d00869330193175 (commit)
      from  6a9d48365f5044b64a6c270760808d17d475ca4b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=c483c50817e8accd0d5052d41d00869330193175

commit c483c50817e8accd0d5052d41d00869330193175
Author: Andrew J. Schorr <address@hidden>
Date:   Wed Nov 5 12:29:58 2014 -0500

    If getline fails due to a retryable I/O error, return -2 without closing 
the file only if PROCINFO[<name>, "RETRY"] is configured.

diff --git a/ChangeLog b/ChangeLog
index 4cf75d0..f37300d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-11-05         Andrew J. Schorr     <address@hidden>
+
+       * io.c (retryable): New function to indicate whether I/O can be
+       retried for this file instead of throwing a hard error.
+       (get_a_record) Check whether this file is configured for retryable
+       I/O before returning nonstandard -2.
+
 2014-11-03         Norihiro Tanaka       <address@hidden>
 
        * re.c (research): Use dfa superset to improve matching speed.
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 82ae5b6..5d278f6 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,10 @@
+2014-11-05         Andrew J. Schorr     <address@hidden>
+
+       * select.c (set_retry): New function to set PROCINFO[<name>, "RETRY"].
+       (do_set_non_blocking): If called with a file name as opposed to a file
+       descriptor, call the set_retry function to configure PROCINFO to tell
+       io.c to retry I/O for temporary failures.
+
 2014-10-08         Arnold D. Robbins     <address@hidden>
 
        * inplace.c (do_inplace_begin): Use a cast to void in front
diff --git a/extension/select.c b/extension/select.c
index 9aefaea..1752ee3 100644
--- a/extension/select.c
+++ b/extension/select.c
@@ -496,6 +496,53 @@ set_non_blocking(int fd)
 #endif
 }
 
+static void
+set_retry(const char *name)
+{
+       static const char suffix[] = "RETRY";
+       static awk_array_t procinfo;
+       static char *subsep;
+       static size_t subsep_len;
+       awk_value_t idx, val;
+       char *s;
+       size_t len;
+
+       if (!subsep) {
+               /* initialize cached values for PROCINFO and SUBSEP */
+               awk_value_t res;
+
+               if (! sym_lookup("PROCINFO", AWK_ARRAY, & res)) {
+                       procinfo = create_array();
+                       res.val_type = AWK_ARRAY;
+                       res.array_cookie = procinfo;
+                       if (! sym_update("PROCINFO", & res)) {
+                               warning(ext_id, _("set_non_blocking: could not 
install PROCINFO array; unable to configure PROCINFO RETRY for `%s'"), name);
+                               return;
+                       }
+                       /* must retrieve it after installing it! */
+                       if (! sym_lookup("PROCINFO", AWK_ARRAY, & res)) {
+                               warning(ext_id, _("set_non_blocking: 
sym_lookup(`%s') failed; unable to configure PROCINFO RETRY for `%s'"), 
"PROCINFO", name);
+                               return;
+                       }
+               }
+               procinfo = res.array_cookie;
+
+               if (! sym_lookup("SUBSEP", AWK_STRING, & res)) {
+                       warning(ext_id, _("set_non_blocking: sym_lookup(`%s') 
failed; unable to configure PROCINFO RETRY for `%s'"), "SUBSEP", name);
+                       return;
+               }
+               subsep = strdup(res.str_value.str);
+               subsep_len = res.str_value.len;
+       }
+
+       len = strlen(name)+subsep_len+sizeof(suffix)-1;
+       emalloc(s, char *, len+2, "set_non_blocking");
+       sprintf(s, "%s%s%s", name, subsep, suffix);
+
+       if (! set_array_element(procinfo, make_malloced_string(s, len, &idx), 
make_null_string(&val)))
+               warning(ext_id, _("set_non_blocking: unable to configure 
PROCINFO RETRY for `%s'"), name);
+}
+
 /*  do_set_non_blocking --- Set a file to be non-blocking */
 
 static awk_value_t *
@@ -520,8 +567,12 @@ do_set_non_blocking(int nargs, awk_value_t *result)
                (get_argument(1, AWK_STRING, & cmdtype) ||
                        (! cmd.str_value.len && (nargs == 1)))) {
                const awk_input_buf_t *buf;
-               if ((buf = get_file(cmd.str_value.str, cmd.str_value.len, 
cmdtype.str_value.str, cmdtype.str_value.len)) != NULL)
-                       return make_number(set_non_blocking(buf->fd), result);
+               if ((buf = get_file(cmd.str_value.str, cmd.str_value.len, 
cmdtype.str_value.str, cmdtype.str_value.len)) != NULL) {
+                       int rc = set_non_blocking(buf->fd);
+                       if (rc == 0)
+                               set_retry(buf->name);
+                       return make_number(rc, result);
+               }
                warning(ext_id, _("set_non_blocking: get_file(`%s', `%s') 
failed"), cmd.str_value.str, cmdtype.str_value.str);
        } else if (do_lint) {
                if (nargs < 2)
diff --git a/io.c b/io.c
index 5692a51..6d816da 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;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog           |    7 ++++++
 extension/ChangeLog |    7 ++++++
 extension/select.c  |   55 +++++++++++++++++++++++++++++++++++++++++++++++++-
 io.c                |   11 ++++++++-
 4 files changed, 76 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]