diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 65 |
2 files changed, 29 insertions, 42 deletions
@@ -1,3 +1,9 @@ | |||
1 | Tue Jan 19 11:14:18 CET 2016 | ||
2 | Removed workaround for Cygwin non-blocking sockets: | ||
3 | handling non-blocking sockets were fixed in Cygwin | ||
4 | and libmicrohttpd how uses non-blocking sockets on | ||
5 | all platforms. -EG | ||
6 | |||
1 | Mon Jan 18 23:54:45 CET 2016 | 7 | Mon Jan 18 23:54:45 CET 2016 |
2 | Cleaned up examples to avoid giving oversimplified code | 8 | Cleaned up examples to avoid giving oversimplified code |
3 | that may lead to complications if adopted naively. -CG | 9 | that may lead to complications if adopted naively. -CG |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index ef002eea..0c2c4d3c 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -1460,38 +1460,32 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1460 | 1460 | ||
1461 | if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO)) | 1461 | if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO)) |
1462 | { | 1462 | { |
1463 | /* non-blocking sockets are required on most systems and for GNUtls; | 1463 | /* in turbo mode, we assume that non-blocking was already set |
1464 | however, they somehow cause serious problems on CYGWIN (#1824); | ||
1465 | in turbo mode, we assume that non-blocking was already set | ||
1466 | by 'accept4' or whoever calls 'MHD_add_connection' */ | 1464 | by 'accept4' or whoever calls 'MHD_add_connection' */ |
1467 | #ifdef CYGWIN | 1465 | |
1468 | if (0 != (daemon->options & MHD_USE_SSL)) | 1466 | /* make socket non-blocking */ |
1469 | #endif | ||
1470 | { | ||
1471 | /* make socket non-blocking */ | ||
1472 | #if !defined(MHD_WINSOCK_SOCKETS) | 1467 | #if !defined(MHD_WINSOCK_SOCKETS) |
1473 | int flags = fcntl (connection->socket_fd, F_GETFL); | 1468 | int flags = fcntl (connection->socket_fd, F_GETFL); |
1474 | if ( (-1 == flags) || | 1469 | if ( (-1 == flags) || |
1475 | (0 != fcntl (connection->socket_fd, F_SETFL, flags | O_NONBLOCK)) ) | 1470 | (0 != fcntl (connection->socket_fd, F_SETFL, flags | O_NONBLOCK)) ) |
1476 | { | 1471 | { |
1477 | #ifdef HAVE_MESSAGES | 1472 | #ifdef HAVE_MESSAGES |
1478 | MHD_DLOG (daemon, | 1473 | MHD_DLOG (daemon, |
1479 | "Failed to make socket non-blocking: %s\n", | 1474 | "Failed to make socket non-blocking: %s\n", |
1480 | MHD_socket_last_strerr_ ()); | 1475 | MHD_socket_last_strerr_ ()); |
1481 | #endif | 1476 | #endif |
1482 | } | 1477 | } |
1483 | #else | 1478 | #else |
1484 | unsigned long flags = 1; | 1479 | unsigned long flags = 1; |
1485 | if (0 != ioctlsocket (connection->socket_fd, FIONBIO, &flags)) | 1480 | if (0 != ioctlsocket (connection->socket_fd, FIONBIO, &flags)) |
1486 | { | 1481 | { |
1487 | #ifdef HAVE_MESSAGES | 1482 | #ifdef HAVE_MESSAGES |
1488 | MHD_DLOG (daemon, | 1483 | MHD_DLOG (daemon, |
1489 | "Failed to make socket non-blocking: %s\n", | 1484 | "Failed to make socket non-blocking: %s\n", |
1490 | MHD_socket_last_strerr_ ()); | 1485 | MHD_socket_last_strerr_ ()); |
1491 | #endif | ||
1492 | } | ||
1493 | #endif | 1486 | #endif |
1494 | } | 1487 | } |
1488 | #endif | ||
1495 | } | 1489 | } |
1496 | 1490 | ||
1497 | #if HTTPS_SUPPORT | 1491 | #if HTTPS_SUPPORT |
@@ -1869,22 +1863,15 @@ make_nonblocking_noninheritable (struct MHD_Daemon *daemon, | |||
1869 | } | 1863 | } |
1870 | #else | 1864 | #else |
1871 | int flags; | 1865 | int flags; |
1872 | int nonblock; | ||
1873 | 1866 | ||
1874 | nonblock = O_NONBLOCK; | ||
1875 | #ifdef CYGWIN | ||
1876 | if (0 == (daemon->options & MHD_USE_SSL)) | ||
1877 | nonblock = 0; | ||
1878 | #endif | ||
1879 | flags = fcntl (sock, F_GETFD); | 1867 | flags = fcntl (sock, F_GETFD); |
1880 | if ( ( (-1 == flags) || | 1868 | if ( ( (-1 == flags) || |
1881 | ( (flags != (flags | nonblock | FD_CLOEXEC)) && | 1869 | ( (flags != (flags | O_NONBLOCK | FD_CLOEXEC)) && |
1882 | (0 != fcntl (sock, F_SETFD, flags | nonblock | FD_CLOEXEC)) ) ) ) | 1870 | (0 != fcntl (sock, F_SETFD, flags | O_NONBLOCK | FD_CLOEXEC)) ) ) ) |
1883 | { | 1871 | { |
1884 | #ifdef HAVE_MESSAGES | 1872 | #ifdef HAVE_MESSAGES |
1885 | MHD_DLOG (daemon, | 1873 | MHD_DLOG (daemon, |
1886 | "Failed to make socket %snon-inheritable: %s\n", | 1874 | "Failed to make socket non-blocking non-inheritable: %s\n", |
1887 | ((nonblock) ? "non-blocking " : ""), | ||
1888 | MHD_socket_last_strerr_ ()); | 1875 | MHD_socket_last_strerr_ ()); |
1889 | #endif | 1876 | #endif |
1890 | } | 1877 | } |
@@ -1961,16 +1948,10 @@ MHD_accept_connection (struct MHD_Daemon *daemon) | |||
1961 | MHD_socket s; | 1948 | MHD_socket s; |
1962 | MHD_socket fd; | 1949 | MHD_socket fd; |
1963 | #ifdef USE_ACCEPT4 | 1950 | #ifdef USE_ACCEPT4 |
1964 | int nonblock; | ||
1965 | |||
1966 | #ifdef HAVE_SOCK_NONBLOCK | 1951 | #ifdef HAVE_SOCK_NONBLOCK |
1967 | nonblock = SOCK_NONBLOCK; | 1952 | static const int nonblock = SOCK_NONBLOCK; |
1968 | #else | 1953 | #else |
1969 | nonblock = 0; | 1954 | static const int nonblock = 0; |
1970 | #endif | ||
1971 | #ifdef CYGWIN | ||
1972 | if (0 == (daemon->options & MHD_USE_SSL)) | ||
1973 | nonblock = 0; | ||
1974 | #endif | 1955 | #endif |
1975 | #endif /* USE_ACCEPT4 */ | 1956 | #endif /* USE_ACCEPT4 */ |
1976 | 1957 | ||