aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-12 08:41:49 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-12 08:41:49 +0000
commitda7e8ad76dcec43b011ea65a20b7b45608590f34 (patch)
tree1248fe259c510dbf963f70370f418f366d3a1e41
parent2160c665890c35077ed7322a330337434f22d2ed (diff)
downloadlibmicrohttpd-da7e8ad76dcec43b011ea65a20b7b45608590f34.tar.gz
libmicrohttpd-da7e8ad76dcec43b011ea65a20b7b45608590f34.zip
fixing #1824
-rw-r--r--ChangeLog5
-rw-r--r--src/daemon/daemon.c51
2 files changed, 21 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index 5d4e8cdd..bea4ddad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
1Wed Oct 12 10:40:12 CEST 2011
2 Made sockets blocking again for non-Linux platforms as non-blocking
3 sockets cause problems (#1824) on Cygwin but offer better performance
4 on Linux (see change on August 11 2011). -CG/pross
5
1Fri Oct 7 19:50:07 CEST 2011 6Fri Oct 7 19:50:07 CEST 2011
2 Fixed problems with testcases on W32. -LRN 7 Fixed problems with testcases on W32. -LRN
3 8
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 99bba8a1..85bcd46f 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -768,40 +768,6 @@ send_param_adapter (struct MHD_Connection *connection,
768 768
769 769
770/** 770/**
771 * Set if a socket should use non-blocking IO.
772 * @param fd socket
773 */
774static void
775socket_set_nonblocking (int fd)
776{
777#if MINGW
778 u_long mode;
779 mode = 1;
780 if (ioctlsocket (fd, FIONBIO, &mode) == SOCKET_ERROR)
781 {
782 SetErrnoFromWinsockError (WSAGetLastError ());
783#if HAVE_MESSAGES
784 FPRINTF(stderr, "Failed to make socket non-blocking: %s\n",
785 STRERROR (errno));
786#endif
787 }
788#else
789
790 /* not MINGW */
791 int flags = fcntl (fd, F_GETFL);
792 if ( (flags == -1) ||
793 (0 != fcntl (fd, F_SETFL, flags | O_NONBLOCK)) )
794 {
795#if HAVE_MESSAGES
796 FPRINTF(stderr, "Failed to make socket non-blocking: %s\n",
797 STRERROR (errno));
798#endif
799 }
800#endif
801}
802
803
804/**
805 * Create a thread and set the attributes according to our options. 771 * Create a thread and set the attributes according to our options.
806 * 772 *
807 * @param thread handle to initialize 773 * @param thread handle to initialize
@@ -979,7 +945,22 @@ MHD_add_connection (struct MHD_Daemon *daemon,
979 MHD_set_http_callbacks_ (connection); 945 MHD_set_http_callbacks_ (connection);
980 connection->recv_cls = &recv_param_adapter; 946 connection->recv_cls = &recv_param_adapter;
981 connection->send_cls = &send_param_adapter; 947 connection->send_cls = &send_param_adapter;
982 socket_set_nonblocking (connection->socket_fd); 948#if LINUX
949 {
950 /* non-blocking sockets perform better on Linux */
951 int flags = fcntl (fd, F_GETFL);
952 if ( (flags == -1) ||
953 (0 != fcntl (fd, F_SETFL, flags | O_NONBLOCK)) )
954 {
955#if HAVE_MESSAGES
956 FPRINTF(stderr, "Failed to make socket non-blocking: %s\n",
957 STRERROR (errno));
958#endif
959 }
960#endif
961 }
962#endif
963
983#if HTTPS_SUPPORT 964#if HTTPS_SUPPORT
984 if (0 != (daemon->options & MHD_USE_SSL)) 965 if (0 != (daemon->options & MHD_USE_SSL))
985 { 966 {