[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 04/05: Replaced calls of MHD_get_timeout() in tests and
From: |
gnunet |
Subject: |
[libmicrohttpd] 04/05: Replaced calls of MHD_get_timeout() in tests and examples |
Date: |
Thu, 28 Apr 2022 18:09:47 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit ba77b04c65c5b6b0bad204f8e08f986b5c215dc0
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu Apr 28 17:19:54 2022 +0300
Replaced calls of MHD_get_timeout() in tests and examples
The calls were replaced with the calls of the new functions.
Completely removed the usage of MHD_UNSIGNED_LONG_LONG.
---
doc/examples/sessions.c | 4 +--
src/examples/fileserver_example_external_select.c | 6 ++---
src/examples/post_example.c | 4 +--
src/examples/suspend_resume_epoll.c | 12 ++-------
src/microhttpd/test_client_put_stop.c | 3 +--
src/microhttpd/test_set_panic.c | 3 +--
src/microhttpd/test_upgrade.c | 32 +++++++++++------------
src/microhttpd/test_upgrade_large.c | 32 +++++++++++------------
src/testcurl/perf_get_concurrent.c | 10 +++----
src/testcurl/test_get_close_keep_alive.c | 3 +--
src/testcurl/test_post_loop.c | 16 ++++++------
src/testcurl/test_toolarge.c | 3 +--
src/testcurl/test_tricky.c | 3 +--
13 files changed, 59 insertions(+), 72 deletions(-)
diff --git a/doc/examples/sessions.c b/doc/examples/sessions.c
index 0c8e5114..9b36c485 100644
--- a/doc/examples/sessions.c
+++ b/doc/examples/sessions.c
@@ -742,7 +742,7 @@ main (int argc, char *const *argv)
fd_set ws;
fd_set es;
MHD_socket max;
- MHD_UNSIGNED_LONG_LONG mhd_timeout;
+ uint64_t mhd_timeout;
if (argc != 2)
{
@@ -770,7 +770,7 @@ main (int argc, char *const *argv)
FD_ZERO (&es);
if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
break; /* fatal internal error */
- if (MHD_get_timeout (d, &mhd_timeout) == MHD_YES)
+ if (MHD_get_timeout64 (d, &mhd_timeout) == MHD_YES)
{
tv.tv_sec = mhd_timeout / 1000;
tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000)) * 1000;
diff --git a/src/examples/fileserver_example_external_select.c
b/src/examples/fileserver_example_external_select.c
index cdd455ec..3c077413 100644
--- a/src/examples/fileserver_example_external_select.c
+++ b/src/examples/fileserver_example_external_select.c
@@ -134,7 +134,7 @@ main (int argc, char *const *argv)
fd_set ws;
fd_set es;
MHD_socket max;
- MHD_UNSIGNED_LONG_LONG mhd_timeout;
+ uint64_t mhd_timeout;
if (argc != 3)
{
@@ -157,9 +157,9 @@ main (int argc, char *const *argv)
FD_ZERO (&es);
if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
break; /* fatal internal error */
- if (MHD_get_timeout (d, &mhd_timeout) == MHD_YES)
+ if (MHD_get_timeout64 (d, &mhd_timeout) == MHD_YES)
{
- if (((MHD_UNSIGNED_LONG_LONG) tv.tv_sec) < mhd_timeout / 1000LL)
+ if (((uint64_t) tv.tv_sec) < mhd_timeout / 1000LL)
{
tv.tv_sec = mhd_timeout / 1000LL;
tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000LL)) * 1000LL;
diff --git a/src/examples/post_example.c b/src/examples/post_example.c
index 1134a331..709fc918 100644
--- a/src/examples/post_example.c
+++ b/src/examples/post_example.c
@@ -733,7 +733,7 @@ main (int argc, char *const *argv)
fd_set ws;
fd_set es;
MHD_socket max;
- MHD_UNSIGNED_LONG_LONG mhd_timeout;
+ uint64_t mhd_timeout;
if (argc != 2)
{
@@ -761,7 +761,7 @@ main (int argc, char *const *argv)
FD_ZERO (&es);
if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
break; /* fatal internal error */
- if (MHD_get_timeout (d, &mhd_timeout) == MHD_YES)
+ if (MHD_get_timeout64 (d, &mhd_timeout) == MHD_YES)
{
tv.tv_sec = mhd_timeout / 1000;
tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000)) * 1000;
diff --git a/src/examples/suspend_resume_epoll.c
b/src/examples/suspend_resume_epoll.c
index b63f80be..87ec6521 100644
--- a/src/examples/suspend_resume_epoll.c
+++ b/src/examples/suspend_resume_epoll.c
@@ -174,16 +174,8 @@ main (int argc,
while (1)
{
- int timeout;
- MHD_UNSIGNED_LONG_LONG to;
-
- if (MHD_YES !=
- MHD_get_timeout (d,
- &to))
- timeout = TIMEOUT_INFINITE;
- else
- timeout = (to < INT_MAX - 1) ? (int) to : (INT_MAX - 1);
- current_event_count = epoll_wait (epfd, events_list, 1, timeout);
+ current_event_count = epoll_wait (epfd, events_list, 1,
+ MHD_get_timeout_i (d));
if (1 == current_event_count)
{
diff --git a/src/microhttpd/test_client_put_stop.c
b/src/microhttpd/test_client_put_stop.c
index 09845ff9..dfd6af2e 100644
--- a/src/microhttpd/test_client_put_stop.c
+++ b/src/microhttpd/test_client_put_stop.c
@@ -1408,10 +1408,9 @@ performQueryExternal (struct MHD_Daemon *d, struct
_MHD_dumbClient *clnt)
{
/* client has finished, check whether MHD is still
* processing any connections */
- unsigned long long to;
full_req_sent = 1;
do_client = 0;
- if (client_accepted && (MHD_YES != MHD_get_timeout (d, &to)))
+ if (client_accepted && (0 > MHD_get_timeout64s (d)))
{
ret = 0;
break; /* MHD finished as well */
diff --git a/src/microhttpd/test_set_panic.c b/src/microhttpd/test_set_panic.c
index 2d81c620..b1a24000 100644
--- a/src/microhttpd/test_set_panic.c
+++ b/src/microhttpd/test_set_panic.c
@@ -1179,10 +1179,9 @@ performQueryExternal (struct MHD_Daemon *d, struct
_MHD_dumbClient *clnt)
{
/* client has finished, check whether MHD is still
* processing any connections */
- unsigned long long to;
full_req_sent = 1;
do_client = 0;
- if (client_accepted && (MHD_YES != MHD_get_timeout (d, &to)))
+ if (client_accepted && (0 > MHD_get_timeout64s (d)))
{
ret = 0;
break; /* MHD finished as well */
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c
index 2ade5edd..5ceb6466 100644
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@ -1095,7 +1095,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
fd_set ws;
fd_set es;
MHD_socket max_fd;
- MHD_UNSIGNED_LONG_LONG to;
+ uint64_t to64;
struct timeval tv;
while (! done)
@@ -1104,7 +1104,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
FD_ZERO (&ws);
FD_ZERO (&es);
max_fd = MHD_INVALID_SOCKET;
- to = 1000;
+ to64 = 1000;
if (MHD_YES !=
MHD_get_fdset (daemon,
@@ -1113,12 +1113,12 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
&es,
&max_fd))
mhdErrorExitDesc ("MHD_get_fdset() failed");
- (void) MHD_get_timeout (daemon,
- &to);
- if (1000 < to)
- to = 1000;
- tv.tv_sec = to / 1000;
- tv.tv_usec = 1000 * (to % 1000);
+ (void) MHD_get_timeout64 (daemon,
+ &to64);
+ if (1000 < to64)
+ to64 = 1000;
+ tv.tv_sec = to64 / 1000;
+ tv.tv_usec = 1000 * (to64 % 1000);
if (0 > MHD_SYS_select_ (max_fd + 1,
&rs,
&ws,
@@ -1173,7 +1173,7 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
const union MHD_DaemonInfo *di;
MHD_socket ep;
fd_set rs;
- MHD_UNSIGNED_LONG_LONG to;
+ uint64_t to64;
struct timeval tv;
int ret;
@@ -1185,15 +1185,15 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
while (! done)
{
FD_ZERO (&rs);
- to = 1000;
+ to64 = 1000;
FD_SET (ep, &rs);
- (void) MHD_get_timeout (daemon,
- &to);
- if (1000 < to)
- to = 1000;
- tv.tv_sec = to / 1000;
- tv.tv_usec = 1000 * (to % 1000);
+ (void) MHD_get_timeout64 (daemon,
+ &to64);
+ if (1000 < to64)
+ to64 = 1000;
+ tv.tv_sec = to64 / 1000;
+ tv.tv_usec = 1000 * (to64 % 1000);
ret = select (ep + 1,
&rs,
NULL,
diff --git a/src/microhttpd/test_upgrade_large.c
b/src/microhttpd/test_upgrade_large.c
index 83ab50ca..312a3448 100644
--- a/src/microhttpd/test_upgrade_large.c
+++ b/src/microhttpd/test_upgrade_large.c
@@ -1278,7 +1278,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
fd_set ws;
fd_set es;
MHD_socket max_fd;
- MHD_UNSIGNED_LONG_LONG to;
+ uint64_t to64;
struct timeval tv;
while (! done)
@@ -1287,7 +1287,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
FD_ZERO (&ws);
FD_ZERO (&es);
max_fd = MHD_INVALID_SOCKET;
- to = 1000;
+ to64 = 1000;
FD_SET (MHD_itc_r_fd_ (kicker), &rs);
if (MHD_YES !=
@@ -1297,12 +1297,12 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
&es,
&max_fd))
mhdErrorExitDesc ("MHD_get_fdset() failed");
- (void) MHD_get_timeout (daemon,
- &to);
- if (1000 < to)
- to = 1000;
- tv.tv_sec = to / 1000;
- tv.tv_usec = 1000 * (to % 1000);
+ (void) MHD_get_timeout64 (daemon,
+ &to64);
+ if (1000 < to64)
+ to64 = 1000;
+ tv.tv_sec = to64 / 1000;
+ tv.tv_usec = 1000 * (to64 % 1000);
if (0 > MHD_SYS_select_ (max_fd + 1,
&rs,
&ws,
@@ -1359,7 +1359,7 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
const union MHD_DaemonInfo *di;
MHD_socket ep;
fd_set rs;
- MHD_UNSIGNED_LONG_LONG to;
+ uint64_t to64;
struct timeval tv;
int ret;
@@ -1371,15 +1371,15 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
while (! done)
{
FD_ZERO (&rs);
- to = 1000;
+ to64 = 1000;
FD_SET (MHD_itc_r_fd_ (kicker), &rs);
FD_SET (ep, &rs);
- (void) MHD_get_timeout (daemon,
- &to);
- if (1000 < to)
- to = 1000;
- tv.tv_sec = to / 1000;
- tv.tv_usec = 1000 * (to % 1000);
+ (void) MHD_get_timeout64 (daemon,
+ &to64);
+ if (1000 < to64)
+ to64 = 1000;
+ tv.tv_sec = to64 / 1000;
+ tv.tv_usec = 1000 * (to64 % 1000);
ret = select (ep + 1,
&rs,
NULL,
diff --git a/src/testcurl/perf_get_concurrent.c
b/src/testcurl/perf_get_concurrent.c
index ea282874..80f66eea 100644
--- a/src/testcurl/perf_get_concurrent.c
+++ b/src/testcurl/perf_get_concurrent.c
@@ -413,7 +413,7 @@ testExternalGet (int port)
fd_set es;
MHD_socket max;
struct timeval tv;
- MHD_UNSIGNED_LONG_LONG tt;
+ uint64_t tt64;
int tret;
char *ret_val;
int ret = 0;
@@ -455,11 +455,11 @@ testExternalGet (int port)
MHD_stop_daemon (d);
return 4096;
}
- tret = MHD_get_timeout (d, &tt);
+ tret = MHD_get_timeout64 (d, &tt64);
if (MHD_YES != tret)
- tt = 1;
- tv.tv_sec = tt / 1000;
- tv.tv_usec = 1000 * (tt % 1000);
+ tt64 = 1;
+ tv.tv_sec = tt64 / 1000;
+ tv.tv_usec = 1000 * (tt64 % 1000);
if (-1 == select (max + 1, &rs, &ws, &es, &tv))
{
#ifdef MHD_POSIX_SOCKETS
diff --git a/src/testcurl/test_get_close_keep_alive.c
b/src/testcurl/test_get_close_keep_alive.c
index 8f83fa1d..7857f2ad 100644
--- a/src/testcurl/test_get_close_keep_alive.c
+++ b/src/testcurl/test_get_close_keep_alive.c
@@ -562,8 +562,7 @@ performQueryExternal (struct MHD_Daemon *d, CURL *c)
}
if (NULL == multi)
{ /* libcurl has finished, check whether MHD still needs to perform
cleanup */
- unsigned long long to;
- if ((MHD_YES != MHD_get_timeout (d, &to)) || (0 != to))
+ if (0 != MHD_get_timeout64s (d))
break; /* MHD finished as well */
}
if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk))
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c
index c36fba7f..37cd121b 100644
--- a/src/testcurl/test_post_loop.c
+++ b/src/testcurl/test_post_loop.c
@@ -413,7 +413,7 @@ testExternalPost ()
time_t start;
struct timeval tv;
int i;
- unsigned long long timeout;
+ uint64_t timeout64;
long ctimeout;
char url[1024];
int port;
@@ -516,15 +516,15 @@ testExternalPost ()
MHD_stop_daemon (d);
return 4096;
}
- if (MHD_NO == MHD_get_timeout (d, &timeout))
- timeout = 100; /* 100ms == INFTY -- CURL bug... */
+ if (MHD_NO == MHD_get_timeout64 (d, &timeout64))
+ timeout64 = 100; /* 100ms == INFTY -- CURL bug... */
if ((CURLM_OK == curl_multi_timeout (multi, &ctimeout)) &&
- (ctimeout < (long long) timeout) && (ctimeout >= 0))
- timeout = ctimeout;
+ (ctimeout >= 0) && ((uint64_t) ctimeout < timeout64))
+ timeout64 = (uint64_t) ctimeout;
if ( (c == NULL) || (0 == running) )
- timeout = 0; /* terminate quickly... */
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout % 1000) * 1000;
+ timeout64 = 0; /* terminate quickly... */
+ tv.tv_sec = timeout64 / 1000;
+ tv.tv_usec = (timeout64 % 1000) * 1000;
if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv))
{
#ifdef MHD_POSIX_SOCKETS
diff --git a/src/testcurl/test_toolarge.c b/src/testcurl/test_toolarge.c
index d8bfaef6..42ea471f 100644
--- a/src/testcurl/test_toolarge.c
+++ b/src/testcurl/test_toolarge.c
@@ -661,8 +661,7 @@ performQueryExternal (struct MHD_Daemon *d, CURL *c)
}
if (NULL == multi)
{ /* libcurl has finished, check whether MHD still needs to perform
cleanup */
- unsigned long long to;
- if ((MHD_YES != MHD_get_timeout (d, &to)) || (0 != to))
+ if (0 != MHD_get_timeout64s (d))
break; /* MHD finished as well */
}
if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk))
diff --git a/src/testcurl/test_tricky.c b/src/testcurl/test_tricky.c
index 1aca7dce..5bc28323 100644
--- a/src/testcurl/test_tricky.c
+++ b/src/testcurl/test_tricky.c
@@ -591,8 +591,7 @@ performQueryExternal (struct MHD_Daemon *d, CURL *c)
}
if (NULL == multi)
{ /* libcurl has finished, check whether MHD still needs to perform
cleanup */
- unsigned long long to;
- if ((MHD_YES != MHD_get_timeout (d, &to)) || (0 != to))
+ if (0 != MHD_get_timeout64s (d))
break; /* MHD finished as well */
}
if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk))
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.