aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-06-23 10:49:30 +0000
committerChristian Grothoff <christian@grothoff.org>2013-06-23 10:49:30 +0000
commitefbf50c0d22b0c27088d05b707773433371cc9c1 (patch)
treee48d0e74fe76060bc4e18b7126563b1c95ecd98c
parent21c355734b03b1e39f123d14142e25f71095767a (diff)
downloadlibmicrohttpd-efbf50c0d22b0c27088d05b707773433371cc9c1.tar.gz
libmicrohttpd-efbf50c0d22b0c27088d05b707773433371cc9c1.zip
-API for supporting epoll
-rw-r--r--src/include/microhttpd.h65
1 files changed, 58 insertions, 7 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index ce6865b8..5c87c721 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -106,7 +106,7 @@ extern "C"
106/** 106/**
107 * Current version of the library. 107 * Current version of the library.
108 */ 108 */
109#define MHD_VERSION 0x00092101 109#define MHD_VERSION 0x00092103
110 110
111/** 111/**
112 * MHD-internal return code for "YES". 112 * MHD-internal return code for "YES".
@@ -351,7 +351,7 @@ enum MHD_FLAG
351 MHD_USE_THREAD_PER_CONNECTION = 4, 351 MHD_USE_THREAD_PER_CONNECTION = 4,
352 352
353 /** 353 /**
354 * Run using an internal thread doing SELECT. 354 * Run using an internal thread (or thread pool) doing SELECT.
355 */ 355 */
356 MHD_USE_SELECT_INTERNALLY = 8, 356 MHD_USE_SELECT_INTERNALLY = 8,
357 357
@@ -373,11 +373,20 @@ enum MHD_FLAG
373 MHD_USE_PEDANTIC_CHECKS = 32, 373 MHD_USE_PEDANTIC_CHECKS = 32,
374 374
375 /** 375 /**
376 * Use poll instead of select. This allows sockets with fd >= FD_SETSIZE. 376 * Use poll instead of select. This allows sockets with fd >=
377 * FD_SETSIZE. This option is not compatible with using an
378 * 'external' select mode (as there is no API to get the file
379 * descriptors for the external select from MHD) and must also not
380 * be used in combination with MHD_USE_EPOLL_LINUX_ONLY.
377 */ 381 */
378 MHD_USE_POLL = 64, 382 MHD_USE_POLL = 64,
379 383
380 /** 384 /**
385 * Run using an internal thread (or thread pool) doing POLL.
386 */
387 MHD_USE_POLL_INTERNALLY = MHD_USE_SELECT_INTERNALLY | MHD_USE_POLL,
388
389 /**
381 * Suppress (automatically) adding the 'Date:' header to HTTP responses. 390 * Suppress (automatically) adding the 'Date:' header to HTTP responses.
382 * This option should ONLY be used on systems that do not have a clock 391 * This option should ONLY be used on systems that do not have a clock
383 * and that DO provide other mechanisms for cache control. See also 392 * and that DO provide other mechanisms for cache control. See also
@@ -392,7 +401,34 @@ enum MHD_FLAG
392 * using a thread pool; if it is used, 'MHD_OPTION_THREAD_POOL_SIZE' 401 * using a thread pool; if it is used, 'MHD_OPTION_THREAD_POOL_SIZE'
393 * is ignored. 402 * is ignored.
394 */ 403 */
395 MHD_USE_NO_LISTEN_SOCKET = 256 404 MHD_USE_NO_LISTEN_SOCKET = 256,
405
406 /**
407 * Use 'epoll' instead of 'select' or 'poll' for the event loop.
408 * This option is only available on Linux; using the option on
409 * non-Linux systems will cause 'MHD_start_daemon' to fail.
410 */
411 MHD_USE_EPOLL_LINUX_ONLY = 512,
412
413 /**
414 * Run using an internal thread (or thread pool) doing EPOLL.
415 * This option is only available on Linux; using the option on
416 * non-Linux systems will cause 'MHD_start_daemon' to fail.
417 */
418 MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY = MHD_USE_SELECT_INTERNALLY | MHD_USE_EPOLL_LINUX_ONLY,
419
420 /**
421 * Force MHD to use a signal pipe to notify the event loop (of
422 * threads) of our shutdown. This is required if an appliction uses
423 * 'MHD_USE_INTERNAL_SELECT' or 'MHD_USE_THREAD_PER_CONNECTION' and
424 * then performs 'MHD_quiesce_daemon' (which eliminates our ability
425 * to signal termination via the listen socket). In these modes,
426 * 'MHD_quiesce_daemon' will fail if this option was not set. Also,
427 * use of this option is automatic (as in, you do not even have to
428 * specify it), if 'MHD_USE_NO_LISTEN_SOCKET' is specified. In
429 * "external" select mode, this option is always simply ignored.
430 */
431 MHD_USE_PIPE_FOR_SHUTDOWN = 1024
396 432
397}; 433};
398 434
@@ -629,7 +665,7 @@ enum MHD_OPTION
629 * HTTPS daemon for client authentification. 665 * HTTPS daemon for client authentification.
630 * This option should be followed by a "const char*" argument. 666 * This option should be followed by a "const char*" argument.
631 */ 667 */
632 MHD_OPTION_HTTPS_MEM_TRUST =20 668 MHD_OPTION_HTTPS_MEM_TRUST = 20
633}; 669};
634 670
635 671
@@ -814,6 +850,7 @@ enum MHD_DaemonInfoType
814 * a particular cipher algorithm. The cipher 850 * a particular cipher algorithm. The cipher
815 * algorithm should be passed as an extra 851 * algorithm should be passed as an extra
816 * argument (of type 'enum MHD_GNUTLS_CipherAlgorithm'). 852 * argument (of type 'enum MHD_GNUTLS_CipherAlgorithm').
853 * No longer supported (will return NULL).
817 */ 854 */
818 MHD_DAEMON_INFO_KEY_SIZE, 855 MHD_DAEMON_INFO_KEY_SIZE,
819 856
@@ -822,6 +859,7 @@ enum MHD_DaemonInfoType
822 * a particular cipher algorithm. The cipher 859 * a particular cipher algorithm. The cipher
823 * algorithm should be passed as an extra 860 * algorithm should be passed as an extra
824 * argument (of type 'enum MHD_GNUTLS_HashAlgorithm'). 861 * argument (of type 'enum MHD_GNUTLS_HashAlgorithm').
862 * No longer supported (will return NULL).
825 */ 863 */
826 MHD_DAEMON_INFO_MAC_KEY_SIZE, 864 MHD_DAEMON_INFO_MAC_KEY_SIZE,
827 865
@@ -829,7 +867,13 @@ enum MHD_DaemonInfoType
829 * Request the file descriptor for the listening socket. 867 * Request the file descriptor for the listening socket.
830 * No extra arguments should be passed. 868 * No extra arguments should be passed.
831 */ 869 */
832 MHD_DAEMON_INFO_LISTEN_FD 870 MHD_DAEMON_INFO_LISTEN_FD,
871
872 /**
873 * Request the file descriptor for the external epoll.
874 * No extra arguments should be passed.
875 */
876 MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY
833}; 877};
834 878
835 879
@@ -881,7 +925,7 @@ typedef
881 */ 925 */
882typedef int 926typedef int
883 (*MHD_AcceptPolicyCallback) (void *cls, 927 (*MHD_AcceptPolicyCallback) (void *cls,
884 const struct sockaddr * addr, 928 const struct sockaddr *addr,
885 socklen_t addrlen); 929 socklen_t addrlen);
886 930
887 931
@@ -1117,6 +1161,11 @@ MHD_start_daemon (unsigned int flags,
1117 * "MHD_stop_daemon" has been called (as it is theoretically possible 1161 * "MHD_stop_daemon" has been called (as it is theoretically possible
1118 * that an existing thread is still using it). 1162 * that an existing thread is still using it).
1119 * 1163 *
1164 * Note that some thread modes require the caller to have passed
1165 * MHD_USE_PIPE_FOR_SHUTDOWN when using this API. If this daemon is
1166 * in one of those modes and this option was not given to
1167 * 'MHD_start_daemon', this function will return -1.
1168 *
1120 * @param daemon daemon to stop accepting new connections for 1169 * @param daemon daemon to stop accepting new connections for
1121 * @return old listen socket on success, -1 if the daemon was 1170 * @return old listen socket on success, -1 if the daemon was
1122 * already not listening anymore 1171 * already not listening anymore
@@ -1248,6 +1297,8 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
1248 const fd_set *except_fd_set); 1297 const fd_set *except_fd_set);
1249 1298
1250 1299
1300
1301
1251/* **************** Connection handling functions ***************** */ 1302/* **************** Connection handling functions ***************** */
1252 1303
1253/** 1304/**