aboutsummaryrefslogtreecommitdiff
path: root/tests/server/sws.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2013-01-09 15:10:23 +0100
committerYang Tse <yangsita@gmail.com>2013-01-09 22:23:50 +0100
commita6848250d279026252aa35cd9f93fafccc76333c (patch)
tree6cec3bacd94bd87c52b9e4bd3b73fe47704fbd3d /tests/server/sws.c
parenta9ca5e61e533def9e430597e36d70e96aee8e27a (diff)
test servers: fix errno, ERRNO and SOCKERRNO usage for W32/W64
Diffstat (limited to 'tests/server/sws.c')
-rw-r--r--tests/server/sws.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 44d899fd7..6d478c76c 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -56,6 +56,15 @@
/* include memdebug.h last */
#include "memdebug.h"
+#ifdef USE_WINSOCK
+#undef EINTR
+#define EINTR 4 /* errno.h value */
+#undef EAGAIN
+#define EAGAIN 11 /* errno.h value */
+#undef ERANGE
+#define ERANGE 34 /* errno.h value */
+#endif
+
#ifdef ENABLE_IPV6
static bool use_ipv6 = FALSE;
#endif
@@ -239,13 +248,13 @@ static volatile int exit_signal = 0;
static RETSIGTYPE exit_signal_handler(int signum)
{
- int old_errno = ERRNO;
+ int old_errno = errno;
if(got_exit_signal == 0) {
got_exit_signal = 1;
exit_signal = signum;
}
(void)signal(signum, exit_signal_handler);
- SET_ERRNO(old_errno);
+ errno = old_errno;
}
static void install_signal_handlers(void)
@@ -253,29 +262,29 @@ static void install_signal_handlers(void)
#ifdef SIGHUP
/* ignore SIGHUP signal */
if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGHUP handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGHUP handler: %s", strerror(errno));
#endif
#ifdef SIGPIPE
/* ignore SIGPIPE signal */
if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGPIPE handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGPIPE handler: %s", strerror(errno));
#endif
#ifdef SIGALRM
/* ignore SIGALRM signal */
if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR)
- logmsg("cannot install SIGALRM handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGALRM handler: %s", strerror(errno));
#endif
#ifdef SIGINT
/* handle SIGINT signal with our exit_signal_handler */
if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR)
- logmsg("cannot install SIGINT handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGINT handler: %s", strerror(errno));
else
siginterrupt(SIGINT, 1);
#endif
#ifdef SIGTERM
/* handle SIGTERM signal with our exit_signal_handler */
if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR)
- logmsg("cannot install SIGTERM handler: %s", strerror(ERRNO));
+ logmsg("cannot install SIGTERM handler: %s", strerror(errno));
else
siginterrupt(SIGTERM, 1);
#endif
@@ -316,7 +325,7 @@ static int parse_servercmd(struct httprequest *req)
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file %ld", req->testno);
@@ -617,9 +626,9 @@ static int ProcessRequest(struct httprequest *req)
while(*ptr && ISSPACE(*ptr))
ptr++;
endptr = ptr;
- SET_ERRNO(0);
+ errno = 0;
clen = strtoul(ptr, &endptr, 10);
- if((ptr == endptr) || !ISSPACE(*endptr) || (ERANGE == ERRNO)) {
+ if((ptr == endptr) || !ISSPACE(*endptr) || (ERANGE == errno)) {
/* this assumes that a zero Content-Length is valid */
logmsg("Found invalid Content-Length: (%s) in the request", ptr);
req->open = FALSE; /* closes connection */
@@ -756,7 +765,7 @@ static void storerequest(char *reqbuf, size_t totalsize)
do {
dump = fopen(dumpfile, "ab");
- } while ((dump == NULL) && ((error = ERRNO) == EINTR));
+ } while ((dump == NULL) && ((error = errno) == EINTR));
if (dump == NULL) {
logmsg("Error opening file %s error: %d %s",
dumpfile, error, strerror(error));
@@ -772,7 +781,7 @@ static void storerequest(char *reqbuf, size_t totalsize)
goto storerequest_cleanup;
if(written > 0)
writeleft -= written;
- } while ((writeleft > 0) && ((error = ERRNO) == EINTR));
+ } while ((writeleft > 0) && ((error = errno) == EINTR));
if(writeleft == 0)
logmsg("Wrote request (%zu bytes) input to %s", totalsize, dumpfile);
@@ -787,7 +796,7 @@ storerequest_cleanup:
do {
res = fclose(dump);
- } while(res && ((error = ERRNO) == EINTR));
+ } while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error closing file %s error: %d %s",
dumpfile, error, strerror(error));
@@ -1020,7 +1029,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
stream=fopen(filename, "rb");
if(!stream) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
@@ -1045,7 +1054,7 @@ 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;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file");
@@ -1090,7 +1099,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
dump = fopen(responsedump, "ab");
if(!dump) {
- error = ERRNO;
+ error = errno;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", responsedump);
if(ptr)
@@ -1134,7 +1143,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
do {
res = fclose(dump);
- } while(res && ((error = ERRNO) == EINTR));
+ } while(res && ((error = errno) == EINTR));
if(res)
logmsg("Error closing file %s error: %d %s",
responsedump, error, strerror(error));
@@ -1178,7 +1187,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
res = wait_ms(250);
if(res) {
/* should not happen */
- error = SOCKERRNO;
+ error = errno;
logmsg("wait_ms() failed with error: (%d) %s",
error, strerror(error));
break;