diff options
-rw-r--r-- | ares/ares_gethostbyaddr.c | 1 | ||||
-rw-r--r-- | ares/ares_gethostbyname.c | 19 | ||||
-rw-r--r-- | ares/ares_init.c | 4 | ||||
-rw-r--r-- | ares/ares_search.c | 1 | ||||
-rw-r--r-- | tests/server/sockfilt.c | 10 | ||||
-rw-r--r-- | tests/server/sws.c | 19 | ||||
-rw-r--r-- | tests/server/tftpd.c | 19 | ||||
-rw-r--r-- | tests/server/util.c | 4 |
8 files changed, 66 insertions, 11 deletions
diff --git a/ares/ares_gethostbyaddr.c b/ares/ares_gethostbyaddr.c index 0faeaec2a..db0ac46b3 100644 --- a/ares/ares_gethostbyaddr.c +++ b/ares/ares_gethostbyaddr.c @@ -224,6 +224,7 @@ static int file_lookup(union ares_addr *addr, int family, struct hostent **host) switch(error) { case ENOENT: + case ESRCH: return ARES_ENOTFOUND; default: DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", diff --git a/ares/ares_gethostbyname.c b/ares/ares_gethostbyname.c index 00d78861d..1bd5ac95d 100644 --- a/ares/ares_gethostbyname.c +++ b/ares/ares_gethostbyname.c @@ -248,6 +248,7 @@ static int file_lookup(const char *name, int family, struct hostent **host) FILE *fp; char **alias; int status; + int error; #ifdef WIN32 char PATH_HOSTS[MAX_PATH]; @@ -280,8 +281,22 @@ static int file_lookup(const char *name, int family, struct hostent **host) fp = fopen(PATH_HOSTS, "r"); if (!fp) - return ARES_ENOTFOUND; - + { + error = ERRNO; + switch(error) + { + case ENOENT: + case ESRCH: + return ARES_ENOTFOUND; + default: + DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", + error, strerror(error))); + DEBUGF(fprintf(stderr, "Error opening file: %s\n", + PATH_HOSTS)); + *host = NULL; + return ARES_EFILE; + } + } while ((status = ares__get_hostent(fp, family, host)) == ARES_SUCCESS) { if (strcasecmp((*host)->h_name, name) == 0) diff --git a/ares/ares_init.c b/ares/ares_init.c index 5268745d0..8f78fa445 100644 --- a/ares/ares_init.c +++ b/ares/ares_init.c @@ -639,6 +639,7 @@ DhcpNameServer error = ERRNO; switch(error) { case ENOENT: + case ESRCH: status = ARES_EOF; break; default: @@ -664,6 +665,7 @@ DhcpNameServer error = ERRNO; switch(error) { case ENOENT: + case ESRCH: status = ARES_EOF; break; default: @@ -690,6 +692,7 @@ DhcpNameServer error = ERRNO; switch(error) { case ENOENT: + case ESRCH: status = ARES_EOF; break; default: @@ -716,6 +719,7 @@ DhcpNameServer error = ERRNO; switch(error) { case ENOENT: + case ESRCH: status = ARES_EOF; break; default: diff --git a/ares/ares_search.c b/ares/ares_search.c index 4b898a77f..4ff54532e 100644 --- a/ares/ares_search.c +++ b/ares/ares_search.c @@ -273,6 +273,7 @@ static int single_domain(ares_channel channel, const char *name, char **s) switch(error) { case ENOENT: + case ESRCH: break; default: DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index b1fd71980..ab6682ec5 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -353,7 +353,7 @@ static int juggle(curl_socket_t *sockfdp, client connecting. */ sockfd = accept(sockfd, NULL, NULL); if(CURL_SOCKET_BAD == sockfd) - logmsg("accept() failed\n"); + logmsg("accept() failed"); else { logmsg("====> Client connect"); write(fileno(stdout), "CNCT\n", 5); @@ -438,7 +438,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock, if(getsockname(sock, (struct sockaddr *) &add, &socksize)<0) { - fprintf(stderr, "getsockname() failed"); + logmsg("getsockname() failed with error: %d", SOCKERRNO); return CURL_SOCKET_BAD; } *port = ntohs(add.sin_port); @@ -489,6 +489,7 @@ int main(int argc, char *argv[]) FILE *pidfile; char *pidname= (char *)".sockfilt.pid"; int rc; + int error; int arg=1; enum sockmode mode = PASSIVE_LISTEN; /* default */ @@ -631,7 +632,10 @@ int main(int argc, char *argv[]) logmsg("Wrote pid %d to %s", pid, pidname); } else { - fprintf(stderr, "Couldn't write pid file\n"); + error = ERRNO; + logmsg("fopen() failed with error: %d %s\n", error, strerror(error)); + logmsg("Error opening file: %s\n", pidname); + logmsg("Couldn't write pid file\n"); sclose(sock); return 1; } diff --git a/tests/server/sws.c b/tests/server/sws.c index 88f72218f..2ff9eb80c 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -197,6 +197,7 @@ int ProcessRequest(struct httprequest *req) char logbuf[256]; int prot_major, prot_minor; char *end; + int error; end = strstr(line, END_OF_HEADERS); logmsg("ProcessRequest() called"); @@ -263,6 +264,9 @@ int ProcessRequest(struct httprequest *req) stream=fopen(filename, "rb"); if(!stream) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", filename); logmsg("Couldn't open test file %d", req->testno); req->open = FALSE; /* closes connection */ return 1; /* done */ @@ -569,6 +573,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) FILE *dump; int persistant = TRUE; size_t responsesize; + int error; static char weare[256]; @@ -646,6 +651,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) stream=fopen(filename, "rb"); if(!stream) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", filename); logmsg("Couldn't open test file"); return 0; } @@ -658,6 +666,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) /* re-open the same file again */ stream=fopen(filename, "rb"); if(!stream) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", filename); logmsg("Couldn't open test file"); return 0; } @@ -670,6 +681,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) dump = fopen(RESPONSE_DUMP, "ab"); /* b is for windows-preparing */ if(!dump) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", RESPONSE_DUMP); logmsg("couldn't create logfile: " RESPONSE_DUMP); return -1; } @@ -872,7 +886,10 @@ int main(int argc, char *argv[]) fclose(pidfile); } else { - fprintf(stderr, "Couldn't write pid file\n"); + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", pidname); + logmsg("Couldn't write pid file"); sclose(sock); return 1; } diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index a97325b7a..e7fae0d47 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -424,6 +424,7 @@ int main(int argc, char **argv) curl_socket_t sock; int flag; int rc; + int error; struct testcase test; while(argc>arg) { @@ -513,8 +514,12 @@ int main(int argc, char **argv) fprintf(pidfile, "%d\n", (int)getpid()); fclose(pidfile); } - else - fprintf(stderr, "Couldn't write pid file\n"); + else { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", pidname); + logmsg("Couldn't write pid file"); + } logmsg("Running IPv%d version on port UDP/%d", #ifdef ENABLE_IPV6 @@ -554,8 +559,12 @@ int main(int argc, char **argv) if (tp->th_opcode == RRQ || tp->th_opcode == WRQ) { memset(&test, 0, sizeof(test)); server = fopen(REQUEST_DUMP, "ab"); - if(!server) + if(!server) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", REQUEST_DUMP); break; + } test.server = server; tftp(&test, tp, n); if(test.buffer) @@ -645,6 +654,7 @@ static int validate_access(struct testcase *test, { char *ptr; long testno; + int error; logmsg("trying to get file: %s mode %x", filename, mode); @@ -684,6 +694,9 @@ static int validate_access(struct testcase *test, if(file) { FILE *stream=fopen(file, "rb"); if(!stream) { + error = ERRNO; + logmsg("fopen() failed with error: %d %s", error, strerror(error)); + logmsg("Error opening file: %s", file); logmsg("Couldn't open test file: %s", file); return EACCESS; } diff --git a/tests/server/util.c b/tests/server/util.c index 7db611597..080ef4759 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -130,7 +130,7 @@ void win32_init(void) if (err != 0) { perror("Winsock init failed"); - logmsg("Error initialising winsock -- aborting\n"); + logmsg("Error initialising winsock -- aborting"); exit(1); } @@ -139,7 +139,7 @@ void win32_init(void) WSACleanup(); perror("Winsock init failed"); - logmsg("No suitable winsock.dll found -- aborting\n"); + logmsg("No suitable winsock.dll found -- aborting"); exit(1); } } |