aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-07 09:04:37 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-07 09:04:37 +0000
commit7b8d280e45f434cab6508b2186cd3b286a9c7b7c (patch)
treeaf0f89f29063d18bd4ac9820a932760da957cfde
parent6d7d5bf7847634a7906e379e08907ec7e2b5f920 (diff)
downloadlibmicrohttpd-7b8d280e45f434cab6508b2186cd3b286a9c7b7c.tar.gz
libmicrohttpd-7b8d280e45f434cab6508b2186cd3b286a9c7b7c.zip
-reverting removal of Plibc, select on pipes problem is critial
-rw-r--r--src/examples/Makefile.am2
-rw-r--r--src/include/platform.h27
-rw-r--r--src/microhttpd/connection.c48
-rw-r--r--src/microhttpd/daemon.c310
-rw-r--r--src/microhttpd/memorypool.c18
-rw-r--r--src/microspdy/Makefile.am5
-rw-r--r--src/spdy2http/Makefile.am5
-rw-r--r--src/testcurl/test_options.c12
-rw-r--r--src/testspdy/Makefile.am5
9 files changed, 169 insertions, 263 deletions
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am
index da51cf24..5dbd52ef 100644
--- a/src/examples/Makefile.am
+++ b/src/examples/Makefile.am
@@ -60,7 +60,7 @@ noinst_PROGRAMS += \
60endif 60endif
61 61
62if HAVE_W32 62if HAVE_W32
63AM_CFLAGS += -DWINDOWS 63AM_CFLAGS = -DWINDOWS
64endif 64endif
65 65
66minimal_example_SOURCES = \ 66minimal_example_SOURCES = \
diff --git a/src/include/platform.h b/src/include/platform.h
index 6bcbc233..befebbbe 100644
--- a/src/include/platform.h
+++ b/src/include/platform.h
@@ -109,32 +109,7 @@
109#include <arpa/inet.h> 109#include <arpa/inet.h>
110#endif 110#endif
111 111
112#ifndef WINDOWS 112#include <plibc.h>
113
114#define DIR_SEPARATOR '/'
115#define DIR_SEPARATOR_STR "/"
116#define PATH_SEPARATOR ':'
117#define PATH_SEPARATOR_STR ":"
118#define NEWLINE "\n"
119
120#else /* ifndef WINDOWS */
121
122#include <ws2tcpip.h>
123#include <windows.h>
124
125#define DIR_SEPARATOR '\\'
126#define DIR_SEPARATOR_STR "\\"
127#define PATH_SEPARATOR ';'
128#define PATH_SEPARATOR_STR ";"
129#define NEWLINE "\r\n"
130
131#define SHUT_WR SD_SEND
132#define SHUT_RD SD_RECEIVE
133#define SHUT_RDWR SD_BOTH
134
135#define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__)
136
137#endif /* ifndef WINDOWS */
138 113
139 114
140#endif 115#endif
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index a99cbd2a..e198b6cd 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -262,7 +262,7 @@ MHD_connection_close (struct MHD_Connection *connection,
262 262
263 daemon = connection->daemon; 263 daemon = connection->daemon;
264 if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO)) 264 if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO))
265 shutdown (connection->socket_fd, 265 SHUTDOWN (connection->socket_fd,
266 (MHD_YES == connection->read_closed) ? SHUT_WR : SHUT_RDWR); 266 (MHD_YES == connection->read_closed) ? SHUT_WR : SHUT_RDWR);
267 connection->state = MHD_CONNECTION_CLOSED; 267 connection->state = MHD_CONNECTION_CLOSED;
268 connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; 268 connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP;
@@ -566,7 +566,7 @@ add_extra_headers (struct MHD_Connection *connection)
566 Note that the change from 'SHOULD NOT' to 'MUST NOT' is 566 Note that the change from 'SHOULD NOT' to 'MUST NOT' is
567 a recent development of the HTTP 1.1 specification. 567 a recent development of the HTTP 1.1 specification.
568 */ 568 */
569 sprintf (buf, 569 SPRINTF (buf,
570 MHD_UNSIGNED_LONG_LONG_PRINTF, 570 MHD_UNSIGNED_LONG_LONG_PRINTF,
571 (MHD_UNSIGNED_LONG_LONG) connection->response->total_size); 571 (MHD_UNSIGNED_LONG_LONG) connection->response->total_size);
572 MHD_add_response_header (connection->response, 572 MHD_add_response_header (connection->response,
@@ -598,19 +598,15 @@ get_date_string (char *date)
598 time_t t; 598 time_t t;
599 599
600 time (&t); 600 time (&t);
601#ifndef WINDOWS
602 gmtime_r (&t, &now); 601 gmtime_r (&t, &now);
603#else 602 SPRINTF (date,
604 gmtime_s (&now, &t);
605#endif
606 sprintf (date,
607 "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n", 603 "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n",
608 days[now.tm_wday % 7], 604 days[now.tm_wday % 7],
609 (unsigned int) now.tm_mday, 605 (unsigned int) now.tm_mday,
610 mons[now.tm_mon % 12], 606 mons[now.tm_mon % 12],
611 (unsigned int) (1900 + now.tm_year), 607 (unsigned int) (1900 + now.tm_year),
612 (unsigned int) now.tm_hour, 608 (unsigned int) now.tm_hour,
613 (unsigned int) now.tm_min, 609 (unsigned int) now.tm_min,
614 (unsigned int) now.tm_sec); 610 (unsigned int) now.tm_sec);
615} 611}
616 612
@@ -685,21 +681,21 @@ build_header_response (struct MHD_Connection *connection)
685 add_extra_headers (connection); 681 add_extra_headers (connection);
686 rc = connection->responseCode & (~MHD_ICY_FLAG); 682 rc = connection->responseCode & (~MHD_ICY_FLAG);
687 reason_phrase = MHD_get_reason_phrase_for (rc); 683 reason_phrase = MHD_get_reason_phrase_for (rc);
688 sprintf (code, 684 SPRINTF (code,
689 "%s %u %s\r\n", 685 "%s %u %s\r\n",
690 (0 != (connection->responseCode & MHD_ICY_FLAG)) 686 (0 != (connection->responseCode & MHD_ICY_FLAG))
691 ? "ICY" 687 ? "ICY"
692 : ( (0 == strcasecmp (MHD_HTTP_VERSION_1_0, 688 : ( (0 == strcasecmp (MHD_HTTP_VERSION_1_0,
693 connection->version)) 689 connection->version))
694 ? MHD_HTTP_VERSION_1_0 690 ? MHD_HTTP_VERSION_1_0
695 : MHD_HTTP_VERSION_1_1), 691 : MHD_HTTP_VERSION_1_1),
696 rc, 692 rc,
697 reason_phrase); 693 reason_phrase);
698 off = strlen (code); 694 off = strlen (code);
699 /* estimate size */ 695 /* estimate size */
700 size = off + 2; /* extra \r\n at the end */ 696 size = off + 2; /* extra \r\n at the end */
701 kind = MHD_HEADER_KIND; 697 kind = MHD_HEADER_KIND;
702 if ( (0 == (connection->daemon->options & MHD_SUPPRESS_DATE_NO_CLOCK)) && 698 if ( (0 == (connection->daemon->options & MHD_SUPPRESS_DATE_NO_CLOCK)) &&
703 (NULL == MHD_get_response_header (connection->response, 699 (NULL == MHD_get_response_header (connection->response,
704 MHD_HTTP_HEADER_DATE)) ) 700 MHD_HTTP_HEADER_DATE)) )
705 get_date_string (date); 701 get_date_string (date);
@@ -749,9 +745,9 @@ build_header_response (struct MHD_Connection *connection)
749 } 745 }
750 for (pos = connection->response->first_header; NULL != pos; pos = pos->next) 746 for (pos = connection->response->first_header; NULL != pos; pos = pos->next)
751 if (pos->kind == kind) 747 if (pos->kind == kind)
752 off += sprintf (&data[off], 748 off += SPRINTF (&data[off],
753 "%s: %s\r\n", 749 "%s: %s\r\n",
754 pos->header, 750 pos->header,
755 pos->value); 751 pos->value);
756 if (connection->state == MHD_CONNECTION_FOOTERS_RECEIVED) 752 if (connection->state == MHD_CONNECTION_FOOTERS_RECEIVED)
757 { 753 {
@@ -1511,9 +1507,9 @@ do_read (struct MHD_Connection *connection)
1511 "Failed to receive data: %s\n", 1507 "Failed to receive data: %s\n",
1512 gnutls_strerror (bytes_read)); 1508 gnutls_strerror (bytes_read));
1513 else 1509 else
1514#endif 1510#endif
1515 MHD_DLOG (connection->daemon, 1511 MHD_DLOG (connection->daemon,
1516 "Failed to receive data: %s\n", strerror (errno)); 1512 "Failed to receive data: %s\n", STRERROR (errno));
1517#endif 1513#endif
1518 CONNECTION_CLOSE_ERROR (connection, NULL); 1514 CONNECTION_CLOSE_ERROR (connection, NULL);
1519 return MHD_YES; 1515 return MHD_YES;
@@ -1524,7 +1520,7 @@ do_read (struct MHD_Connection *connection)
1524 connection->read_closed = MHD_YES; 1520 connection->read_closed = MHD_YES;
1525 /* shutdown is not required here, as the other side already 1521 /* shutdown is not required here, as the other side already
1526 knows; so flagging this internally should suffice */ 1522 knows; so flagging this internally should suffice */
1527 /* shutdown (connection->socket_fd, SHUT_RD); */ 1523 /* SHUTDOWN (connection->socket_fd, SHUT_RD); */
1528 return MHD_YES; 1524 return MHD_YES;
1529 } 1525 }
1530 connection->read_buffer_offset += bytes_read; 1526 connection->read_buffer_offset += bytes_read;
@@ -1560,9 +1556,9 @@ do_write (struct MHD_Connection *connection)
1560 "Failed to send data: %s\n", 1556 "Failed to send data: %s\n",
1561 gnutls_strerror (ret)); 1557 gnutls_strerror (ret));
1562 else 1558 else
1563#endif 1559#endif
1564 MHD_DLOG (connection->daemon, 1560 MHD_DLOG (connection->daemon,
1565 "Failed to send data: %s\n", strerror (errno)); 1561 "Failed to send data: %s\n", STRERROR (errno));
1566#endif 1562#endif
1567 CONNECTION_CLOSE_ERROR (connection, NULL); 1563 CONNECTION_CLOSE_ERROR (connection, NULL);
1568 return MHD_YES; 1564 return MHD_YES;
@@ -1918,7 +1914,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1918 break; 1914 break;
1919#if HAVE_MESSAGES 1915#if HAVE_MESSAGES
1920 MHD_DLOG (connection->daemon, 1916 MHD_DLOG (connection->daemon,
1921 "Failed to send data: %s\n", strerror (errno)); 1917 "Failed to send data: %s\n", STRERROR (errno));
1922#endif 1918#endif
1923 CONNECTION_CLOSE_ERROR (connection, NULL); 1919 CONNECTION_CLOSE_ERROR (connection, NULL);
1924 return MHD_YES; 1920 return MHD_YES;
@@ -1980,7 +1976,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
1980 return MHD_YES; 1976 return MHD_YES;
1981#if HAVE_MESSAGES 1977#if HAVE_MESSAGES
1982 MHD_DLOG (connection->daemon, 1978 MHD_DLOG (connection->daemon,
1983 "Failed to send data: %s\n", strerror (errno)); 1979 "Failed to send data: %s\n", STRERROR (errno));
1984#endif 1980#endif
1985 CONNECTION_CLOSE_ERROR (connection, NULL); 1981 CONNECTION_CLOSE_ERROR (connection, NULL);
1986 return MHD_YES; 1982 return MHD_YES;
@@ -2531,7 +2527,7 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection)
2531 if (0 != (daemon->options & MHD_USE_DEBUG)) 2527 if (0 != (daemon->options & MHD_USE_DEBUG))
2532 MHD_DLOG (daemon, 2528 MHD_DLOG (daemon,
2533 "Call to epoll_ctl failed: %s\n", 2529 "Call to epoll_ctl failed: %s\n",
2534 strerror (errno)); 2530 STRERROR (errno));
2535#endif 2531#endif
2536 connection->state = MHD_CONNECTION_CLOSED; 2532 connection->state = MHD_CONNECTION_CLOSED;
2537 cleanup_connection (connection); 2533 cleanup_connection (connection);
@@ -2690,7 +2686,7 @@ MHD_queue_response (struct MHD_Connection *connection,
2690 refuse to read body / footers or further 2686 refuse to read body / footers or further
2691 requests! */ 2687 requests! */
2692 if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO)) 2688 if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO))
2693 (void) shutdown (connection->socket_fd, SHUT_RD); 2689 (void) SHUTDOWN (connection->socket_fd, SHUT_RD);
2694 connection->read_closed = MHD_YES; 2690 connection->read_closed = MHD_YES;
2695 connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; 2691 connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
2696 } 2692 }
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index e639c229..a6a93e77 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -294,14 +294,14 @@ MHD_ip_limit_add (struct MHD_Daemon *daemon,
294 MHD_ip_count_lock (daemon); 294 MHD_ip_count_lock (daemon);
295 295
296 /* Search for the IP address */ 296 /* Search for the IP address */
297 if (NULL == (nodep = tsearch (key, 297 if (NULL == (nodep = TSEARCH (key,
298 &daemon->per_ip_connection_count, 298 &daemon->per_ip_connection_count,
299 &MHD_ip_addr_compare))) 299 &MHD_ip_addr_compare)))
300 { 300 {
301#if HAVE_MESSAGES 301#if HAVE_MESSAGES
302 MHD_DLOG (daemon, 302 MHD_DLOG (daemon,
303 "Failed to add IP connection count node\n"); 303 "Failed to add IP connection count node\n");
304#endif 304#endif
305 MHD_ip_count_unlock (daemon); 305 MHD_ip_count_unlock (daemon);
306 free (key); 306 free (key);
307 return MHD_NO; 307 return MHD_NO;
@@ -350,10 +350,10 @@ MHD_ip_limit_del (struct MHD_Daemon *daemon,
350 MHD_ip_count_lock (daemon); 350 MHD_ip_count_lock (daemon);
351 351
352 /* Search for the IP address */ 352 /* Search for the IP address */
353 if (NULL == (nodep = tfind (&search_key, 353 if (NULL == (nodep = TFIND (&search_key,
354 &daemon->per_ip_connection_count, 354 &daemon->per_ip_connection_count,
355 &MHD_ip_addr_compare))) 355 &MHD_ip_addr_compare)))
356 { 356 {
357 /* Something's wrong if we couldn't find an IP address 357 /* Something's wrong if we couldn't find an IP address
358 * that was previously added */ 358 * that was previously added */
359 MHD_PANIC ("Failed to find previously-added IP address\n"); 359 MHD_PANIC ("Failed to find previously-added IP address\n");
@@ -367,8 +367,8 @@ MHD_ip_limit_del (struct MHD_Daemon *daemon,
367 /* Remove the node entirely if count reduces to 0 */ 367 /* Remove the node entirely if count reduces to 0 */
368 if (0 == --found_key->count) 368 if (0 == --found_key->count)
369 { 369 {
370 tdelete (found_key, 370 TDELETE (found_key,
371 &daemon->per_ip_connection_count, 371 &daemon->per_ip_connection_count,
372 &MHD_ip_addr_compare); 372 &MHD_ip_addr_compare);
373 free (found_key); 373 free (found_key);
374 } 374 }
@@ -696,7 +696,7 @@ MHD_handle_connection (void *data)
696 /* how did we get here!? */ 696 /* how did we get here!? */
697 goto exit; 697 goto exit;
698 } 698 }
699 num_ready = select (max + 1, &rs, &ws, NULL, tvp); 699 num_ready = SELECT (max + 1, &rs, &ws, NULL, tvp);
700 if (num_ready < 0) 700 if (num_ready < 0)
701 { 701 {
702 if (EINTR == errno) 702 if (EINTR == errno)
@@ -705,7 +705,7 @@ MHD_handle_connection (void *data)
705 MHD_DLOG (con->daemon, 705 MHD_DLOG (con->daemon,
706 "Error during select (%d): `%s'\n", 706 "Error during select (%d): `%s'\n",
707 max, 707 max,
708 strerror (errno)); 708 STRERROR (errno));
709#endif 709#endif
710 break; 710 break;
711 } 711 }
@@ -751,7 +751,7 @@ MHD_handle_connection (void *data)
751 continue; 751 continue;
752#if HAVE_MESSAGES 752#if HAVE_MESSAGES
753 MHD_DLOG (con->daemon, "Error during poll: `%s'\n", 753 MHD_DLOG (con->daemon, "Error during poll: `%s'\n",
754 strerror (errno)); 754 STRERROR (errno));
755#endif 755#endif
756 break; 756 break;
757 } 757 }
@@ -814,7 +814,7 @@ recv_param_adapter (struct MHD_Connection *connection,
814 errno = ENOTCONN; 814 errno = ENOTCONN;
815 return -1; 815 return -1;
816 } 816 }
817 ret = recv (connection->socket_fd, other, i, MSG_NOSIGNAL); 817 ret = RECV (connection->socket_fd, other, i, MSG_NOSIGNAL);
818#if EPOLL_SUPPORT 818#if EPOLL_SUPPORT
819 if (ret < (ssize_t) i) 819 if (ret < (ssize_t) i)
820 { 820 {
@@ -853,7 +853,7 @@ send_param_adapter (struct MHD_Connection *connection,
853 return -1; 853 return -1;
854 } 854 }
855 if (0 != (connection->daemon->options & MHD_USE_SSL)) 855 if (0 != (connection->daemon->options & MHD_USE_SSL))
856 return send (connection->socket_fd, other, i, MSG_NOSIGNAL); 856 return SEND (connection->socket_fd, other, i, MSG_NOSIGNAL);
857#if LINUX 857#if LINUX
858 if ( (connection->write_buffer_append_offset == 858 if ( (connection->write_buffer_append_offset ==
859 connection->write_buffer_send_offset) && 859 connection->write_buffer_send_offset) &&
@@ -889,7 +889,7 @@ send_param_adapter (struct MHD_Connection *connection,
889 http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */ 889 http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */
890 } 890 }
891#endif 891#endif
892 ret = send (connection->socket_fd, other, i, MSG_NOSIGNAL); 892 ret = SEND (connection->socket_fd, other, i, MSG_NOSIGNAL);
893#if EPOLL_SUPPORT 893#if EPOLL_SUPPORT
894 if (ret < (ssize_t) i) 894 if (ret < (ssize_t) i)
895 { 895 {
@@ -1009,7 +1009,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1009 client_socket, 1009 client_socket,
1010 addr, addrlen); 1010 addr, addrlen);
1011 /* all pools are at their connection limit, must refuse */ 1011 /* all pools are at their connection limit, must refuse */
1012 if (0 != close (client_socket)) 1012 if (0 != CLOSE (client_socket))
1013 MHD_PANIC ("close failed\n"); 1013 MHD_PANIC ("close failed\n");
1014 return MHD_NO; 1014 return MHD_NO;
1015 } 1015 }
@@ -1024,7 +1024,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1024 client_socket, 1024 client_socket,
1025 FD_SETSIZE); 1025 FD_SETSIZE);
1026#endif 1026#endif
1027 if (0 != close (client_socket)) 1027 if (0 != CLOSE (client_socket))
1028 MHD_PANIC ("close failed\n"); 1028 MHD_PANIC ("close failed\n");
1029 return MHD_NO; 1029 return MHD_NO;
1030 } 1030 }
@@ -1044,7 +1044,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1044 MHD_DLOG (daemon, 1044 MHD_DLOG (daemon,
1045 "Server reached connection limit (closing inbound connection)\n"); 1045 "Server reached connection limit (closing inbound connection)\n");
1046#endif 1046#endif
1047 if (0 != close (client_socket)) 1047 if (0 != CLOSE (client_socket))
1048 MHD_PANIC ("close failed\n"); 1048 MHD_PANIC ("close failed\n");
1049 return MHD_NO; 1049 return MHD_NO;
1050 } 1050 }
@@ -1059,7 +1059,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1059 MHD_DLOG (daemon, "Connection rejected, closing connection\n"); 1059 MHD_DLOG (daemon, "Connection rejected, closing connection\n");
1060#endif 1060#endif
1061#endif 1061#endif
1062 if (0 != close (client_socket)) 1062 if (0 != CLOSE (client_socket))
1063 MHD_PANIC ("close failed\n"); 1063 MHD_PANIC ("close failed\n");
1064 MHD_ip_limit_del (daemon, addr, addrlen); 1064 MHD_ip_limit_del (daemon, addr, addrlen);
1065 return MHD_NO; 1065 return MHD_NO;
@@ -1080,9 +1080,9 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1080#if HAVE_MESSAGES 1080#if HAVE_MESSAGES
1081 MHD_DLOG (daemon, 1081 MHD_DLOG (daemon,
1082 "Error allocating memory: %s\n", 1082 "Error allocating memory: %s\n",
1083 strerror (errno)); 1083 STRERROR (errno));
1084#endif 1084#endif
1085 if (0 != close (client_socket)) 1085 if (0 != CLOSE (client_socket))
1086 MHD_PANIC ("close failed\n"); 1086 MHD_PANIC ("close failed\n");
1087 MHD_ip_limit_del (daemon, addr, addrlen); 1087 MHD_ip_limit_del (daemon, addr, addrlen);
1088 return MHD_NO; 1088 return MHD_NO;
@@ -1094,9 +1094,9 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1094#if HAVE_MESSAGES 1094#if HAVE_MESSAGES
1095 MHD_DLOG (daemon, 1095 MHD_DLOG (daemon,
1096 "Error allocating memory: %s\n", 1096 "Error allocating memory: %s\n",
1097 strerror (errno)); 1097 STRERROR (errno));
1098#endif 1098#endif
1099 if (0 != close (client_socket)) 1099 if (0 != CLOSE (client_socket))
1100 MHD_PANIC ("close failed\n"); 1100 MHD_PANIC ("close failed\n");
1101 MHD_ip_limit_del (daemon, addr, addrlen); 1101 MHD_ip_limit_del (daemon, addr, addrlen);
1102 free (connection); 1102 free (connection);
@@ -1109,9 +1109,9 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1109#if HAVE_MESSAGES 1109#if HAVE_MESSAGES
1110 MHD_DLOG (daemon, 1110 MHD_DLOG (daemon,
1111 "Error allocating memory: %s\n", 1111 "Error allocating memory: %s\n",
1112 strerror (errno)); 1112 STRERROR (errno));
1113#endif 1113#endif
1114 if (0 != close (client_socket)) 1114 if (0 != CLOSE (client_socket))
1115 MHD_PANIC ("close failed\n"); 1115 MHD_PANIC ("close failed\n");
1116 MHD_ip_limit_del (daemon, addr, addrlen); 1116 MHD_ip_limit_del (daemon, addr, addrlen);
1117 MHD_pool_destroy (connection->pool); 1117 MHD_pool_destroy (connection->pool);
@@ -1149,7 +1149,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1149 MHD_DLOG (daemon, 1149 MHD_DLOG (daemon,
1150 "Failed to make socket %d non-blocking: %s\n", 1150 "Failed to make socket %d non-blocking: %s\n",
1151 connection->socket_fd, 1151 connection->socket_fd,
1152 strerror (errno)); 1152 STRERROR (errno));
1153#endif 1153#endif
1154 } 1154 }
1155#else 1155#else
@@ -1159,7 +1159,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1159#if HAVE_MESSAGES 1159#if HAVE_MESSAGES
1160 MHD_DLOG (daemon, 1160 MHD_DLOG (daemon,
1161 "Failed to make socket non-blocking: %s\n", 1161 "Failed to make socket non-blocking: %s\n",
1162 strerror (errno)); 1162 STRERROR (errno));
1163#endif 1163#endif
1164 } 1164 }
1165#endif 1165#endif
@@ -1190,7 +1190,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1190 "Failed to setup TLS credentials: unknown credential type %d\n", 1190 "Failed to setup TLS credentials: unknown credential type %d\n",
1191 daemon->cred_type); 1191 daemon->cred_type);
1192#endif 1192#endif
1193 if (0 != close (client_socket)) 1193 if (0 != CLOSE (client_socket))
1194 MHD_PANIC ("close failed\n"); 1194 MHD_PANIC ("close failed\n");
1195 MHD_ip_limit_del (daemon, addr, addrlen); 1195 MHD_ip_limit_del (daemon, addr, addrlen);
1196 free (connection->addr); 1196 free (connection->addr);
@@ -1233,7 +1233,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1233 { 1233 {
1234#if HAVE_MESSAGES 1234#if HAVE_MESSAGES
1235 MHD_DLOG (daemon, "Failed to create a thread: %s\n", 1235 MHD_DLOG (daemon, "Failed to create a thread: %s\n",
1236 strerror (res_thread_create)); 1236 STRERROR (res_thread_create));
1237#endif 1237#endif
1238 goto cleanup; 1238 goto cleanup;
1239 } 1239 }
@@ -1256,7 +1256,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1256 if (0 != (daemon->options & MHD_USE_DEBUG)) 1256 if (0 != (daemon->options & MHD_USE_DEBUG))
1257 MHD_DLOG (daemon, 1257 MHD_DLOG (daemon,
1258 "Call to epoll_ctl failed: %s\n", 1258 "Call to epoll_ctl failed: %s\n",
1259 strerror (errno)); 1259 STRERROR (errno));
1260#endif 1260#endif
1261 goto cleanup; 1261 goto cleanup;
1262 } 1262 }
@@ -1276,7 +1276,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
1276 return MHD_YES; 1276 return MHD_YES;
1277#if HTTPS_SUPPORT || EPOLL_SUPPORT 1277#if HTTPS_SUPPORT || EPOLL_SUPPORT
1278 cleanup: 1278 cleanup:
1279 if (0 != close (client_socket)) 1279 if (0 != CLOSE (client_socket))
1280 MHD_PANIC ("close failed\n"); 1280 MHD_PANIC ("close failed\n");
1281 MHD_ip_limit_del (daemon, addr, addrlen); 1281 MHD_ip_limit_del (daemon, addr, addrlen);
1282 if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && 1282 if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
@@ -1321,9 +1321,6 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
1321#endif 1321#endif
1322 struct sockaddr *addr = (struct sockaddr *) &addrstorage; 1322 struct sockaddr *addr = (struct sockaddr *) &addrstorage;
1323 socklen_t addrlen; 1323 socklen_t addrlen;
1324#ifdef WINDOWS
1325 LPVOID msgBuffer;
1326#endif
1327 int s; 1324 int s;
1328 int fd; 1325 int fd;
1329 int nonblock; 1326 int nonblock;
@@ -1344,37 +1341,20 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
1344#if HAVE_ACCEPT4 1341#if HAVE_ACCEPT4
1345 s = accept4 (fd, addr, &addrlen, SOCK_CLOEXEC | nonblock); 1342 s = accept4 (fd, addr, &addrlen, SOCK_CLOEXEC | nonblock);
1346#else 1343#else
1347 s = accept (fd, addr, &addrlen); 1344 s = ACCEPT (fd, addr, &addrlen);
1348#endif 1345#endif
1349 if ((-1 == s) || (addrlen <= 0)) 1346 if ((-1 == s) || (addrlen <= 0))
1350 { 1347 {
1351#if HAVE_MESSAGES 1348#if HAVE_MESSAGES
1352 /* This could be a common occurance with multiple worker threads */ 1349 /* This could be a common occurance with multiple worker threads */
1353 if ((EAGAIN != errno) && (EWOULDBLOCK != errno)) 1350 if ((EAGAIN != errno) && (EWOULDBLOCK != errno))
1354 {
1355#ifndef WINDOWS
1356 MHD_DLOG (daemon, 1351 MHD_DLOG (daemon,
1357 "Error accepting connection: %s\n", 1352 "Error accepting connection: %s\n",
1358 strerror (errno)); 1353 STRERROR (errno));
1359#else
1360 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
1361 FORMAT_MESSAGE_FROM_SYSTEM |
1362 FORMAT_MESSAGE_IGNORE_INSERTS,
1363 NULL,
1364 (DWORD) GetLastError (),
1365 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
1366 (LPTSTR) &msgBuffer,
1367 0, NULL);
1368 MHD_DLOG (daemon,
1369 "Error accepting connection: %s\n",
1370 msgBuffer);
1371 LocalFree (msgBuffer);
1372#endif 1354#endif
1373#endif
1374 }
1375 if (-1 != s) 1355 if (-1 != s)
1376 { 1356 {
1377 if (0 != close (s)) 1357 if (0 != CLOSE (s))
1378 MHD_PANIC ("close failed\n"); 1358 MHD_PANIC ("close failed\n");
1379 /* just in case */ 1359 /* just in case */
1380 } 1360 }
@@ -1390,9 +1370,9 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
1390 if (0 != ioctlsocket (s, FIONBIO, &flags)) 1370 if (0 != ioctlsocket (s, FIONBIO, &flags))
1391 { 1371 {
1392#if HAVE_MESSAGES 1372#if HAVE_MESSAGES
1393 MHD_DLOG (daemon, 1373 MHD_DLOG (daemon,
1394 "Failed to make socket non-blocking: %s\n", 1374 "Failed to make socket non-blocking: %s\n",
1395 strerror (errno)); 1375 STRERROR (errno));
1396#endif 1376#endif
1397 } 1377 }
1398 if (!GetHandleInformation ((HANDLE) s, &dwFlags) || 1378 if (!GetHandleInformation ((HANDLE) s, &dwFlags) ||
@@ -1400,18 +1380,10 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
1400 !SetHandleInformation ((HANDLE) s, HANDLE_FLAG_INHERIT, 0))) 1380 !SetHandleInformation ((HANDLE) s, HANDLE_FLAG_INHERIT, 0)))
1401 { 1381 {
1402#if HAVE_MESSAGES 1382#if HAVE_MESSAGES
1403 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 1383 SetErrnoFromWinError (GetLastError ());
1404 FORMAT_MESSAGE_FROM_SYSTEM | 1384 MHD_DLOG (daemon,
1405 FORMAT_MESSAGE_IGNORE_INSERTS, 1385 "Failed to make socket non-inheritable: %s\n",
1406 NULL, 1386 STRERROR (errno));
1407 (DWORD) GetLastError(),
1408 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1409 (LPTSTR) &msgBuffer,
1410 0, NULL );
1411 MHD_DLOG (daemon,
1412 "Error accepting connection: %s\n",
1413 msgBuffer);
1414 LocalFree(msgBuffer);
1415#endif 1387#endif
1416 } 1388 }
1417#else 1389#else
@@ -1429,8 +1401,8 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
1429 { 1401 {
1430#if HAVE_MESSAGES 1402#if HAVE_MESSAGES
1431 MHD_DLOG (daemon, 1403 MHD_DLOG (daemon,
1432 "Failed to make socket non-inheritable: %s\n", 1404 "Failed to make socket non-inheritable: %s\n",
1433 strerror (errno)); 1405 STRERROR (errno));
1434#endif 1406#endif
1435 } 1407 }
1436#endif 1408#endif
@@ -1513,7 +1485,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
1513 pos->response = NULL; 1485 pos->response = NULL;
1514 } 1486 }
1515 if ( (-1 != pos->socket_fd) && 1487 if ( (-1 != pos->socket_fd) &&
1516 (0 != close (pos->socket_fd)) ) 1488 (0 != CLOSE (pos->socket_fd)) )
1517 MHD_PANIC ("close failed\n"); 1489 MHD_PANIC ("close failed\n");
1518 if (NULL != pos->addr) 1490 if (NULL != pos->addr)
1519 free (pos->addr); 1491 free (pos->addr);
@@ -1718,14 +1690,7 @@ MHD_select (struct MHD_Daemon *daemon,
1718 struct timeval timeout; 1690 struct timeval timeout;
1719 struct timeval *tv; 1691 struct timeval *tv;
1720 MHD_UNSIGNED_LONG_LONG ltimeout; 1692 MHD_UNSIGNED_LONG_LONG ltimeout;
1721#ifdef WINDOWS
1722 LPVOID msgBuffer;
1723 DWORD dwBytes;
1724#endif
1725 1693
1726#ifdef WINDOWS
1727loop_select:
1728#endif
1729 timeout.tv_sec = 0; 1694 timeout.tv_sec = 0;
1730 timeout.tv_usec = 0; 1695 timeout.tv_usec = 0;
1731 if (MHD_YES == daemon->shutdown) 1696 if (MHD_YES == daemon->shutdown)
@@ -1742,20 +1707,19 @@ loop_select:
1742 1707
1743 /* If we're at the connection limit, no need to 1708 /* If we're at the connection limit, no need to
1744 accept new connections. */ 1709 accept new connections. */
1745 if ( (0 == daemon->max_connections) && 1710 if ( (0 == daemon->max_connections) &&
1746 (-1 != daemon->socket_fd) ) 1711 (-1 != daemon->socket_fd) )
1747 FD_CLR (daemon->socket_fd, &rs); 1712 FD_CLR (daemon->socket_fd, &rs);
1748 } 1713 }
1749 else 1714 else
1750 { 1715 {
1751 /* accept only, have one thread per connection */ 1716 /* accept only, have one thread per connection */
1752 if (-1 != daemon->socket_fd) 1717 if (-1 != daemon->socket_fd)
1753 { 1718 {
1754 max = daemon->socket_fd; 1719 max = daemon->socket_fd;
1755 FD_SET (daemon->socket_fd, &rs); 1720 FD_SET (daemon->socket_fd, &rs);
1756 } 1721 }
1757 } 1722 }
1758#ifndef WINDOWS
1759 if (-1 != daemon->wpipe[0]) 1723 if (-1 != daemon->wpipe[0])
1760 { 1724 {
1761 FD_SET (daemon->wpipe[0], &rs); 1725 FD_SET (daemon->wpipe[0], &rs);
@@ -1763,18 +1727,12 @@ loop_select:
1763 if (max < daemon->wpipe[0]) 1727 if (max < daemon->wpipe[0])
1764 max = daemon->wpipe[0]; 1728 max = daemon->wpipe[0];
1765 } 1729 }
1766#endif
1767 1730
1768 tv = NULL; 1731 tv = NULL;
1769 if (MHD_NO == may_block) 1732 if (MHD_NO == may_block)
1770 { 1733 {
1771#ifndef WINDOWS
1772 timeout.tv_usec = 0; 1734 timeout.tv_usec = 0;
1773#else
1774 timeout.tv_usec = 100000;
1775#endif
1776 timeout.tv_sec = 0; 1735 timeout.tv_sec = 0;
1777
1778 tv = &timeout; 1736 tv = &timeout;
1779 } 1737 }
1780 else if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && 1738 else if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
@@ -1787,15 +1745,7 @@ loop_select:
1787 } 1745 }
1788 if (-1 == max) 1746 if (-1 == max)
1789 return MHD_YES; 1747 return MHD_YES;
1790#ifdef WINDOWS 1748 num_ready = SELECT (max + 1, &rs, &ws, &es, tv);
1791 if (tv == NULL)
1792 {
1793 timeout.tv_usec = 100000;
1794 timeout.tv_sec = 0;
1795 tv = &timeout;
1796 }
1797#endif
1798 num_ready = select (max + 1, &rs, &ws, &es, tv);
1799 if (MHD_YES == daemon->shutdown) 1749 if (MHD_YES == daemon->shutdown)
1800 return MHD_NO; 1750 return MHD_NO;
1801 if (num_ready < 0) 1751 if (num_ready < 0)
@@ -1803,41 +1753,10 @@ loop_select:
1803 if (EINTR == errno) 1753 if (EINTR == errno)
1804 return MHD_YES; 1754 return MHD_YES;
1805#if HAVE_MESSAGES 1755#if HAVE_MESSAGES
1806#ifndef WINDOWS 1756 MHD_DLOG (daemon, "select failed: %s\n", STRERROR (errno));
1807 MHD_DLOG (daemon, "select failed: %s\n", strerror (errno));
1808#else
1809 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
1810 FORMAT_MESSAGE_FROM_SYSTEM |
1811 FORMAT_MESSAGE_IGNORE_INSERTS,
1812 NULL,
1813 (DWORD) GetLastError(),
1814 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1815 (LPTSTR) &msgBuffer,
1816 0, NULL);
1817 MHD_DLOG (daemon, "select failed: %s\n", msgBuffer);
1818 LocalFree(msgBuffer);
1819#endif
1820#endif 1757#endif
1821 return MHD_NO; 1758 return MHD_NO;
1822 } 1759 }
1823#ifdef WINDOWS
1824 if (num_ready == 0) {
1825 if (-1 != daemon->wpipe[0])
1826 {
1827 if (! PeekNamedPipe((HANDLE) daemon->wpipe[0], NULL, 0, NULL, &dwBytes, NULL))
1828 {
1829 goto loop_select;
1830 }
1831 else if (dwBytes)
1832 FD_SET (daemon->wpipe[0], &rs);
1833 else
1834 goto loop_select;
1835 }
1836 else
1837 goto loop_select;
1838 }
1839#endif
1840
1841 return MHD_run_from_select (daemon, &rs, &ws, &es); 1760 return MHD_run_from_select (daemon, &rs, &ws, &es);
1842} 1761}
1843 1762
@@ -1931,7 +1850,7 @@ MHD_poll_all (struct MHD_Daemon *daemon,
1931#if HAVE_MESSAGES 1850#if HAVE_MESSAGES
1932 MHD_DLOG (daemon, 1851 MHD_DLOG (daemon,
1933 "poll failed: %s\n", 1852 "poll failed: %s\n",
1934 strerror (errno)); 1853 STRERROR (errno));
1935#endif 1854#endif
1936 return MHD_NO; 1855 return MHD_NO;
1937 } 1856 }
@@ -2031,7 +1950,7 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon,
2031 if (EINTR == errno) 1950 if (EINTR == errno)
2032 return MHD_YES; 1951 return MHD_YES;
2033#if HAVE_MESSAGES 1952#if HAVE_MESSAGES
2034 MHD_DLOG (daemon, "poll failed: %s\n", strerror (errno)); 1953 MHD_DLOG (daemon, "poll failed: %s\n", STRERROR (errno));
2035#endif 1954#endif
2036 return MHD_NO; 1955 return MHD_NO;
2037 } 1956 }
@@ -2124,7 +2043,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
2124 if (0 != (daemon->options & MHD_USE_DEBUG)) 2043 if (0 != (daemon->options & MHD_USE_DEBUG))
2125 MHD_DLOG (daemon, 2044 MHD_DLOG (daemon,
2126 "Call to epoll_ctl failed: %s\n", 2045 "Call to epoll_ctl failed: %s\n",
2127 strerror (errno)); 2046 STRERROR (errno));
2128#endif 2047#endif
2129 return MHD_NO; 2048 return MHD_NO;
2130 } 2049 }
@@ -2176,7 +2095,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
2176 if (0 != (daemon->options & MHD_USE_DEBUG)) 2095 if (0 != (daemon->options & MHD_USE_DEBUG))
2177 MHD_DLOG (daemon, 2096 MHD_DLOG (daemon,
2178 "Call to epoll_wait failed: %s\n", 2097 "Call to epoll_wait failed: %s\n",
2179 strerror (errno)); 2098 STRERROR (errno));
2180#endif 2099#endif
2181 return MHD_NO; 2100 return MHD_NO;
2182 } 2101 }
@@ -2762,19 +2681,19 @@ create_socket (int domain, int type, int protocol)
2762#ifdef WINDOWS 2681#ifdef WINDOWS
2763 DWORD dwFlags; 2682 DWORD dwFlags;
2764#endif 2683#endif
2765 2684
2766 /* use SOCK_STREAM rather than ai_socktype: some getaddrinfo 2685 /* use SOCK_STREAM rather than ai_socktype: some getaddrinfo
2767 * implementations do not set ai_socktype, e.g. RHL6.2. */ 2686 * implementations do not set ai_socktype, e.g. RHL6.2. */
2768 fd = socket (domain, ctype, protocol); 2687 fd = SOCKET (domain, ctype, protocol);
2769 if ( (-1 == fd) && (EINVAL == errno) && (0 != sock_cloexec) ) 2688 if ( (-1 == fd) && (EINVAL == errno) && (0 != sock_cloexec) )
2770 { 2689 {
2771 sock_cloexec = 0; 2690 sock_cloexec = 0;
2772 fd = socket(domain, type, protocol); 2691 fd = SOCKET(domain, type, protocol);
2773 } 2692 }
2774 if (-1 == fd) 2693 if (-1 == fd)
2775 return -1; 2694 return -1;
2776 if (0 != sock_cloexec) 2695 if (0 != sock_cloexec)
2777 return fd; /* this is it */ 2696 return fd; /* this is it */
2778 /* flag was not set during 'socket' call, let's try setting it manually */ 2697 /* flag was not set during 'socket' call, let's try setting it manually */
2779#ifndef WINDOWS 2698#ifndef WINDOWS
2780 flags = fcntl (fd, F_GETFD); 2699 flags = fcntl (fd, F_GETFD);
@@ -2783,6 +2702,9 @@ create_socket (int domain, int type, int protocol)
2783 if (!GetHandleInformation ((HANDLE) fd, &dwFlags)) 2702 if (!GetHandleInformation ((HANDLE) fd, &dwFlags))
2784#endif 2703#endif
2785 { 2704 {
2705#ifdef WINDOWS
2706 SetErrnoFromWinError (GetLastError ());
2707#endif
2786 return fd; /* good luck */ 2708 return fd; /* good luck */
2787 } 2709 }
2788#ifndef WINDOWS 2710#ifndef WINDOWS
@@ -2796,6 +2718,9 @@ create_socket (int domain, int type, int protocol)
2796 if (!SetHandleInformation ((HANDLE) fd, HANDLE_FLAG_INHERIT, 0)) 2718 if (!SetHandleInformation ((HANDLE) fd, HANDLE_FLAG_INHERIT, 0))
2797#endif 2719#endif
2798 { 2720 {
2721#ifdef WINDOWS
2722 SetErrnoFromWinError (GetLastError ());
2723#endif
2799 return fd; /* good luck */ 2724 return fd; /* good luck */
2800 } 2725 }
2801 return fd; 2726 return fd;
@@ -2822,7 +2747,7 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon)
2822 if (0 != (daemon->options & MHD_USE_DEBUG)) 2747 if (0 != (daemon->options & MHD_USE_DEBUG))
2823 MHD_DLOG (daemon, 2748 MHD_DLOG (daemon,
2824 "Call to epoll_create1 failed: %s\n", 2749 "Call to epoll_create1 failed: %s\n",
2825 strerror (errno)); 2750 STRERROR (errno));
2826#endif 2751#endif
2827 return MHD_NO; 2752 return MHD_NO;
2828 } 2753 }
@@ -2839,7 +2764,7 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon)
2839 if (0 != (daemon->options & MHD_USE_DEBUG)) 2764 if (0 != (daemon->options & MHD_USE_DEBUG))
2840 MHD_DLOG (daemon, 2765 MHD_DLOG (daemon,
2841 "Call to epoll_ctl failed: %s\n", 2766 "Call to epoll_ctl failed: %s\n",
2842 strerror (errno)); 2767 STRERROR (errno));
2843#endif 2768#endif
2844 return MHD_NO; 2769 return MHD_NO;
2845 } 2770 }
@@ -2887,15 +2812,15 @@ MHD_start_daemon_va (unsigned int flags,
2887 2812
2888#ifndef HAVE_INET6 2813#ifndef HAVE_INET6
2889 if (0 != (flags & MHD_USE_IPv6)) 2814 if (0 != (flags & MHD_USE_IPv6))
2890 return NULL; 2815 return NULL;
2891#endif 2816#endif
2892#ifndef HAVE_POLL_H 2817#ifndef HAVE_POLL_H
2893 if (0 != (flags & MHD_USE_POLL)) 2818 if (0 != (flags & MHD_USE_POLL))
2894 return NULL; 2819 return NULL;
2895#endif 2820#endif
2896#if ! HTTPS_SUPPORT 2821#if ! HTTPS_SUPPORT
2897 if (0 != (flags & MHD_USE_SSL)) 2822 if (0 != (flags & MHD_USE_SSL))
2898 return NULL; 2823 return NULL;
2899#endif 2824#endif
2900 if (NULL == dh) 2825 if (NULL == dh)
2901 return NULL; 2826 return NULL;
@@ -2940,17 +2865,12 @@ MHD_start_daemon_va (unsigned int flags,
2940 if (0 == (flags & (MHD_USE_SELECT_INTERNALLY | MHD_USE_THREAD_PER_CONNECTION))) 2865 if (0 == (flags & (MHD_USE_SELECT_INTERNALLY | MHD_USE_THREAD_PER_CONNECTION)))
2941 use_pipe = 0; /* useless if we are using 'external' select */ 2866 use_pipe = 0; /* useless if we are using 'external' select */
2942 if ( (use_pipe) && 2867 if ( (use_pipe) &&
2943#ifndef WINDOWS 2868 (0 != PIPE (daemon->wpipe)) )
2944 (0 != pipe (daemon->wpipe)) )
2945#else
2946 (0 == CreatePipe ((HANDLE *) &daemon->wpipe[0],
2947 (HANDLE *) &daemon->wpipe[1], NULL, 0)) )
2948#endif
2949 { 2869 {
2950#if HAVE_MESSAGES 2870#if HAVE_MESSAGES
2951 MHD_DLOG (daemon, 2871 MHD_DLOG (daemon,
2952 "Failed to create control pipe: %s\n", 2872 "Failed to create control pipe: %s\n",
2953 strerror (errno)); 2873 STRERROR (errno));
2954#endif 2874#endif
2955 free (daemon); 2875 free (daemon);
2956 return NULL; 2876 return NULL;
@@ -2963,9 +2883,9 @@ MHD_start_daemon_va (unsigned int flags,
2963 MHD_DLOG (daemon, 2883 MHD_DLOG (daemon,
2964 "file descriptor for control pipe exceeds maximum value\n"); 2884 "file descriptor for control pipe exceeds maximum value\n");
2965#endif 2885#endif
2966 if (0 != close (daemon->wpipe[0])) 2886 if (0 != CLOSE (daemon->wpipe[0]))
2967 MHD_PANIC ("close failed\n"); 2887 MHD_PANIC ("close failed\n");
2968 if (0 != close (daemon->wpipe[1])) 2888 if (0 != CLOSE (daemon->wpipe[1]))
2969 MHD_PANIC ("close failed\n"); 2889 MHD_PANIC ("close failed\n");
2970 free (daemon); 2890 free (daemon);
2971 return NULL; 2891 return NULL;
@@ -3017,7 +2937,7 @@ MHD_start_daemon_va (unsigned int flags,
3017#if HAVE_MESSAGES 2937#if HAVE_MESSAGES
3018 MHD_DLOG (daemon, 2938 MHD_DLOG (daemon,
3019 "Failed to allocate memory for nonce-nc map: %s\n", 2939 "Failed to allocate memory for nonce-nc map: %s\n",
3020 strerror (errno)); 2940 STRERROR (errno));
3021#endif 2941#endif
3022#if HTTPS_SUPPORT 2942#if HTTPS_SUPPORT
3023 if (0 != (flags & MHD_USE_SSL)) 2943 if (0 != (flags & MHD_USE_SSL))
@@ -3105,20 +3025,20 @@ MHD_start_daemon_va (unsigned int flags,
3105 if (0 != (flags & MHD_USE_DEBUG)) 3025 if (0 != (flags & MHD_USE_DEBUG))
3106 MHD_DLOG (daemon, 3026 MHD_DLOG (daemon,
3107 "Call to socket failed: %s\n", 3027 "Call to socket failed: %s\n",
3108 strerror (errno)); 3028 STRERROR (errno));
3109#endif 3029#endif
3110 goto free_and_fail; 3030 goto free_and_fail;
3111 } 3031 }
3112 if ( (setsockopt (socket_fd, 3032 if ( (0 > SETSOCKOPT (socket_fd,
3113 SOL_SOCKET, 3033 SOL_SOCKET,
3114 SO_REUSEADDR, 3034 SO_REUSEADDR,
3115 &on, sizeof (on))) && 3035 &on, sizeof (on))) &&
3116 (0 != (flags & MHD_USE_DEBUG)) ) 3036 (0 != (flags & MHD_USE_DEBUG)) )
3117 { 3037 {
3118#if HAVE_MESSAGES 3038#if HAVE_MESSAGES
3119 MHD_DLOG (daemon, 3039 MHD_DLOG (daemon,
3120 "setsockopt failed: %s\n", 3040 "setsockopt failed: %s\n",
3121 strerror (errno)); 3041 STRERROR (errno));
3122#endif 3042#endif
3123 } 3043 }
3124 3044
@@ -3170,30 +3090,30 @@ MHD_start_daemon_va (unsigned int flags,
3170#else 3090#else
3171 const char on = 1; 3091 const char on = 1;
3172#endif 3092#endif
3173 if ( (setsockopt (socket_fd, 3093 if ( (0 > SETSOCKOPT (socket_fd,
3174 IPPROTO_IPV6, IPV6_V6ONLY, 3094 IPPROTO_IPV6, IPV6_V6ONLY,
3175 &on, sizeof (on))) && 3095 &on, sizeof (on))) &&
3176 (0 != (flags & MHD_USE_DEBUG)) ) 3096 (0 != (flags & MHD_USE_DEBUG)) )
3177 { 3097 {
3178#if HAVE_MESSAGES 3098#if HAVE_MESSAGES
3179 MHD_DLOG (daemon, 3099 MHD_DLOG (daemon,
3180 "setsockopt failed: %s\n", 3100 "setsockopt failed: %s\n",
3181 strerror (errno)); 3101 STRERROR (errno));
3182#endif 3102#endif
3183 } 3103 }
3184#endif 3104#endif
3185#endif 3105#endif
3186 } 3106 }
3187 if (-1 == bind (socket_fd, servaddr, addrlen)) 3107 if (-1 == BIND (socket_fd, servaddr, addrlen))
3188 { 3108 {
3189#if HAVE_MESSAGES 3109#if HAVE_MESSAGES
3190 if (0 != (flags & MHD_USE_DEBUG)) 3110 if (0 != (flags & MHD_USE_DEBUG))
3191 MHD_DLOG (daemon, 3111 MHD_DLOG (daemon,
3192 "Failed to bind to port %u: %s\n", 3112 "Failed to bind to port %u: %s\n",
3193 (unsigned int) port, 3113 (unsigned int) port,
3194 strerror (errno)); 3114 STRERROR (errno));
3195#endif 3115#endif
3196 if (0 != close (socket_fd)) 3116 if (0 != CLOSE (socket_fd))
3197 MHD_PANIC ("close failed\n"); 3117 MHD_PANIC ("close failed\n");
3198 goto free_and_fail; 3118 goto free_and_fail;
3199 } 3119 }
@@ -3206,23 +3126,23 @@ MHD_start_daemon_va (unsigned int flags,
3206#if HAVE_MESSAGES 3126#if HAVE_MESSAGES
3207 MHD_DLOG (daemon, 3127 MHD_DLOG (daemon,
3208 "Failed to make listen socket non-blocking: %s\n", 3128 "Failed to make listen socket non-blocking: %s\n",
3209 strerror (errno)); 3129 STRERROR (errno));
3210#endif 3130#endif
3211 if (0 != close (socket_fd)) 3131 if (0 != CLOSE (socket_fd))
3212 MHD_PANIC ("close failed\n"); 3132 MHD_PANIC ("close failed\n");
3213 goto free_and_fail; 3133 goto free_and_fail;
3214 } 3134 }
3215 } 3135 }
3216#endif 3136#endif
3217 if (listen (socket_fd, 32) < 0) 3137 if (LISTEN (socket_fd, 32) < 0)
3218 { 3138 {
3219#if HAVE_MESSAGES 3139#if HAVE_MESSAGES
3220 if (0 != (flags & MHD_USE_DEBUG)) 3140 if (0 != (flags & MHD_USE_DEBUG))
3221 MHD_DLOG (daemon, 3141 MHD_DLOG (daemon,
3222 "Failed to listen for connections: %s\n", 3142 "Failed to listen for connections: %s\n",
3223 strerror (errno)); 3143 STRERROR (errno));
3224#endif 3144#endif
3225 if (0 != close (socket_fd)) 3145 if (0 != CLOSE (socket_fd))
3226 MHD_PANIC ("close failed\n"); 3146 MHD_PANIC ("close failed\n");
3227 goto free_and_fail; 3147 goto free_and_fail;
3228 } 3148 }
@@ -3242,7 +3162,7 @@ MHD_start_daemon_va (unsigned int flags,
3242 socket_fd, 3162 socket_fd,
3243 FD_SETSIZE); 3163 FD_SETSIZE);
3244#endif 3164#endif
3245 if (0 != close (socket_fd)) 3165 if (0 != CLOSE (socket_fd))
3246 MHD_PANIC ("close failed\n"); 3166 MHD_PANIC ("close failed\n");
3247 goto free_and_fail; 3167 goto free_and_fail;
3248 } 3168 }
@@ -3255,7 +3175,7 @@ MHD_start_daemon_va (unsigned int flags,
3255 "MHD failed to initialize IP connection limit mutex\n"); 3175 "MHD failed to initialize IP connection limit mutex\n");
3256#endif 3176#endif
3257 if ( (-1 != socket_fd) && 3177 if ( (-1 != socket_fd) &&
3258 (0 != close (socket_fd)) ) 3178 (0 != CLOSE (socket_fd)) )
3259 MHD_PANIC ("close failed\n"); 3179 MHD_PANIC ("close failed\n");
3260 goto free_and_fail; 3180 goto free_and_fail;
3261 } 3181 }
@@ -3267,7 +3187,7 @@ MHD_start_daemon_va (unsigned int flags,
3267#endif 3187#endif
3268 pthread_mutex_destroy (&daemon->cleanup_connection_mutex); 3188 pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
3269 if ( (-1 != socket_fd) && 3189 if ( (-1 != socket_fd) &&
3270 (0 != close (socket_fd)) ) 3190 (0 != CLOSE (socket_fd)) )
3271 MHD_PANIC ("close failed\n"); 3191 MHD_PANIC ("close failed\n");
3272 goto free_and_fail; 3192 goto free_and_fail;
3273 } 3193 }
@@ -3281,7 +3201,7 @@ MHD_start_daemon_va (unsigned int flags,
3281 "Failed to initialize TLS support\n"); 3201 "Failed to initialize TLS support\n");
3282#endif 3202#endif
3283 if ( (-1 != socket_fd) && 3203 if ( (-1 != socket_fd) &&
3284 (0 != close (socket_fd)) ) 3204 (0 != CLOSE (socket_fd)) )
3285 MHD_PANIC ("close failed\n"); 3205 MHD_PANIC ("close failed\n");
3286 pthread_mutex_destroy (&daemon->cleanup_connection_mutex); 3206 pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
3287 pthread_mutex_destroy (&daemon->per_ip_connection_mutex); 3207 pthread_mutex_destroy (&daemon->per_ip_connection_mutex);
@@ -3298,12 +3218,12 @@ MHD_start_daemon_va (unsigned int flags,
3298#if HAVE_MESSAGES 3218#if HAVE_MESSAGES
3299 MHD_DLOG (daemon, 3219 MHD_DLOG (daemon,
3300 "Failed to create listen thread: %s\n", 3220 "Failed to create listen thread: %s\n",
3301 strerror (res_thread_create)); 3221 STRERROR (res_thread_create));
3302#endif 3222#endif
3303 pthread_mutex_destroy (&daemon->cleanup_connection_mutex); 3223 pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
3304 pthread_mutex_destroy (&daemon->per_ip_connection_mutex); 3224 pthread_mutex_destroy (&daemon->per_ip_connection_mutex);
3305 if ( (-1 != socket_fd) && 3225 if ( (-1 != socket_fd) &&
3306 (0 != close (socket_fd)) ) 3226 (0 != CLOSE (socket_fd)) )
3307 MHD_PANIC ("close failed\n"); 3227 MHD_PANIC ("close failed\n");
3308 goto free_and_fail; 3228 goto free_and_fail;
3309 } 3229 }
@@ -3337,8 +3257,14 @@ MHD_start_daemon_va (unsigned int flags,
3337 goto thread_failed; 3257 goto thread_failed;
3338#else 3258#else
3339 sk_flags = 1; 3259 sk_flags = 1;
3260#if HAVE_PLIBC_FD
3261 if (SOCKET_ERROR ==
3262 ioctlsocket (plibc_fd_get_handle (socket_fd), FIONBIO, &sk_flags))
3263 goto thread_failed;
3264#else
3340 if (ioctlsocket (socket_fd, FIONBIO, &sk_flags) == SOCKET_ERROR) 3265 if (ioctlsocket (socket_fd, FIONBIO, &sk_flags) == SOCKET_ERROR)
3341 goto thread_failed; 3266 goto thread_failed;
3267#endif // PLIBC_FD
3342#endif // MINGW 3268#endif // MINGW
3343 3269
3344 /* Allocate memory for pooled objects */ 3270 /* Allocate memory for pooled objects */
@@ -3388,8 +3314,8 @@ MHD_start_daemon_va (unsigned int flags,
3388 { 3314 {
3389#if HAVE_MESSAGES 3315#if HAVE_MESSAGES
3390 MHD_DLOG (daemon, 3316 MHD_DLOG (daemon,
3391 "Failed to create pool thread: %s\n", 3317 "Failed to create pool thread: %s\n",
3392 strerror (res_thread_create)); 3318 STRERROR (res_thread_create));
3393#endif 3319#endif
3394 /* Free memory for this worker; cleanup below handles 3320 /* Free memory for this worker; cleanup below handles
3395 * all previously-created workers. */ 3321 * all previously-created workers. */
@@ -3408,7 +3334,7 @@ thread_failed:
3408 if (0 == i) 3334 if (0 == i)
3409 { 3335 {
3410 if ( (-1 != socket_fd) && 3336 if ( (-1 != socket_fd) &&
3411 (0 != close (socket_fd)) ) 3337 (0 != CLOSE (socket_fd)) )
3412 MHD_PANIC ("close failed\n"); 3338 MHD_PANIC ("close failed\n");
3413 pthread_mutex_destroy (&daemon->cleanup_connection_mutex); 3339 pthread_mutex_destroy (&daemon->cleanup_connection_mutex);
3414 pthread_mutex_destroy (&daemon->per_ip_connection_mutex); 3340 pthread_mutex_destroy (&daemon->per_ip_connection_mutex);
@@ -3496,7 +3422,7 @@ close_all_connections (struct MHD_Daemon *daemon)
3496 (0 != pthread_mutex_lock (&daemon->cleanup_connection_mutex)) ) 3422 (0 != pthread_mutex_lock (&daemon->cleanup_connection_mutex)) )
3497 MHD_PANIC ("Failed to acquire cleanup mutex\n"); 3423 MHD_PANIC ("Failed to acquire cleanup mutex\n");
3498 for (pos = daemon->connections_head; NULL != pos; pos = pos->nextX) 3424 for (pos = daemon->connections_head; NULL != pos; pos = pos->nextX)
3499 shutdown (pos->socket_fd, 3425 SHUTDOWN (pos->socket_fd,
3500 (pos->read_closed == MHD_YES) ? SHUT_WR : SHUT_RDWR); 3426 (pos->read_closed == MHD_YES) ? SHUT_WR : SHUT_RDWR);
3501 if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && 3427 if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
3502 (0 != pthread_mutex_unlock (&daemon->cleanup_connection_mutex)) ) 3428 (0 != pthread_mutex_unlock (&daemon->cleanup_connection_mutex)) )
@@ -3583,7 +3509,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
3583 } 3509 }
3584 if (-1 != daemon->wpipe[1]) 3510 if (-1 != daemon->wpipe[1])
3585 { 3511 {
3586 if (1 != write (daemon->wpipe[1], "e", 1)) 3512 if (1 != WRITE (daemon->wpipe[1], "e", 1))
3587 MHD_PANIC ("failed to signal shutdownn via pipe"); 3513 MHD_PANIC ("failed to signal shutdownn via pipe");
3588 } 3514 }
3589#ifdef HAVE_LISTEN_SHUTDOWN 3515#ifdef HAVE_LISTEN_SHUTDOWN
@@ -3591,7 +3517,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
3591 { 3517 {
3592 /* fd might be -1 here due to 'MHD_quiesce_daemon' */ 3518 /* fd might be -1 here due to 'MHD_quiesce_daemon' */
3593 if (-1 != fd) 3519 if (-1 != fd)
3594 (void) shutdown (fd, SHUT_RDWR); 3520 (void) SHUTDOWN (fd, SHUT_RDWR);
3595 } 3521 }
3596#endif 3522#endif
3597#if EPOLL_SUPPORT 3523#if EPOLL_SUPPORT
@@ -3620,7 +3546,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
3620 pthread_mutex_destroy (&daemon->worker_pool[i].cleanup_connection_mutex); 3546 pthread_mutex_destroy (&daemon->worker_pool[i].cleanup_connection_mutex);
3621#if EPOLL_SUPPORT 3547#if EPOLL_SUPPORT
3622 if ( (-1 != daemon->worker_pool[i].epoll_fd) && 3548 if ( (-1 != daemon->worker_pool[i].epoll_fd) &&
3623 (0 != close (daemon->worker_pool[i].epoll_fd)) ) 3549 (0 != CLOSE (daemon->worker_pool[i].epoll_fd)) )
3624 MHD_PANIC ("close failed\n"); 3550 MHD_PANIC ("close failed\n");
3625#endif 3551#endif
3626 } 3552 }
@@ -3641,7 +3567,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
3641 } 3567 }
3642 close_all_connections (daemon); 3568 close_all_connections (daemon);
3643 if ( (-1 != fd) && 3569 if ( (-1 != fd) &&
3644 (0 != close (fd)) ) 3570 (0 != CLOSE (fd)) )
3645 MHD_PANIC ("close failed\n"); 3571 MHD_PANIC ("close failed\n");
3646 3572
3647 /* TLS clean up */ 3573 /* TLS clean up */
@@ -3656,7 +3582,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
3656#if EPOLL_SUPPORT 3582#if EPOLL_SUPPORT
3657 if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) && 3583 if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) &&
3658 (-1 != daemon->epoll_fd) && 3584 (-1 != daemon->epoll_fd) &&
3659 (0 != close (daemon->epoll_fd)) ) 3585 (0 != CLOSE (daemon->epoll_fd)) )
3660 MHD_PANIC ("close failed\n"); 3586 MHD_PANIC ("close failed\n");
3661#endif 3587#endif
3662 3588
@@ -3669,9 +3595,9 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
3669 3595
3670 if (-1 != daemon->wpipe[1]) 3596 if (-1 != daemon->wpipe[1])
3671 { 3597 {
3672 if (0 != close (daemon->wpipe[0])) 3598 if (0 != CLOSE (daemon->wpipe[0]))
3673 MHD_PANIC ("close failed\n"); 3599 MHD_PANIC ("close failed\n");
3674 if (0 != close (daemon->wpipe[1])) 3600 if (0 != CLOSE (daemon->wpipe[1]))
3675 MHD_PANIC ("close failed\n"); 3601 MHD_PANIC ("close failed\n");
3676 } 3602 }
3677 free (daemon); 3603 free (daemon);
@@ -3761,12 +3687,15 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL;
3761/** 3687/**
3762 * Initialize do setup work. 3688 * Initialize do setup work.
3763 */ 3689 */
3764void ATTRIBUTE_CONSTRUCTOR 3690void ATTRIBUTE_CONSTRUCTOR
3765MHD_init () 3691MHD_init ()
3766{ 3692{
3767 mhd_panic = &mhd_panic_std; 3693 mhd_panic = &mhd_panic_std;
3768 mhd_panic_cls = NULL; 3694 mhd_panic_cls = NULL;
3769 3695
3696#ifdef WINDOWS
3697 plibc_init ("GNU", "libmicrohttpd");
3698#endif
3770#if HTTPS_SUPPORT 3699#if HTTPS_SUPPORT
3771 gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); 3700 gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
3772 gnutls_global_init (); 3701 gnutls_global_init ();
@@ -3774,12 +3703,15 @@ MHD_init ()
3774} 3703}
3775 3704
3776 3705
3777void ATTRIBUTE_DESTRUCTOR 3706void ATTRIBUTE_DESTRUCTOR
3778MHD_fini () 3707MHD_fini ()
3779{ 3708{
3780#if HTTPS_SUPPORT 3709#if HTTPS_SUPPORT
3781 gnutls_global_deinit (); 3710 gnutls_global_deinit ();
3782#endif 3711#endif
3712#ifdef WINDOWS
3713 plibc_shutdown ();
3714#endif
3783} 3715}
3784 3716
3785/* end of daemon.c */ 3717/* end of daemon.c */
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c
index 56fb75fe..db347056 100644
--- a/src/microhttpd/memorypool.c
+++ b/src/microhttpd/memorypool.c
@@ -95,7 +95,7 @@ MHD_pool_create (size_t max)
95 if (max <= 32 * 1024) 95 if (max <= 32 * 1024)
96 pool->memory = MAP_FAILED; 96 pool->memory = MAP_FAILED;
97 else 97 else
98 pool->memory = mmap (NULL, max, PROT_READ | PROT_WRITE, 98 pool->memory = MMAP (NULL, max, PROT_READ | PROT_WRITE,
99 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 99 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
100#else 100#else
101 pool->memory = MAP_FAILED; 101 pool->memory = MAP_FAILED;
@@ -134,11 +134,7 @@ MHD_pool_destroy (struct MemoryPool *pool)
134 if (pool->is_mmap == MHD_NO) 134 if (pool->is_mmap == MHD_NO)
135 free (pool->memory); 135 free (pool->memory);
136 else 136 else
137#ifndef WINDOWS 137 MUNMAP (pool->memory, pool->size);
138 munmap (pool->memory, pool->size);
139#else
140 VirtualFree (pool->memory, 0, MEM_RELEASE);
141#endif
142 free (pool); 138 free (pool);
143} 139}
144 140
@@ -155,7 +151,7 @@ MHD_pool_destroy (struct MemoryPool *pool)
155 * bytes 151 * bytes
156 */ 152 */
157void * 153void *
158MHD_pool_allocate (struct MemoryPool *pool, 154MHD_pool_allocate (struct MemoryPool *pool,
159 size_t size, int from_end) 155 size_t size, int from_end)
160{ 156{
161 void *ret; 157 void *ret;
@@ -196,8 +192,8 @@ MHD_pool_allocate (struct MemoryPool *pool,
196 */ 192 */
197void * 193void *
198MHD_pool_reallocate (struct MemoryPool *pool, 194MHD_pool_reallocate (struct MemoryPool *pool,
199 void *old, 195 void *old,
200 size_t old_size, 196 size_t old_size,
201 size_t new_size) 197 size_t new_size)
202{ 198{
203 void *ret; 199 void *ret;
@@ -246,8 +242,8 @@ MHD_pool_reallocate (struct MemoryPool *pool,
246 * @return addr new address of "keep" (if it had to change) 242 * @return addr new address of "keep" (if it had to change)
247 */ 243 */
248void * 244void *
249MHD_pool_reset (struct MemoryPool *pool, 245MHD_pool_reset (struct MemoryPool *pool,
250 void *keep, 246 void *keep,
251 size_t size) 247 size_t size)
252{ 248{
253 size = ROUND_TO_ALIGN (size); 249 size = ROUND_TO_ALIGN (size);
diff --git a/src/microspdy/Makefile.am b/src/microspdy/Makefile.am
index fa99a5cf..9ad451bd 100644
--- a/src/microspdy/Makefile.am
+++ b/src/microspdy/Makefile.am
@@ -1,4 +1,9 @@
1if USE_PRIVATE_PLIBC_H
2 PLIBC_INCLUDE = -I$(top_srcdir)/src/include/plibc
3endif
4
1AM_CPPFLAGS = \ 5AM_CPPFLAGS = \
6 $(PLIBC_INCLUDE) \
2 -I$(top_srcdir)/src/include \ 7 -I$(top_srcdir)/src/include \
3 -I$(top_srcdir)/src/microspdy 8 -I$(top_srcdir)/src/microspdy
4 9
diff --git a/src/spdy2http/Makefile.am b/src/spdy2http/Makefile.am
index 3f11daa5..475bcbfe 100644
--- a/src/spdy2http/Makefile.am
+++ b/src/spdy2http/Makefile.am
@@ -6,7 +6,12 @@ if USE_COVERAGE
6 AM_CFLAGS += -fprofile-arcs -ftest-coverage 6 AM_CFLAGS += -fprofile-arcs -ftest-coverage
7endif 7endif
8 8
9if USE_PRIVATE_PLIBC_H
10 PLIBC_INCLUDE = -I$(top_srcdir)/src/include/plibc
11endif
12
9AM_CPPFLAGS = \ 13AM_CPPFLAGS = \
14 $(PLIBC_INCLUDE) \
10 -I$(top_srcdir) \ 15 -I$(top_srcdir) \
11 -I$(top_srcdir)/src/include \ 16 -I$(top_srcdir)/src/include \
12 -I$(top_srcdir)/src/applicationlayer \ 17 -I$(top_srcdir)/src/applicationlayer \
diff --git a/src/testcurl/test_options.c b/src/testcurl/test_options.c
index 83aee6fd..79042a46 100644
--- a/src/testcurl/test_options.c
+++ b/src/testcurl/test_options.c
@@ -19,22 +19,14 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file test_options.c 22 * @file mhds_get_test.c
23 * @brief Testcase for libmicrohttpd HTTPS GET operations 23 * @brief Testcase for libmicrohttpd HTTPS GET operations
24 * @author Sagie Amir 24 * @author Sagie Amir
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "microhttpd.h" 28#include "microhttpd.h"
28 29
29/* inet_pton requires Vista, add defines to declare that we
30 are compiling for Vista */
31#if (defined(__MINGW64__) || defined(__MINGW32__))
32#ifndef _WIN32_WINNT
33#define _WIN32_WINNT 0x0600
34#endif
35#endif
36
37
38#define MHD_E_MEM "Error: memory error\n" 30#define MHD_E_MEM "Error: memory error\n"
39#define MHD_E_SERVER_INIT "Error: failed to start server\n" 31#define MHD_E_SERVER_INIT "Error: failed to start server\n"
40 32
diff --git a/src/testspdy/Makefile.am b/src/testspdy/Makefile.am
index 9b29452a..712ea020 100644
--- a/src/testspdy/Makefile.am
+++ b/src/testspdy/Makefile.am
@@ -6,7 +6,12 @@ if USE_COVERAGE
6 AM_CFLAGS += -fprofile-arcs -ftest-coverage 6 AM_CFLAGS += -fprofile-arcs -ftest-coverage
7endif 7endif
8 8
9if USE_PRIVATE_PLIBC_H
10 PLIBC_INCLUDE = -I$(top_srcdir)/src/include/plibc
11endif
12
9AM_CPPFLAGS = \ 13AM_CPPFLAGS = \
14 $(PLIBC_INCLUDE) \
10 -I$(top_srcdir) \ 15 -I$(top_srcdir) \
11 -I$(top_srcdir)/src/include \ 16 -I$(top_srcdir)/src/include \
12 -I$(top_srcdir)/src/applicationlayer \ 17 -I$(top_srcdir)/src/applicationlayer \