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.c89
1 files changed, 45 insertions, 44 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index d5a0ceaf..27c63837 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -231,7 +231,7 @@ MHD_ip_addr_compare (const void *a1, const void *a2)
231 * @param addr address to parse 231 * @param addr address to parse
232 * @param addrlen number of bytes in addr 232 * @param addrlen number of bytes in addr
233 * @param key where to store the parsed address 233 * @param key where to store the parsed address
234 * @return MHD_YES on success and MHD_NO otherwise (e.g., invalid address type) 234 * @return #MHD_YES on success and #MHD_NO otherwise (e.g., invalid address type)
235 */ 235 */
236static int 236static int
237MHD_ip_addr_to_key (const struct sockaddr *addr, 237MHD_ip_addr_to_key (const struct sockaddr *addr,
@@ -271,8 +271,8 @@ MHD_ip_addr_to_key (const struct sockaddr *addr,
271 * @param daemon handle to daemon where connection counts are tracked 271 * @param daemon handle to daemon where connection counts are tracked
272 * @param addr address to add (or increment counter) 272 * @param addr address to add (or increment counter)
273 * @param addrlen number of bytes in addr 273 * @param addrlen number of bytes in addr
274 * @return Return MHD_YES if IP below limit, MHD_NO if IP has surpassed limit. 274 * @return Return #MHD_YES if IP below limit, #MHD_NO if IP has surpassed limit.
275 * Also returns MHD_NO if fails to allocate memory. 275 * Also returns #MHD_NO if fails to allocate memory.
276 */ 276 */
277static int 277static int
278MHD_ip_limit_add (struct MHD_Daemon *daemon, 278MHD_ip_limit_add (struct MHD_Daemon *daemon,
@@ -332,11 +332,11 @@ MHD_ip_limit_add (struct MHD_Daemon *daemon,
332 332
333/** 333/**
334 * Decrement connection count for IP address, removing from table 334 * Decrement connection count for IP address, removing from table
335 * count reaches 0 335 * count reaches 0.
336 * 336 *
337 * @param daemon handle to daemon where connection counts are tracked 337 * @param daemon handle to daemon where connection counts are tracked
338 * @param addr address to remove (or decrement counter) 338 * @param addr address to remove (or decrement counter)
339 * @param addrlen number of bytes in addr 339 * @param addrlen number of bytes in @a addr
340 */ 340 */
341static void 341static void
342MHD_ip_limit_del (struct MHD_Daemon *daemon, 342MHD_ip_limit_del (struct MHD_Daemon *daemon,
@@ -389,7 +389,7 @@ MHD_ip_limit_del (struct MHD_Daemon *daemon,
389/** 389/**
390 * Callback for receiving data from the socket. 390 * Callback for receiving data from the socket.
391 * 391 *
392 * @param connection the MHD connection structure 392 * @param connection the MHD_Connection structure
393 * @param other where to write received data to 393 * @param other where to write received data to
394 * @param i maximum size of other (in bytes) 394 * @param i maximum size of other (in bytes)
395 * @return number of bytes actually received 395 * @return number of bytes actually received
@@ -536,10 +536,10 @@ MHD_TLS_init (struct MHD_Daemon *daemon)
536 536
537 537
538/** 538/**
539 * Add "fd" to the "fd_set". If "fd" is 539 * Add @a fd to the @a set. If @a fd is
540 * greater than "*max", set "*max" to fd. 540 * greater than @a max_fd, set @a max_fd to @a fd.
541 * 541 *
542 * @param fd file descriptor to add to the set 542 * @param fd file descriptor to add to the @a set
543 * @param set set to modify 543 * @param set set to modify
544 * @param max_fd maximum value to potentially update 544 * @param max_fd maximum value to potentially update
545 */ 545 */
@@ -642,7 +642,7 @@ MHD_get_fdset (struct MHD_Daemon *daemon,
642 642
643/** 643/**
644 * Main function of the thread that handles an individual 644 * Main function of the thread that handles an individual
645 * connection when MHD_USE_THREAD_PER_CONNECTION is set. 645 * connection when #MHD_USE_THREAD_PER_CONNECTION is set.
646 * 646 *
647 * @param data the 'struct MHD_Connection' this thread will handle 647 * @param data the 'struct MHD_Connection' this thread will handle
648 * @return always NULL 648 * @return always NULL
@@ -1002,10 +1002,10 @@ create_thread (pthread_t *thread,
1002 * @param client_socket socket to manage (MHD will expect 1002 * @param client_socket socket to manage (MHD will expect
1003 * to receive an HTTP request from this socket next). 1003 * to receive an HTTP request from this socket next).
1004 * @param addr IP address of the client 1004 * @param addr IP address of the client
1005 * @param addrlen number of bytes in addr 1005 * @param addrlen number of bytes in @a addr
1006 * @param external_add perform additional operations needed due 1006 * @param external_add perform additional operations needed due
1007 * to the application calling us directly 1007 * to the application calling us directly
1008 * @return MHD_YES on success, MHD_NO if this daemon could 1008 * @return #MHD_YES on success, #MHD_NO if this daemon could
1009 * not handle the connection (i.e. malloc failed, etc). 1009 * not handle the connection (i.e. malloc failed, etc).
1010 * The socket will be closed in any case; 'errno' is 1010 * The socket will be closed in any case; 'errno' is
1011 * set to indicate further details about the error. 1011 * set to indicate further details about the error.
@@ -1813,12 +1813,12 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
1813 1813
1814 1814
1815/** 1815/**
1816 * Main internal select call. Will compute select sets, call 'select' 1816 * Main internal select() call. Will compute select sets, call select()
1817 * and then MHD_run_from_select with the result. 1817 * and then #MHD_run_from_select with the result.
1818 * 1818 *
1819 * @param daemon daemon to run select loop for 1819 * @param daemon daemon to run select() loop for
1820 * @param may_block YES if blocking, NO if non-blocking 1820 * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking
1821 * @return MHD_NO on serious errors, MHD_YES on success 1821 * @return #MHD_NO on serious errors, #MHD_YES on success
1822 */ 1822 */
1823static int 1823static int
1824MHD_select (struct MHD_Daemon *daemon, 1824MHD_select (struct MHD_Daemon *daemon,
@@ -1906,11 +1906,11 @@ MHD_select (struct MHD_Daemon *daemon,
1906#ifdef HAVE_POLL_H 1906#ifdef HAVE_POLL_H
1907/** 1907/**
1908 * Process all of our connections and possibly the server 1908 * Process all of our connections and possibly the server
1909 * socket using 'poll'. 1909 * socket using poll().
1910 * 1910 *
1911 * @param daemon daemon to run poll loop for 1911 * @param daemon daemon to run poll loop for
1912 * @param may_block YES if blocking, NO if non-blocking 1912 * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking
1913 * @return MHD_NO on serious errors, MHD_YES on success 1913 * @return #MHD_NO on serious errors, #MHD_YES on success
1914 */ 1914 */
1915static int 1915static int
1916MHD_poll_all (struct MHD_Daemon *daemon, 1916MHD_poll_all (struct MHD_Daemon *daemon,
@@ -2053,11 +2053,11 @@ MHD_poll_all (struct MHD_Daemon *daemon,
2053 2053
2054 2054
2055/** 2055/**
2056 * Process only the listen socket using 'poll'. 2056 * Process only the listen socket using poll().
2057 * 2057 *
2058 * @param daemon daemon to run poll loop for 2058 * @param daemon daemon to run poll loop for
2059 * @param may_block YES if blocking, NO if non-blocking 2059 * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking
2060 * @return MHD_NO on serious errors, MHD_YES on success 2060 * @return #MHD_NO on serious errors, #MHD_YES on success
2061 */ 2061 */
2062static int 2062static int
2063MHD_poll_listen_socket (struct MHD_Daemon *daemon, 2063MHD_poll_listen_socket (struct MHD_Daemon *daemon,
@@ -2113,11 +2113,11 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon,
2113 2113
2114 2114
2115/** 2115/**
2116 * Do 'poll'-based processing. 2116 * Do poll()-based processing.
2117 * 2117 *
2118 * @param daemon daemon to run poll loop for 2118 * @param daemon daemon to run poll()-loop for
2119 * @param may_block YES if blocking, NO if non-blocking 2119 * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking
2120 * @return MHD_NO on serious errors, MHD_YES on success 2120 * @return #MHD_NO on serious errors, #MHD_YES on success
2121 */ 2121 */
2122static int 2122static int
2123MHD_poll (struct MHD_Daemon *daemon, 2123MHD_poll (struct MHD_Daemon *daemon,
@@ -2139,23 +2139,23 @@ MHD_poll (struct MHD_Daemon *daemon,
2139#if EPOLL_SUPPORT 2139#if EPOLL_SUPPORT
2140 2140
2141/** 2141/**
2142 * How many events to we process at most per epoll call? Trade-off 2142 * How many events to we process at most per epoll() call? Trade-off
2143 * between required stack-size and number of system calls we have to 2143 * between required stack-size and number of system calls we have to
2144 * make; 128 should be way enough to avoid more than one system call 2144 * make; 128 should be way enough to avoid more than one system call
2145 * for most scenarios, and still be moderate in stack size 2145 * for most scenarios, and still be moderate in stack size
2146 * consumption. Embedded systems might want to choose a smaller value 2146 * consumption. Embedded systems might want to choose a smaller value
2147 * --- but why use 'epoll' on such a system in the first place? 2147 * --- but why use epoll() on such a system in the first place?
2148 */ 2148 */
2149#define MAX_EVENTS 128 2149#define MAX_EVENTS 128
2150 2150
2151 2151
2152/** 2152/**
2153 * Do 'epoll'-based processing (this function is allowed to 2153 * Do epoll()-based processing (this function is allowed to
2154 * block if 'may_block' is set to MHD_YES). 2154 * block if @a may_block is set to #MHD_YES).
2155 * 2155 *
2156 * @param daemon daemon to run poll loop for 2156 * @param daemon daemon to run poll loop for
2157 * @param may_block MHD_YES if blocking, MHD_NO if non-blocking 2157 * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking
2158 * @return MHD_NO on serious errors, MHD_YES on success 2158 * @return #MHD_NO on serious errors, #MHD_YES on success
2159 */ 2159 */
2160static int 2160static int
2161MHD_epoll (struct MHD_Daemon *daemon, 2161MHD_epoll (struct MHD_Daemon *daemon,
@@ -2424,7 +2424,7 @@ MHD_select_thread (void *cls)
2424 * will be allowed to connect; you can pass NULL 2424 * will be allowed to connect; you can pass NULL
2425 * in which case connections from any IP will be 2425 * in which case connections from any IP will be
2426 * accepted 2426 * accepted
2427 * @param apc_cls extra argument to apc 2427 * @param apc_cls extra argument to @a apc
2428 * @param dh handler called for all requests (repeatedly) 2428 * @param dh handler called for all requests (repeatedly)
2429 * @param dh_cls extra argument to @a dh 2429 * @param dh_cls extra argument to @a dh
2430 * @return NULL on error, handle to daemon on success 2430 * @return NULL on error, handle to daemon on success
@@ -2539,7 +2539,7 @@ typedef void (*VfprintfFunctionPointerType)(void *cls,
2539 * @param daemon the daemon to initialize 2539 * @param daemon the daemon to initialize
2540 * @param servaddr where to store the server's listen address 2540 * @param servaddr where to store the server's listen address
2541 * @param ap the options 2541 * @param ap the options
2542 * @return MHD_YES on success, MHD_NO on error 2542 * @return #MHD_YES on success, #MHD_NO on error
2543 */ 2543 */
2544static int 2544static int
2545parse_options_va (struct MHD_Daemon *daemon, 2545parse_options_va (struct MHD_Daemon *daemon,
@@ -2553,7 +2553,7 @@ parse_options_va (struct MHD_Daemon *daemon,
2553 * @param daemon the daemon to initialize 2553 * @param daemon the daemon to initialize
2554 * @param servaddr where to store the server's listen address 2554 * @param servaddr where to store the server's listen address
2555 * @param ... the options 2555 * @param ... the options
2556 * @return MHD_YES on success, MHD_NO on error 2556 * @return #MHD_YES on success, #MHD_NO on error
2557 */ 2557 */
2558static int 2558static int
2559parse_options (struct MHD_Daemon *daemon, 2559parse_options (struct MHD_Daemon *daemon,
@@ -2576,7 +2576,7 @@ parse_options (struct MHD_Daemon *daemon,
2576 * @param daemon the daemon to initialize 2576 * @param daemon the daemon to initialize
2577 * @param servaddr where to store the server's listen address 2577 * @param servaddr where to store the server's listen address
2578 * @param ap the options 2578 * @param ap the options
2579 * @return MHD_YES on success, MHD_NO on error 2579 * @return #MHD_YES on success, #MHD_NO on error
2580 */ 2580 */
2581static int 2581static int
2582parse_options_va (struct MHD_Daemon *daemon, 2582parse_options_va (struct MHD_Daemon *daemon,
@@ -2828,7 +2828,7 @@ parse_options_va (struct MHD_Daemon *daemon,
2828 2828
2829 2829
2830/** 2830/**
2831 * Create a listen socket, if possible with CLOEXEC flag set. 2831 * Create a listen socket, if possible with SOCK_CLOEXEC flag set.
2832 * 2832 *
2833 * @param daemon daemon for which we create the socket 2833 * @param daemon daemon for which we create the socket
2834 * @param domain socket domain (i.e. PF_INET) 2834 * @param domain socket domain (i.e. PF_INET)
@@ -2860,11 +2860,11 @@ create_socket (struct MHD_Daemon *daemon,
2860 2860
2861#if EPOLL_SUPPORT 2861#if EPOLL_SUPPORT
2862/** 2862/**
2863 * Setup epoll FD for the daemon and initialize it to listen 2863 * Setup epoll() FD for the daemon and initialize it to listen
2864 * on the listen FD. 2864 * on the listen FD.
2865 * 2865 *
2866 * @param daemon daemon to initialize for epoll 2866 * @param daemon daemon to initialize for epoll()
2867 * @return MHD_YES on success, MHD_NO on failure 2867 * @return #MHD_YES on success, #MHD_NO on failure
2868 */ 2868 */
2869static int 2869static int
2870setup_epoll_to_listen (struct MHD_Daemon *daemon) 2870setup_epoll_to_listen (struct MHD_Daemon *daemon)
@@ -2917,7 +2917,7 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon)
2917 * will be allowed to connect; you can pass NULL 2917 * will be allowed to connect; you can pass NULL
2918 * in which case connections from any IP will be 2918 * in which case connections from any IP will be
2919 * accepted 2919 * accepted
2920 * @param apc_cls extra argument to apc 2920 * @param apc_cls extra argument to @a apc
2921 * @param dh handler called for all requests (repeatedly) 2921 * @param dh handler called for all requests (repeatedly)
2922 * @param dh_cls extra argument to @a dh 2922 * @param dh_cls extra argument to @a dh
2923 * @param ap list of options (type-value pairs, 2923 * @param ap list of options (type-value pairs,
@@ -3596,9 +3596,9 @@ close_all_connections (struct MHD_Daemon *daemon)
3596 3596
3597#if EPOLL_SUPPORT 3597#if EPOLL_SUPPORT
3598/** 3598/**
3599 * Shutdown 'epoll' event loop by adding 'wpipe' to its event set. 3599 * Shutdown epoll()-event loop by adding 'wpipe' to its event set.
3600 * 3600 *
3601 * @param daemon daemon of which the epoll instance must be signalled 3601 * @param daemon daemon of which the epoll() instance must be signalled
3602 */ 3602 */
3603static void 3603static void
3604epoll_shutdown (struct MHD_Daemon *daemon) 3604epoll_shutdown (struct MHD_Daemon *daemon)
@@ -3868,3 +3868,4 @@ MHD_fini ()
3868} 3868}
3869 3869
3870/* end of daemon.c */ 3870/* end of daemon.c */
3871