gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, non-fatal-io-2, updated. gawk-4.1.0-1139


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, non-fatal-io-2, updated. gawk-4.1.0-1139-g9adb80c
Date: Fri, 27 Feb 2015 07:09:53 +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, non-fatal-io-2 has been updated
       via  9adb80ce25def725ddd98d63f62e35a27e04c570 (commit)
       via  765d3a443f5121f148d47ec813069e1257212d5e (commit)
       via  1752d5ee472ce827ee66ea38c33085123575a033 (commit)
      from  9322ab27e20be82722b2db73f74447f2b35c6502 (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=9adb80ce25def725ddd98d63f62e35a27e04c570

commit 9adb80ce25def725ddd98d63f62e35a27e04c570
Author: Arnold D. Robbins <address@hidden>
Date:   Fri Feb 27 09:09:11 2015 +0200

    Improve missing_d/getaddrinfo.[ch].

diff --git a/missing_d/ChangeLog b/missing_d/ChangeLog
index 70fbde6..89dbdb4 100644
--- a/missing_d/ChangeLog
+++ b/missing_d/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-27         Arnold D. Robbins     <address@hidden>
+
+       * getaddrinfo.h (gai_strerror): Add declaration.
+       * getaddrinfo.c (gai_strerror): New function.
+       (getaddrinfo): Return errno values instead of just -1.
+
 2014-04-08         Arnold D. Robbins     <address@hidden>
 
        * 4.1.1: Release tar ball made.
diff --git a/missing_d/getaddrinfo.c b/missing_d/getaddrinfo.c
index 677f27d..f24ac59 100644
--- a/missing_d/getaddrinfo.c
+++ b/missing_d/getaddrinfo.c
@@ -12,6 +12,8 @@
 #ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
 #endif
+#include <errno.h>
+#include <string.h>    /* strerror */
 
 #include "getaddrinfo.h"
 
@@ -29,12 +31,12 @@ getaddrinfo(const char *hostname, const char *portname,
 {
        struct addrinfo *out;
        if (res == NULL)
-               return -1;
+               return EINVAL;
 
        out = (struct addrinfo *) malloc(sizeof(*out));
        if (out == NULL) {
                *res = NULL;
-               return -1;
+               return ENOMEM;
        }
        memset(out, '\0', sizeof(*out));
 
@@ -42,7 +44,7 @@ getaddrinfo(const char *hostname, const char *portname,
        if (out->ai_addr == NULL) {
                free(out);
                *res = NULL;
-               return -1;
+               return ENOMEM;
        }
 
        out->ai_socktype = SOCK_STREAM;
@@ -78,7 +80,7 @@ getaddrinfo(const char *hostname, const char *portname,
                                = ((struct in_addr 
*)he->h_addr_list[0])->s_addr;
                } else {
                        freeaddrinfo(out);
-                       return -1;
+                       return EADDRNOTAVAIL;
                }
        } else {
                if (!(out->ai_flags & AI_PASSIVE))
@@ -109,4 +111,10 @@ getaddrinfo(const char *hostname, const char *portname,
 
        return 0;
 }
+
+const char *
+gai_strerror(int errcode)
+{
+       return strerror(errcode);
+}
 #endif
diff --git a/missing_d/getaddrinfo.h b/missing_d/getaddrinfo.h
index 3d816c9..873d67d 100644
--- a/missing_d/getaddrinfo.h
+++ b/missing_d/getaddrinfo.h
@@ -29,3 +29,5 @@ void freeaddrinfo(struct xaddrinfo * res);
 
 int getaddrinfo(const char * hostname, const char * portname,
        struct xaddrinfo * hints, struct xaddrinfo ** res);
+
+const char *gai_strerror(int errcode);

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=765d3a443f5121f148d47ec813069e1257212d5e

commit 765d3a443f5121f148d47ec813069e1257212d5e
Author: Arnold D. Robbins <address@hidden>
Date:   Fri Feb 27 09:06:01 2015 +0200

    For non-fatal sockets, get a better error message.

diff --git a/ChangeLog b/ChangeLog
index fe40c28..a0d233f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
        getaddrinfo() fails. Change fatals to warnings.
        (devopen): Pass in address of boolean hard_error variable
        and stop trying to open the file if hard_error is true.
+       Save and restore errno around call to socketopen() and
+       use restored errno if open() fails at strictopen.
 
 2015-02-24         Arnold D. Robbins     <address@hidden>
 
diff --git a/io.c b/io.c
index b00aa30..af963a8 100644
--- a/io.c
+++ b/io.c
@@ -1618,6 +1618,7 @@ devopen(const char *name, const char *mode)
        char *ptr;
        int flag = 0;
        struct inet_socket_info isi;
+       int save_errno = 0;
 
        if (strcmp(name, "-") == 0)
                return fileno(stdin);
@@ -1702,10 +1703,12 @@ devopen(const char *name, const char *mode)
                }
                retries = def_retries;
 
+               errno = 0;
                do {
                        openfd = socketopen(isi.family, isi.protocol, 
name+isi.localport.offset, name+isi.remoteport.offset, 
name+isi.remotehost.offset, & hard_error);
                        retries--;
                } while (openfd == INVALID_HANDLE && ! hard_error && retries > 
0 && usleep(msleep) == 0);
+               save_errno = errno;
        }
 
        /* restore original name string */
@@ -1717,8 +1720,11 @@ devopen(const char *name, const char *mode)
        }
 
 strictopen:
-       if (openfd == INVALID_HANDLE)
+       if (openfd == INVALID_HANDLE) {
                openfd = open(name, flag, 0666);
+               if (openfd == INVALID_HANDLE && save_errno)
+                       errno = save_errno;
+       }
 #if defined(__EMX__) || defined(__MINGW32__)
        if (openfd == INVALID_HANDLE && errno == EACCES) {
                /* On OS/2 and Windows directory access via open() is
diff --git a/test/ChangeLog b/test/ChangeLog
index 4348270..3b9f494 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2015-02-27         Arnold D. Robbins     <address@hidden>
+
+       * nonfatal1.ok: Update after code changes.
+
 2015-02-26         Arnold D. Robbins     <address@hidden>
 
        * Makefile.am (EXTRA_DIST): Add profile0.in which got forgotten
diff --git a/test/nonfatal1.ok b/test/nonfatal1.ok
index b96b8e2..b22393b 100644
--- a/test/nonfatal1.ok
+++ b/test/nonfatal1.ok
@@ -1,2 +1,2 @@
-gawk: nonfatal1.awk:3: fatal: remote host and port information (ti10, 357) 
invalid
-EXIT CODE: 2
+gawk: nonfatal1.awk:3: warning: remote host and port information (ti10, 357) 
invalid
+Connection timed out

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=1752d5ee472ce827ee66ea38c33085123575a033

commit 1752d5ee472ce827ee66ea38c33085123575a033
Author: Arnold D. Robbins <address@hidden>
Date:   Fri Feb 27 08:59:09 2015 +0200

    Make socket open not immediately fatal.

diff --git a/ChangeLog b/ChangeLog
index f024ec1..fe40c28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-02-27         Andrew J. Schorr     <address@hidden>
+
+       * io.c (socketopen): New parameter hard_error; set it if
+       getaddrinfo() fails. Change fatals to warnings.
+       (devopen): Pass in address of boolean hard_error variable
+       and stop trying to open the file if hard_error is true.
+
 2015-02-24         Arnold D. Robbins     <address@hidden>
 
        * POSIX.STD: Update copyright year.
diff --git a/io.c b/io.c
index f975353..b00aa30 100644
--- a/io.c
+++ b/io.c
@@ -1466,7 +1466,7 @@ str2mode(const char *mode)
 
 static int
 socketopen(int family, int type, const char *localpname,
-       const char *remotepname, const char *remotehostname)
+       const char *remotepname, const char *remotehostname, bool *hard_error)
 {
        struct addrinfo *lres, *lres0;
        struct addrinfo lhints;
@@ -1485,8 +1485,11 @@ socketopen(int family, int type, const char *localpname,
 
        lerror = getaddrinfo(NULL, localpname, & lhints, & lres);
        if (lerror) {
-               if (strcmp(localpname, "0") != 0)
-                       fatal(_("local port %s invalid in `/inet'"), 
localpname);
+               if (strcmp(localpname, "0") != 0) {
+                       warning(_("local port %s invalid in `/inet'"), 
localpname);
+                       *hard_error = true;
+                       return INVALID_HANDLE;
+               }
                lres0 = NULL;
                lres = & lhints;
        } else
@@ -1504,7 +1507,9 @@ socketopen(int family, int type, const char *localpname,
                if (rerror) {
                        if (lres0 != NULL)
                                freeaddrinfo(lres0);
-                       fatal(_("remote host and port information (%s, %s) 
invalid"), remotehostname, remotepname);
+                       warning(_("remote host and port information (%s, %s) 
invalid"), remotehostname, remotepname);
+                       *hard_error = true;
+                       return INVALID_HANDLE;
                }
                rres0 = rres;
                socket_fd = INVALID_HANDLE;
@@ -1668,6 +1673,7 @@ devopen(const char *name, const char *mode)
                static bool first_time = true;
                unsigned long retries = 0;
                static long msleep = 1000;
+               bool hard_error = false;
 
                if (first_time) {
                        char *cp, *end;
@@ -1697,9 +1703,9 @@ devopen(const char *name, const char *mode)
                retries = def_retries;
 
                do {
-                       openfd = socketopen(isi.family, isi.protocol, 
name+isi.localport.offset, name+isi.remoteport.offset, 
name+isi.remotehost.offset);
+                       openfd = socketopen(isi.family, isi.protocol, 
name+isi.localport.offset, name+isi.remoteport.offset, 
name+isi.remotehost.offset, & hard_error);
                        retries--;
-               } while (openfd == INVALID_HANDLE && retries > 0 && 
usleep(msleep) == 0);
+               } while (openfd == INVALID_HANDLE && ! hard_error && retries > 
0 && usleep(msleep) == 0);
        }
 
        /* restore original name string */

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

Summary of changes:
 ChangeLog               |    9 +++++++++
 io.c                    |   26 +++++++++++++++++++-------
 missing_d/ChangeLog     |    6 ++++++
 missing_d/getaddrinfo.c |   16 ++++++++++++----
 missing_d/getaddrinfo.h |    2 ++
 test/ChangeLog          |    4 ++++
 test/nonfatal1.ok       |    4 ++--
 7 files changed, 54 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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