[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28122 - in libmicrohttpd: . src/examples src/include src/m
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28122 - in libmicrohttpd: . src/examples src/include src/microspdy src/testspdy |
Date: |
Wed, 17 Jul 2013 16:46:49 +0200 |
Author: andreyu
Date: 2013-07-17 16:46:49 +0200 (Wed, 17 Jul 2013)
New Revision: 28122
Modified:
libmicrohttpd/README
libmicrohttpd/src/examples/spdy_event_loop.c
libmicrohttpd/src/examples/spdy_fileserver.c
libmicrohttpd/src/examples/spdy_response_with_callback.c
libmicrohttpd/src/include/microspdy.h
libmicrohttpd/src/microspdy/daemon.c
libmicrohttpd/src/microspdy/daemon.h
libmicrohttpd/src/microspdy/internal.c
libmicrohttpd/src/microspdy/internal.h
libmicrohttpd/src/microspdy/structures.h
libmicrohttpd/src/testspdy/test_misc.c
libmicrohttpd/src/testspdy/test_new_connection.c
libmicrohttpd/src/testspdy/test_notls.c
libmicrohttpd/src/testspdy/test_request_response.c
libmicrohttpd/src/testspdy/test_request_response_with_callback.c
libmicrohttpd/src/testspdy/test_requests_with_assets.c
libmicrohttpd/src/testspdy/test_session_timeout.c
Log:
spdy: change SPDY_get_timeout to give not seconds but milliseconds as it used
to be
Modified: libmicrohttpd/README
===================================================================
--- libmicrohttpd/README 2013-07-17 13:43:51 UTC (rev 28121)
+++ libmicrohttpd/README 2013-07-17 14:46:49 UTC (rev 28122)
@@ -103,7 +103,6 @@
- 8 different output queues (one for each priority) have to be implemented
together with a suitable algorithm for utilizing them. Otherwise, downloading
a file will block all responses with same or smaller priority
-- Change session timeout to use not seconds but something more precise
- SPDY RST_STREAM sending on each possible error (DONE?)
- SPDY_close_session
- Find the best way for closing still opened stream (new call or existing)
Modified: libmicrohttpd/src/examples/spdy_event_loop.c
===================================================================
--- libmicrohttpd/src/examples/spdy_event_loop.c 2013-07-17 13:43:51 UTC
(rev 28121)
+++ libmicrohttpd/src/examples/spdy_event_loop.c 2013-07-17 14:46:49 UTC
(rev 28122)
@@ -337,22 +337,17 @@
FD_ZERO(&except_fd_set);
ret = SPDY_get_timeout(daemon, &timeoutlong);
- //printf("tout %i\n",timeoutlong);
- if(SPDY_NO == ret || timeoutlong > 1)
- {
- //do sth else
- //sleep(1);
-
- //try new connection
+ if(SPDY_NO == ret || timeoutlong > 1000)
+ {
timeout.tv_sec = 1;
- timeout.tv_usec = 0;
+ timeout.tv_usec = 0;
}
else
{
- timeout.tv_sec = timeoutlong;
- timeout.tv_usec = 0;//(timeoutlong % 1000) * 1000;
+ timeout.tv_sec = timeoutlong / 1000;
+ timeout.tv_usec = (timeoutlong % 1000) * 1000;
}
-
+
printf("ret=%i; timeoutlong=%i; sec=%i; usec=%i\n", ret,
timeoutlong, timeout.tv_sec, timeout.tv_usec);
//raise(SIGINT);
Modified: libmicrohttpd/src/examples/spdy_fileserver.c
===================================================================
--- libmicrohttpd/src/examples/spdy_fileserver.c 2013-07-17 13:43:51 UTC
(rev 28121)
+++ libmicrohttpd/src/examples/spdy_fileserver.c 2013-07-17 14:46:49 UTC
(rev 28122)
@@ -287,7 +287,6 @@
}
basedir = argv[3];
- timeout.tv_usec = 0;
do
{
@@ -296,17 +295,15 @@
FD_ZERO(&except_fd_set);
ret = SPDY_get_timeout(daemon, &timeoutlong);
- if(SPDY_NO == ret || timeoutlong > 1)
- {
- //do sth else
- //sleep(1);
-
- //try new connection
+ if(SPDY_NO == ret || timeoutlong > 1000)
+ {
timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
}
else
{
- timeout.tv_sec = timeoutlong;
+ timeout.tv_sec = timeoutlong / 1000;
+ timeout.tv_usec = (timeoutlong % 1000) * 1000;
}
maxfd = SPDY_get_fdset (daemon,
Modified: libmicrohttpd/src/examples/spdy_response_with_callback.c
===================================================================
--- libmicrohttpd/src/examples/spdy_response_with_callback.c 2013-07-17
13:43:51 UTC (rev 28121)
+++ libmicrohttpd/src/examples/spdy_response_with_callback.c 2013-07-17
14:46:49 UTC (rev 28122)
@@ -180,8 +180,6 @@
return 1;
}
- timeout.tv_usec = 0;
-
do
{
FD_ZERO(&read_fd_set);
@@ -189,17 +187,15 @@
FD_ZERO(&except_fd_set);
ret = SPDY_get_timeout(daemon, &timeoutlong);
- if(SPDY_NO == ret || timeoutlong > 1)
- {
- //do sth else
- //sleep(1);
-
- //try new connection
+ if(SPDY_NO == ret || timeoutlong > 1000)
+ {
timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
}
else
{
- timeout.tv_sec = timeoutlong;
+ timeout.tv_sec = timeoutlong / 1000;
+ timeout.tv_usec = (timeoutlong % 1000) * 1000;
}
maxfd = SPDY_get_fdset (daemon,
Modified: libmicrohttpd/src/include/microspdy.h
===================================================================
--- libmicrohttpd/src/include/microspdy.h 2013-07-17 13:43:51 UTC (rev
28121)
+++ libmicrohttpd/src/include/microspdy.h 2013-07-17 14:46:49 UTC (rev
28122)
@@ -905,7 +905,7 @@
* should at most block, not the timeout value set for connections.
*
* @param daemon to query for timeout
- * @param timeout will be set to the timeout value (in seconds)
+ * @param timeout will be set to the timeout value (in milliseconds)
* @return SPDY_YES on success
* SPDY_NO if no connections exist that
* would necessiate the use of a timeout right now
Modified: libmicrohttpd/src/microspdy/daemon.c
===================================================================
--- libmicrohttpd/src/microspdy/daemon.c 2013-07-17 13:43:51 UTC (rev
28121)
+++ libmicrohttpd/src/microspdy/daemon.c 2013-07-17 14:46:49 UTC (rev
28122)
@@ -134,7 +134,7 @@
switch (opt)
{
case SPDY_DAEMON_OPTION_SESSION_TIMEOUT:
- daemon->session_timeout = va_arg (valist,
unsigned int);
+ daemon->session_timeout = va_arg (valist,
unsigned int) * 1000;
break;
case SPDY_DAEMON_OPTION_SOCK_ADDR:
daemon->address = va_arg (valist, struct
sockaddr *);
@@ -390,8 +390,8 @@
SPDYF_get_timeout (struct SPDY_Daemon *daemon,
unsigned long long *timeout)
{
- time_t earliest_deadline = 0;
- time_t now;
+ unsigned long long earliest_deadline = 0;
+ unsigned long long now;
struct SPDY_Session *pos;
bool have_timeout;
@@ -417,10 +417,9 @@
if (!have_timeout)
return SPDY_NO;
- if (earliest_deadline < now)
+ if (earliest_deadline <= now)
*timeout = 0;
else
- //*timeout = 1000 * (1 + earliest_deadline - now);
*timeout = earliest_deadline - now;
return SPDY_YES;
Modified: libmicrohttpd/src/microspdy/daemon.h
===================================================================
--- libmicrohttpd/src/microspdy/daemon.h 2013-07-17 13:43:51 UTC (rev
28121)
+++ libmicrohttpd/src/microspdy/daemon.h 2013-07-17 14:46:49 UTC (rev
28122)
@@ -86,7 +86,7 @@
* should at most block, not the timeout value set for connections.
*
* @param daemon daemon to query for timeout
- * @param timeout set to the timeout (in seconds)
+ * @param timeout set to the timeout (in milliseconds)
* @return SPDY_YES on success, SPDY_NO if no connections exist that
* would necessiate the use of a timeout right now
*/
Modified: libmicrohttpd/src/microspdy/internal.c
===================================================================
--- libmicrohttpd/src/microspdy/internal.c 2013-07-17 13:43:51 UTC (rev
28121)
+++ libmicrohttpd/src/microspdy/internal.c 2013-07-17 14:46:49 UTC (rev
28122)
@@ -26,13 +26,13 @@
#include "structures.h"
-time_t
+unsigned long long
SPDYF_monotonic_time(void)
{
#ifdef HAVE_CLOCK_GETTIME
- struct timespec ts;
- if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
- return ts.tv_sec;
+ struct timespec ts;
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
+ return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
#endif
- return time(NULL);
+ return time(NULL) * 1000;
}
Modified: libmicrohttpd/src/microspdy/internal.h
===================================================================
--- libmicrohttpd/src/microspdy/internal.h 2013-07-17 13:43:51 UTC (rev
28121)
+++ libmicrohttpd/src/microspdy/internal.h 2013-07-17 14:46:49 UTC (rev
28122)
@@ -180,9 +180,9 @@
/**
* Returns monotonic time, to be used for session timeouts.
*
- * @return time in seconds
+ * @return time in milliseconds
*/
-time_t
+unsigned long long
SPDYF_monotonic_time(void);
#endif
Modified: libmicrohttpd/src/microspdy/structures.h
===================================================================
--- libmicrohttpd/src/microspdy/structures.h 2013-07-17 13:43:51 UTC (rev
28121)
+++ libmicrohttpd/src/microspdy/structures.h 2013-07-17 14:46:49 UTC (rev
28122)
@@ -739,9 +739,9 @@
/**
* Last time this connection had any activity
- * (reading or writing).
+ * (reading or writing). In milliseconds.
*/
- time_t last_activity;
+ unsigned long long last_activity;
/**
* Socket for this connection. Set to -1 if
@@ -918,10 +918,10 @@
SPDYF_IODeinit fio_deinit;
/**
- * After how many seconds of inactivity should
+ * After how many milliseconds of inactivity should
* connections time out? Zero for no timeout.
*/
- time_t session_timeout;
+ unsigned long long session_timeout;
/**
* Listen socket.
Modified: libmicrohttpd/src/testspdy/test_misc.c
===================================================================
--- libmicrohttpd/src/testspdy/test_misc.c 2013-07-17 13:43:51 UTC (rev
28121)
+++ libmicrohttpd/src/testspdy/test_misc.c 2013-07-17 14:46:49 UTC (rev
28122)
@@ -210,7 +210,6 @@
return 1;
}
- timeout.tv_usec = 0;
create_child();
do
@@ -220,13 +219,15 @@
FD_ZERO(&except_fd_set);
ret = SPDY_get_timeout(daemon, &timeoutlong);
- if(SPDY_NO == ret || timeoutlong > 1)
+ if(SPDY_NO == ret || timeoutlong > 1000)
{
timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
}
else
{
- timeout.tv_sec = timeoutlong;
+ timeout.tv_sec = timeoutlong / 1000;
+ timeout.tv_usec = (timeoutlong % 1000) * 1000;
}
maxfd = SPDY_get_fdset (daemon,
Modified: libmicrohttpd/src/testspdy/test_new_connection.c
===================================================================
--- libmicrohttpd/src/testspdy/test_new_connection.c 2013-07-17 13:43:51 UTC
(rev 28121)
+++ libmicrohttpd/src/testspdy/test_new_connection.c 2013-07-17 14:46:49 UTC
(rev 28122)
@@ -897,8 +897,6 @@
printf("no daemon\n");
return 1;
}
-
- timeout.tv_usec = 0;
do
{
@@ -907,13 +905,15 @@
FD_ZERO(&except_fd_set);
ret = SPDY_get_timeout(daemon, &timeoutlong);
- if(SPDY_NO == ret || timeoutlong > 1)
+ if(SPDY_NO == ret || timeoutlong > 1000)
{
timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
}
else
{
- timeout.tv_sec = timeoutlong;
+ timeout.tv_sec = timeoutlong / 1000;
+ timeout.tv_usec = (timeoutlong % 1000) * 1000;
}
maxfd = SPDY_get_fdset (daemon,
Modified: libmicrohttpd/src/testspdy/test_notls.c
===================================================================
--- libmicrohttpd/src/testspdy/test_notls.c 2013-07-17 13:43:51 UTC (rev
28121)
+++ libmicrohttpd/src/testspdy/test_notls.c 2013-07-17 14:46:49 UTC (rev
28122)
@@ -859,8 +859,6 @@
printf("no daemon\n");
return 1;
}
-
- timeout.tv_usec = 0;
do
{
@@ -869,13 +867,15 @@
FD_ZERO(&except_fd_set);
ret = SPDY_get_timeout(daemon, &timeoutlong);
- if(SPDY_NO == ret || timeoutlong > 1)
+ if(SPDY_NO == ret || timeoutlong > 1000)
{
timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
}
else
{
- timeout.tv_sec = timeoutlong;
+ timeout.tv_sec = timeoutlong / 1000;
+ timeout.tv_usec = (timeoutlong % 1000) * 1000;
}
maxfd = SPDY_get_fdset (daemon,
Modified: libmicrohttpd/src/testspdy/test_request_response.c
===================================================================
--- libmicrohttpd/src/testspdy/test_request_response.c 2013-07-17 13:43:51 UTC
(rev 28121)
+++ libmicrohttpd/src/testspdy/test_request_response.c 2013-07-17 14:46:49 UTC
(rev 28122)
@@ -908,8 +908,6 @@
printf("no daemon\n");
return 1;
}
-
- timeout.tv_usec = 0;
do
{
@@ -918,13 +916,15 @@
FD_ZERO(&except_fd_set);
ret = SPDY_get_timeout(daemon, &timeoutlong);
- if(SPDY_NO == ret || timeoutlong > 1)
+ if(SPDY_NO == ret || timeoutlong > 1000)
{
timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
}
else
{
- timeout.tv_sec = timeoutlong;
+ timeout.tv_sec = timeoutlong / 1000;
+ timeout.tv_usec = (timeoutlong % 1000) * 1000;
}
maxfd = SPDY_get_fdset (daemon,
Modified: libmicrohttpd/src/testspdy/test_request_response_with_callback.c
===================================================================
--- libmicrohttpd/src/testspdy/test_request_response_with_callback.c
2013-07-17 13:43:51 UTC (rev 28121)
+++ libmicrohttpd/src/testspdy/test_request_response_with_callback.c
2013-07-17 14:46:49 UTC (rev 28122)
@@ -176,8 +176,6 @@
printf("no daemon\n");
return 1;
}
-
- timeout.tv_usec = 0;
do
{
@@ -186,13 +184,15 @@
FD_ZERO(&except_fd_set);
ret = SPDY_get_timeout(daemon, &timeoutlong);
- if(SPDY_NO == ret || timeoutlong > 1)
+ if(SPDY_NO == ret || timeoutlong > 1000)
{
timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
}
else
{
- timeout.tv_sec = timeoutlong;
+ timeout.tv_sec = timeoutlong / 1000;
+ timeout.tv_usec = (timeoutlong % 1000) * 1000;
}
maxfd = SPDY_get_fdset (daemon,
Modified: libmicrohttpd/src/testspdy/test_requests_with_assets.c
===================================================================
--- libmicrohttpd/src/testspdy/test_requests_with_assets.c 2013-07-17
13:43:51 UTC (rev 28121)
+++ libmicrohttpd/src/testspdy/test_requests_with_assets.c 2013-07-17
14:46:49 UTC (rev 28122)
@@ -226,8 +226,6 @@
printf("no daemon\n");
return 1;
}
-
- timeout.tv_usec = 0;
do
{
@@ -239,15 +237,17 @@
FD_ZERO(&read_fd_set);
FD_ZERO(&write_fd_set);
FD_ZERO(&except_fd_set);
-
+
ret = SPDY_get_timeout(daemon, &timeoutlong);
- if(SPDY_NO == ret || timeoutlong > 1)
+ if(SPDY_NO == ret || timeoutlong > 1000)
{
timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
}
else
{
- timeout.tv_sec = timeoutlong;
+ timeout.tv_sec = timeoutlong / 1000;
+ timeout.tv_usec = (timeoutlong % 1000) * 1000;
}
maxfd = SPDY_get_fdset (daemon,
Modified: libmicrohttpd/src/testspdy/test_session_timeout.c
===================================================================
--- libmicrohttpd/src/testspdy/test_session_timeout.c 2013-07-17 13:43:51 UTC
(rev 28121)
+++ libmicrohttpd/src/testspdy/test_session_timeout.c 2013-07-17 14:46:49 UTC
(rev 28122)
@@ -33,6 +33,7 @@
#include <sys/stat.h>
#define TIMEOUT 2
+#define SELECT_MS_TIMEOUT 20
int port;
@@ -95,13 +96,16 @@
int childstatus;
unsigned long long timeoutlong=0;
struct timeval timeout;
+ struct timespec ts;
int ret;
fd_set read_fd_set;
fd_set write_fd_set;
fd_set except_fd_set;
int maxfd = -1;
struct SPDY_Daemon *daemon;
-
+ unsigned long long beginning = 0;
+ unsigned long long now;
+
SPDY_init();
daemon = SPDY_start_daemon(port,
@@ -120,8 +124,6 @@
printf("no daemon\n");
return 1;
}
-
- timeout.tv_usec = 0;
do
{
@@ -138,10 +140,32 @@
{
killchild("SPDY_get_timeout returned wrong
SPDY_NO");
}
- if(timeoutlong)
+ /*if(timeoutlong)
{
killchild("SPDY_get_timeout returned wrong
timeout");
- }
+ }*/
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
+ now = ts.tv_nsec / 1000000 + ts.tv_sec*1000;
+ else
+ killchild("clock_gettime returned wrong value");
+ if(now - beginning > TIMEOUT*1000 + SELECT_MS_TIMEOUT)
+ {
+ printf("Started at: %ims\n",beginning);
+ printf("Now is: %ims\n",now);
+ printf("Timeout is: %i\n",TIMEOUT);
+ printf("Select Timeout is: %ims\n",SELECT_MS_TIMEOUT);
+ printf("SPDY_get_timeout gave: %ims\n",timeoutlong);
+ killchild("Timeout passed but session was not
closed");
+ }
+ if(timeoutlong > beginning + TIMEOUT *1000)
+ {
+ printf("Started at: %ims\n",beginning);
+ printf("Now is: %ims\n",now);
+ printf("Timeout is: %i\n",TIMEOUT);
+ printf("Select Timeout is: %ims\n",SELECT_MS_TIMEOUT);
+ printf("SPDY_get_timeout gave: %ims\n",timeoutlong);
+ killchild("SPDY_get_timeout returned wrong
timeout");
+ }
}
else
{
@@ -151,14 +175,20 @@
}
}
- if(SPDY_NO == ret || timeoutlong > 1)
+ if(SPDY_NO == ret || timeoutlong >= 1000)
{
timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
}
else
{
- timeout.tv_sec = timeoutlong;
+ timeout.tv_sec = timeoutlong / 1000;
+ timeout.tv_usec = (timeoutlong % 1000) * 1000;
}
+
+ //ignore values
+ timeout.tv_sec = 0;
+ timeout.tv_usec = SELECT_MS_TIMEOUT * 1000;
maxfd = SPDY_get_fdset (daemon,
&read_fd_set,
@@ -179,12 +209,16 @@
break;
default:
SPDY_run(daemon);
- if(do_sleep)
+ if(0 == beginning)
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
+ beginning = ts.tv_nsec / 1000000 + ts.tv_sec*1000;
+ else
+ killchild("clock_gettime returned wrong
number");
+ /*if(do_sleep)
{
sleep(TIMEOUT);
do_sleep = 0;
- }
-
+ }*/
break;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28122 - in libmicrohttpd: . src/examples src/include src/microspdy src/testspdy,
gnunet <=