aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r--src/microhttpd/daemon.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index fde1703d..294ed722 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2376,7 +2376,7 @@ psk_gnutls_adapter (gnutls_session_t session,
2376 * @param non_blck indicate that socket in non-blocking mode 2376 * @param non_blck indicate that socket in non-blocking mode
2377 * @param sk_spipe_supprs indicate that the @a client_socket has 2377 * @param sk_spipe_supprs indicate that the @a client_socket has
2378 * set SIGPIPE suppression 2378 * set SIGPIPE suppression
2379 * @param sk_is_unix true if this is a UNIX domain socket (AF_UNIX) 2379 * @param sk_is_nonip _MHD_YES if this is not a TCP/IP socket
2380 * @return pointer to the connection on success, NULL if this daemon could 2380 * @return pointer to the connection on success, NULL if this daemon could
2381 * not handle the connection (i.e. malloc failed, etc). 2381 * not handle the connection (i.e. malloc failed, etc).
2382 * The socket will be closed in case of error; 'errno' is 2382 * The socket will be closed in case of error; 'errno' is
@@ -2390,7 +2390,7 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
2390 bool external_add, 2390 bool external_add,
2391 bool non_blck, 2391 bool non_blck,
2392 bool sk_spipe_supprs, 2392 bool sk_spipe_supprs,
2393 bool sk_is_unix) 2393 enum MHD_tristate sk_is_nonip)
2394{ 2394{
2395 struct MHD_Connection *connection; 2395 struct MHD_Connection *connection;
2396 int eno = 0; 2396 int eno = 0;
@@ -2492,7 +2492,7 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
2492 connection->addr_len = addrlen; 2492 connection->addr_len = addrlen;
2493 connection->socket_fd = client_socket; 2493 connection->socket_fd = client_socket;
2494 connection->sk_nonblck = non_blck; 2494 connection->sk_nonblck = non_blck;
2495 connection->is_unix = sk_is_unix; 2495 connection->is_nonip = sk_is_nonip;
2496 connection->sk_spipe_suppress = sk_spipe_supprs; 2496 connection->sk_spipe_suppress = sk_spipe_supprs;
2497 connection->daemon = daemon; 2497 connection->daemon = daemon;
2498 connection->last_activity = MHD_monotonic_sec_counter (); 2498 connection->last_activity = MHD_monotonic_sec_counter ();
@@ -2863,7 +2863,7 @@ cleanup:
2863 * @param non_blck indicate that socket in non-blocking mode 2863 * @param non_blck indicate that socket in non-blocking mode
2864 * @param sk_spipe_supprs indicate that the @a client_socket has 2864 * @param sk_spipe_supprs indicate that the @a client_socket has
2865 * set SIGPIPE suppression 2865 * set SIGPIPE suppression
2866 * @param sk_is_unix true if this is a UNIX domain socket (AF_UNIX) 2866 * @param sk_is_nonip _MHD_YES if this is not a TCP/IP socket
2867 * @return #MHD_YES on success, #MHD_NO if this daemon could 2867 * @return #MHD_YES on success, #MHD_NO if this daemon could
2868 * not handle the connection (i.e. malloc failed, etc). 2868 * not handle the connection (i.e. malloc failed, etc).
2869 * The socket will be closed in any case; 'errno' is 2869 * The socket will be closed in any case; 'errno' is
@@ -2877,7 +2877,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
2877 bool external_add, 2877 bool external_add,
2878 bool non_blck, 2878 bool non_blck,
2879 bool sk_spipe_supprs, 2879 bool sk_spipe_supprs,
2880 bool sk_is_unix) 2880 enum MHD_tristate sk_is_nonip)
2881{ 2881{
2882 struct MHD_Connection *connection; 2882 struct MHD_Connection *connection;
2883 2883
@@ -2923,7 +2923,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
2923 external_add, 2923 external_add,
2924 non_blck, 2924 non_blck,
2925 sk_spipe_supprs, 2925 sk_spipe_supprs,
2926 sk_is_unix); 2926 sk_is_nonip);
2927 if (NULL == connection) 2927 if (NULL == connection)
2928 return MHD_NO; 2928 return MHD_NO;
2929 2929
@@ -3348,7 +3348,6 @@ MHD_add_connection (struct MHD_Daemon *daemon,
3348{ 3348{
3349 bool sk_nonbl; 3349 bool sk_nonbl;
3350 bool sk_spipe_supprs; 3350 bool sk_spipe_supprs;
3351 bool sk_is_unix = false;
3352 3351
3353 /* NOT thread safe with internal thread. TODO: fix thread safety. */ 3352 /* NOT thread safe with internal thread. TODO: fix thread safety. */
3354 if ((0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) && 3353 if ((0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) &&
@@ -3419,20 +3418,6 @@ MHD_add_connection (struct MHD_Daemon *daemon,
3419 _ ("Failed to set noninheritable mode on new client socket.\n")); 3418 _ ("Failed to set noninheritable mode on new client socket.\n"));
3420#endif 3419#endif
3421 } 3420 }
3422#ifdef SO_DOMAIN
3423 {
3424 int af;
3425 socklen_t len = sizeof (af);
3426
3427 if ( (0 == getsockopt (daemon->listen_fd,
3428 SOL_SOCKET,
3429 SO_DOMAIN,
3430 &af,
3431 &len)) &&
3432 (AF_UNIX == af) )
3433 sk_is_unix = true;
3434 }
3435#endif
3436 3421
3437#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 3422#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3438 if (NULL != daemon->worker_pool) 3423 if (NULL != daemon->worker_pool)
@@ -3453,7 +3438,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
3453 true, 3438 true,
3454 sk_nonbl, 3439 sk_nonbl,
3455 sk_spipe_supprs, 3440 sk_spipe_supprs,
3456 sk_is_unix); 3441 _MHD_UNKNOWN);
3457 } 3442 }
3458 /* all pools are at their connection limit, must refuse */ 3443 /* all pools are at their connection limit, must refuse */
3459 MHD_socket_close_chk_ (client_socket); 3444 MHD_socket_close_chk_ (client_socket);
@@ -3471,7 +3456,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
3471 true, 3456 true,
3472 sk_nonbl, 3457 sk_nonbl,
3473 sk_spipe_supprs, 3458 sk_spipe_supprs,
3474 sk_is_unix); 3459 _MHD_UNKNOWN);
3475} 3460}
3476 3461
3477 3462
@@ -5840,20 +5825,25 @@ parse_options_va (struct MHD_Daemon *daemon,
5840 { 5825 {
5841 daemon->listen_fd = va_arg (ap, 5826 daemon->listen_fd = va_arg (ap,
5842 MHD_socket); 5827 MHD_socket);
5843#ifdef SO_DOMAIN 5828#if defined(SO_DOMAIN) && defined(AF_UNIX)
5844 { 5829 {
5845 int af; 5830 int af;
5846 socklen_t len = sizeof (af); 5831 socklen_t len = sizeof (af);
5847 5832
5848 if ( (0 == getsockopt (daemon->listen_fd, 5833 if (0 == getsockopt (daemon->listen_fd,
5849 SOL_SOCKET, 5834 SOL_SOCKET,
5850 SO_DOMAIN, 5835 SO_DOMAIN,
5851 &af, 5836 &af,
5852 &len)) && 5837 &len))
5853 (AF_UNIX == af) ) 5838 {
5854 daemon->listen_is_unix = true; 5839 daemon->listen_is_unix = (AF_UNIX == af) ? _MHD_YES : MHD_NO;
5840 }
5841 else
5842 daemon->listen_is_unix = _MHD_UNKNOWN;
5855 } 5843 }
5856#endif 5844#else /* ! SO_DOMAIN || ! AF_UNIX */
5845 daemon->listen_is_unix = _MHD_UNKNOWN;
5846#endif /* ! SO_DOMAIN || ! AF_UNIX */
5857 } 5847 }
5858 break; 5848 break;
5859 case MHD_OPTION_EXTERNAL_LOGGER: 5849 case MHD_OPTION_EXTERNAL_LOGGER:
@@ -6342,6 +6332,7 @@ MHD_start_daemon_va (unsigned int flags,
6342 } 6332 }
6343#endif /* HTTPS_SUPPORT */ 6333#endif /* HTTPS_SUPPORT */
6344 daemon->listen_fd = MHD_INVALID_SOCKET; 6334 daemon->listen_fd = MHD_INVALID_SOCKET;
6335 daemon->listen_is_unix = _MHD_NO;
6345 daemon->listening_address_reuse = 0; 6336 daemon->listening_address_reuse = 0;
6346 daemon->options = *pflags; 6337 daemon->options = *pflags;
6347 pflags = &daemon->options; 6338 pflags = &daemon->options;
@@ -6722,6 +6713,8 @@ MHD_start_daemon_va (unsigned int flags,
6722 servaddr = (struct sockaddr *) &servaddr4; 6713 servaddr = (struct sockaddr *) &servaddr4;
6723 } 6714 }
6724 } 6715 }
6716 else
6717 daemon->listen_is_unix = _MHD_UNKNOWN;
6725 daemon->listen_fd = listen_fd; 6718 daemon->listen_fd = listen_fd;
6726 if (0 != (*pflags & MHD_USE_IPv6)) 6719 if (0 != (*pflags & MHD_USE_IPv6))
6727 { 6720 {