aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r--src/daemon/daemon.c51
1 files changed, 16 insertions, 35 deletions
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 {