diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | io.c | 8 | ||||
-rw-r--r-- | test/ChangeLog | 4 | ||||
-rw-r--r-- | test/nonfatal1.ok | 4 |
4 files changed, 15 insertions, 3 deletions
@@ -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 <arnold@skeeve.com> @@ -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 43482705..3b9f494f 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2015-02-27 Arnold D. Robbins <arnold@skeeve.com> + + * nonfatal1.ok: Update after code changes. + 2015-02-26 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (EXTRA_DIST): Add profile0.in which got forgotten diff --git a/test/nonfatal1.ok b/test/nonfatal1.ok index b96b8e27..b22393b2 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 |