diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-04-28 16:59:19 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-04-28 19:06:46 +0300 |
commit | c6eae238be6357a7e0b77298a0cdada4c63e80bc (patch) | |
tree | e2c1239c5e621452a953316f0bbd90ce5355f0a1 /src/include/microhttpd.h | |
parent | aea4dcaefeb0b5baef0b7742356403f31a462e62 (diff) | |
download | libmicrohttpd-c6eae238be6357a7e0b77298a0cdada4c63e80bc.tar.gz libmicrohttpd-c6eae238be6357a7e0b77298a0cdada4c63e80bc.zip |
Added new function MHD_get_timeout_i()
This function is useful for direct in in poll() or epoll_wait().
Diffstat (limited to 'src/include/microhttpd.h')
-rw-r--r-- | src/include/microhttpd.h | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index 0563e907..8f89eba0 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -96,7 +96,7 @@ extern "C" | |||
96 | * they are parsed as decimal numbers. | 96 | * they are parsed as decimal numbers. |
97 | * Example: 0x01093001 = 1.9.30-1. | 97 | * Example: 0x01093001 = 1.9.30-1. |
98 | */ | 98 | */ |
99 | #define MHD_VERSION 0x00097509 | 99 | #define MHD_VERSION 0x00097510 |
100 | 100 | ||
101 | /* If generic headers don't work on your platform, include headers | 101 | /* If generic headers don't work on your platform, include headers |
102 | which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', | 102 | which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', |
@@ -2903,7 +2903,8 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon, | |||
2903 | * connections with data pending in network buffers and other problems. | 2903 | * connections with data pending in network buffers and other problems. |
2904 | * | 2904 | * |
2905 | * It is important to always use this function (or #MHD_get_timeout64(), | 2905 | * It is important to always use this function (or #MHD_get_timeout64(), |
2906 | * #MHD_get_timeout64s() functions) when "external" polling is used. | 2906 | * #MHD_get_timeout64s(), #MHD_get_timeout_i() functions) when "external" |
2907 | * polling is used. | ||
2907 | * If this function returns #MHD_YES then #MHD_run() (or #MHD_run_from_select()) | 2908 | * If this function returns #MHD_YES then #MHD_run() (or #MHD_run_from_select()) |
2908 | * must be called right after return from polling function, regardless of | 2909 | * must be called right after return from polling function, regardless of |
2909 | * the states of MHD FDs. | 2910 | * the states of MHD FDs. |
@@ -2939,7 +2940,8 @@ MHD_get_timeout (struct MHD_Daemon *daemon, | |||
2939 | * connections with data pending in network buffers and other problems. | 2940 | * connections with data pending in network buffers and other problems. |
2940 | * | 2941 | * |
2941 | * It is important to always use this function (or #MHD_get_timeout(), | 2942 | * It is important to always use this function (or #MHD_get_timeout(), |
2942 | * #MHD_get_timeout64s() functions) when "external" polling is used. | 2943 | * #MHD_get_timeout64s(), #MHD_get_timeout_i() functions) when "external" |
2944 | * polling is used. | ||
2943 | * If this function returns #MHD_YES then #MHD_run() (or #MHD_run_from_select()) | 2945 | * If this function returns #MHD_YES then #MHD_run() (or #MHD_run_from_select()) |
2944 | * must be called right after return from polling function, regardless of | 2946 | * must be called right after return from polling function, regardless of |
2945 | * the states of MHD FDs. | 2947 | * the states of MHD FDs. |
@@ -2978,7 +2980,8 @@ MHD_get_timeout64 (struct MHD_Daemon *daemon, | |||
2978 | * network buffers and other problems. | 2980 | * network buffers and other problems. |
2979 | * | 2981 | * |
2980 | * It is important to always use this function (or #MHD_get_timeout(), | 2982 | * It is important to always use this function (or #MHD_get_timeout(), |
2981 | * #MHD_get_timeout64() functions) when "external" polling is used. | 2983 | * #MHD_get_timeout64(), #MHD_get_timeout_i() functions) when "external" |
2984 | * polling is used. | ||
2982 | * If this function returns non-negative value then #MHD_run() (or | 2985 | * If this function returns non-negative value then #MHD_run() (or |
2983 | * #MHD_run_from_select()) must be called right after return from polling | 2986 | * #MHD_run_from_select()) must be called right after return from polling |
2984 | * function, regardless of the states of MHD FDs. | 2987 | * function, regardless of the states of MHD FDs. |
@@ -3002,6 +3005,47 @@ MHD_get_timeout64s (struct MHD_Daemon *daemon); | |||
3002 | 3005 | ||
3003 | 3006 | ||
3004 | /** | 3007 | /** |
3008 | * Obtain timeout value for external polling function for this daemon. | ||
3009 | * | ||
3010 | * This function set value to the amount of milliseconds for which polling | ||
3011 | * function (`select()`, `poll()` or epoll) should at most block, not the | ||
3012 | * timeout value set for connections. | ||
3013 | * | ||
3014 | * Any "external" sockets polling function must be called with the timeout | ||
3015 | * value provided by this function (if returned value is non-negative). | ||
3016 | * Smaller timeout values can be used for polling function if it is required | ||
3017 | * for any reason, but using larger timeout value or no timeout (indefinite | ||
3018 | * timeout) when this function returns non-negative value will break MHD | ||
3019 | * processing logic and result in "hung" connections with data pending in | ||
3020 | * network buffers and other problems. | ||
3021 | * | ||
3022 | * It is important to always use this function (or #MHD_get_timeout(), | ||
3023 | * #MHD_get_timeout64(), #MHD_get_timeout64s() functions) when "external" | ||
3024 | * polling is used. | ||
3025 | * If this function returns non-negative value then #MHD_run() (or | ||
3026 | * #MHD_run_from_select()) must be called right after return from polling | ||
3027 | * function, regardless of the states of MHD FDs. | ||
3028 | * | ||
3029 | * In practice, if zero or positive value is returned then #MHD_run() (or | ||
3030 | * #MHD_run_from_select()) must be called not later than returned amount of | ||
3031 | * millisecond even if no activity is detected on sockets by sockets | ||
3032 | * polling function. | ||
3033 | * | ||
3034 | * @param daemon the daemon to query for timeout | ||
3035 | * @return -1 if connections' timeouts are not set and no data processing | ||
3036 | * is pending, so external polling function may wait for sockets | ||
3037 | * activity for indefinite amount of time, | ||
3038 | * otherwise returned value is the the maximum amount of millisecond | ||
3039 | * (capped at INT_MAX) that external polling function must wait | ||
3040 | * for the activity of FDs. | ||
3041 | * @note Available since #MHD_VERSION 0x00097510 | ||
3042 | * @ingroup event | ||
3043 | */ | ||
3044 | _MHD_EXTERN int | ||
3045 | MHD_get_timeout_i (struct MHD_Daemon *daemon); | ||
3046 | |||
3047 | |||
3048 | /** | ||
3005 | * Run webserver operations (without blocking unless in client callbacks). | 3049 | * Run webserver operations (without blocking unless in client callbacks). |
3006 | * | 3050 | * |
3007 | * This method should be called by clients in combination with | 3051 | * This method should be called by clients in combination with |