[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 08/13: Added new function MHD_get_timeout64s()
From: |
gnunet |
Subject: |
[libmicrohttpd] 08/13: Added new function MHD_get_timeout64s() |
Date: |
Wed, 27 Apr 2022 21:25:16 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 860aa4e0ed63d3f1dc706bf669b9592fc4aef778
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed Apr 27 17:05:10 2022 +0300
Added new function MHD_get_timeout64s()
---
src/include/microhttpd.h | 42 ++++++++++++++++++++++++++++++++++++++++--
src/microhttpd/daemon.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 2 deletions(-)
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 3c2ad376..023a44ad 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -96,11 +96,11 @@ extern "C"
* they are parsed as decimal numbers.
* Example: 0x01093001 = 1.9.30-1.
*/
-#define MHD_VERSION 0x00097508
+#define MHD_VERSION 0x00097509
/* If generic headers don't work on your platform, include headers
which define 'va_list', 'size_t', 'ssize_t', 'intptr_t',
- 'uint16_t', 'uint32_t', 'uint64_t', 'off_t', 'struct sockaddr',
+ 'uint16_t', 'uint32_t', 'uint64_t', 'int64_t', 'off_t', 'struct sockaddr',
'socklen_t', 'fd_set' and "#define MHD_PLATFORM_H" before
including "microhttpd.h". Then the following "standard"
includes won't be used (which might be a good idea, especially
@@ -2960,6 +2960,44 @@ MHD_get_timeout64 (struct MHD_Daemon *daemon,
uint64_t *timeout);
+/**
+ * Obtain timeout value for external polling function for this daemon.
+ *
+ * This function set value to the amount of milliseconds for which polling
+ * function (`select()`, `poll()` or epoll) should at most block, not the
+ * timeout value set for connections.
+ *
+ * Any "external" sockets polling function must be called with the timeout
+ * value provided by this function (if returned value is non-negative).
+ * Smaller timeout values can be used for polling function if it is required
+ * for any reason, but using larger timeout value or no timeout (indefinite
+ * timeout) when this function returns non-negative value will break MHD
+ * processing logic and result in "hung" connections with data pending in
+ * network buffers and other problems.
+ *
+ * It is important to always use this function when "external" polling is
+ * used. If this function returns non-negative value then #MHD_run() (or
+ * #MHD_run_from_select()) must be called right after return from polling
+ * function, regardless of the states of MHD FDs.
+ *
+ * In practice, if zero or positive value is returned then #MHD_run() (or
+ * #MHD_run_from_select()) must be called not later than returned amount of
+ * millisecond even if no activity is detected on sockets by sockets
+ * polling function.
+ *
+ * @param daemon the daemon to query for timeout
+ * @return -1 if connections' timeouts are not set and no data processing
+ * is pending, so external polling function may wait for sockets
+ * activity for indefinite amount of time,
+ * otherwise returned value is the the maximum amount of millisecond
+ * that external polling function must wait for the activity of FDs.
+ * @note Available since #MHD_VERSION 0x00097509
+ * @ingroup event
+ */
+_MHD_EXTERN int64_t
+MHD_get_timeout64s (struct MHD_Daemon *daemon);
+
+
/**
* Run webserver operations (without blocking unless in client callbacks).
*
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index dec72581..80a15a02 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -4038,6 +4038,53 @@ MHD_get_timeout64 (struct MHD_Daemon *daemon,
}
+/**
+ * Obtain timeout value for external polling function for this daemon.
+ *
+ * This function set value to the amount of milliseconds for which polling
+ * function (`select()`, `poll()` or epoll) should at most block, not the
+ * timeout value set for connections.
+ *
+ * Any "external" sockets polling function must be called with the timeout
+ * value provided by this function (if returned value is non-negative).
+ * Smaller timeout values can be used for polling function if it is required
+ * for any reason, but using larger timeout value or no timeout (indefinite
+ * timeout) when this function returns non-negative value will break MHD
+ * processing logic and result in "hung" connections with data pending in
+ * network buffers and other problems.
+ *
+ * It is important to always use this function when "external" polling is
+ * used. If this function returns non-negative value then #MHD_run() (or
+ * #MHD_run_from_select()) must be called right after return from polling
+ * function, regardless of the states of MHD FDs.
+ *
+ * In practice, if zero or positive value is returned then #MHD_run() (or
+ * #MHD_run_from_select()) must be called not later than returned amount of
+ * millisecond even if no activity is detected on sockets by sockets
+ * polling function.
+ *
+ * @param daemon the daemon to query for timeout
+ * @return -1 if connections' timeouts are not set and no data processing
+ * is pending, so external polling function may wait for sockets
+ * activity for indefinite amount of time,
+ * otherwise returned value is the the maximum amount of millisecond
+ * that external polling function must wait for the activity of FDs.
+ * @note Available since #MHD_VERSION 0x00097509
+ * @ingroup event
+ */
+_MHD_EXTERN int64_t
+MHD_get_timeout64s (struct MHD_Daemon *daemon)
+{
+ uint64_t utimeout;
+ if (MHD_NO == MHD_get_timeout64 (daemon, &utimeout))
+ return -1;
+ if (INT64_MAX < utimeout)
+ return INT64_MAX;
+
+ return (int64_t) utimeout;
+}
+
+
/**
* Obtain timeout value for polling function for this daemon.
* @remark To be called only from the thread that processes
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (54e12358 -> d14fc3b3), gnunet, 2022/04/27
- [libmicrohttpd] 04/13: thread-per-connection: do not cache connection timeout, gnunet, 2022/04/27
- [libmicrohttpd] 03/13: Response from callback: do allow negative return amounts, except predefined values, gnunet, 2022/04/27
- [libmicrohttpd] 01/13: MHD_itc_clear_(): simplified eventfd version, gnunet, 2022/04/27
- [libmicrohttpd] 08/13: Added new function MHD_get_timeout64s(),
gnunet <=
- [libmicrohttpd] 02/13: Fixed compiler warnings of implicit casting, which could change the value, gnunet, 2022/04/27
- [libmicrohttpd] 06/13: Added new function MHD_get_timeout64(), gnunet, 2022/04/27
- [libmicrohttpd] 09/13: daemon: added workaround for 'uncrustify' broken formatting, gnunet, 2022/04/27
- [libmicrohttpd] 07/13: get_timeout_millisec_(): refactoring for readability, gnunet, 2022/04/27
- [libmicrohttpd] 05/13: thread-per-connection: improved timeout handling for 'poll()' mode, fixed short busy-waiting, gnunet, 2022/04/27
- [libmicrohttpd] 10/13: Use new function MHD_get_timeout64() in MHD code, gnunet, 2022/04/27
- [libmicrohttpd] 11/13: mhd_send: added safe default value if sysconf() is broken, gnunet, 2022/04/27
- [libmicrohttpd] 12/13: Fixes related to implicit cast warnings, gnunet, 2022/04/27
- [libmicrohttpd] 13/13: MHD_get_timeout*(): improved doxy, gnunet, 2022/04/27