diff options
author | Yang Tse <yangsita@gmail.com> | 2007-02-16 16:01:19 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2007-02-16 16:01:19 +0000 |
commit | 4894ce16fc7af89d876e2f70db4dded7e1663198 (patch) | |
tree | 87d862afccc642c48f55d7549160859401b3face /tests/server | |
parent | aa4435c23b008450124d8c015e896d1002cb93ca (diff) |
use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling
Diffstat (limited to 'tests/server')
-rw-r--r-- | tests/server/sockfilt.c | 6 | ||||
-rw-r--r-- | tests/server/sws.c | 16 | ||||
-rw-r--r-- | tests/server/tftpd.c | 4 | ||||
-rw-r--r-- | tests/server/util.c | 13 | ||||
-rw-r--r-- | tests/server/util.h | 1 |
5 files changed, 13 insertions, 27 deletions
diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index ea3b43940..7ea0270d3 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -238,7 +238,7 @@ static int juggle(curl_socket_t *sockfdp, do { rc = select(maxfd + 1, &fds_read, &fds_write, &fds_err, &timeout); - } while((rc == -1) && (our_sockerrno() == EINTR)); + } while((rc == -1) && (SOCKERRNO == EINTR)); switch(rc) { case -1: @@ -447,7 +447,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock, /* start accepting connections */ rc = listen(sock, 4); if(0 != rc) { - logmsg("listen() failed with error: %d", errno); + logmsg("listen() failed with error: %d", SOCKERRNO); sclose(sock); return CURL_SOCKET_BAD; } @@ -570,7 +570,7 @@ int main(int argc, char *argv[]) sock = mksock(use_ipv6); if (CURL_SOCKET_BAD == sock) { - logmsg("Error opening socket: %d", errno); + logmsg("Error opening socket: %d", SOCKERRNO); return 1; } diff --git a/tests/server/sws.c b/tests/server/sws.c index 57c4b5eb5..88f72218f 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -466,7 +466,7 @@ void storerequest(char *reqbuf) do { dump = fopen(REQUEST_DUMP, "ab"); - } while ((dump == NULL) && ((error = errno) == EINTR)); + } while ((dump == NULL) && ((error = ERRNO) == EINTR)); if (dump == NULL) { logmsg("Error opening file %s error: %d", REQUEST_DUMP, error); logmsg("Failed to write request input to " REQUEST_DUMP); @@ -479,7 +479,7 @@ void storerequest(char *reqbuf) 1, (size_t)writeleft, dump); if (written > 0) writeleft -= written; - } while ((writeleft > 0) && ((error = errno) == EINTR)); + } while ((writeleft > 0) && ((error = ERRNO) == EINTR)); fclose(dump); /* close it ASAP */ @@ -515,7 +515,7 @@ static int get_request(curl_socket_t sock, struct httprequest *req) ssize_t got = sread(sock, reqbuf + req->offset, REQBUFSIZ - req->offset); if (got <= 0) { if (got < 0) { - logmsg("recv() returned error: %d", errno); + logmsg("recv() returned error: %d", SOCKERRNO); return DOCNUMBER_INTERNAL; } logmsg("Connection closed by client"); @@ -830,14 +830,14 @@ int main(int argc, char *argv[]) #endif if (CURL_SOCKET_BAD == sock) { - logmsg("Error opening socket: %d", errno); + logmsg("Error opening socket: %d", SOCKERRNO); return 1; } flag = 1; if (0 != setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &flag, sizeof(flag))) { - logmsg("setsockopt(SO_REUSEADDR) failed: %d", errno); + logmsg("setsockopt(SO_REUSEADDR) failed: %d", SOCKERRNO); sclose(sock); return 1; } @@ -861,7 +861,7 @@ int main(int argc, char *argv[]) } #endif /* ENABLE_IPV6 */ if(0 != rc) { - logmsg("Error binding socket: %d", errno); + logmsg("Error binding socket: %d", SOCKERRNO); sclose(sock); return 1; } @@ -888,7 +888,7 @@ int main(int argc, char *argv[]) /* start accepting connections */ rc = listen(sock, 5); if(0 != rc) { - logmsg("listen() failed with error: %d", errno); + logmsg("listen() failed with error: %d", SOCKERRNO); sclose(sock); return 1; } @@ -897,7 +897,7 @@ int main(int argc, char *argv[]) msgsock = accept(sock, NULL, NULL); if (CURL_SOCKET_BAD == msgsock) { - printf("MAJOR ERROR: accept() failed with error: %d\n", errno); + printf("MAJOR ERROR: accept() failed with error: %d\n", SOCKERRNO); break; } diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index 561f2f044..a97325b7a 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -749,7 +749,7 @@ static void sendtftp(struct testcase *test, struct formats *pf) do { size = readit(test, &dp, pf->f_convert); if (size < 0) { - nak(errno + 100); + nak(ERRNO + 100); return; } dp->th_opcode = htons((u_short)DATA); @@ -864,7 +864,7 @@ send_ack: size = writeit(test, &dp, (int)(n - 4), pf->f_convert); if (size != (n-4)) { /* ahem */ if (size < 0) - nak(errno + 100); + nak(ERRNO + 100); else nak(ENOSPACE); goto abort; diff --git a/tests/server/util.c b/tests/server/util.c index ddc4bc949..5dbf6e658 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -59,19 +59,6 @@ const struct in6_addr in6addr_any = {{ IN6ADDR_ANY_INIT }}; #endif -/* - * our_sockerrno() returns the *socket-related* errno (or equivalent) on this - * platform to hide platform specific for the function that calls this. - */ -int our_sockerrno(void) -{ -#ifdef USE_WINSOCK - return (int)WSAGetLastError(); -#else - return errno; -#endif -} - /* someone else must set this properly */ extern const char *serverlogfile; diff --git a/tests/server/util.h b/tests/server/util.h index fa225c036..b0b4ae4c9 100644 --- a/tests/server/util.h +++ b/tests/server/util.h @@ -23,7 +23,6 @@ * $Id$ ***************************************************************************/ -int our_sockerrno(void); void logmsg(const char *msg, ...); #ifndef FALSE |