aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Uzunov <andrey.uzunov@gmail.com>2013-07-17 14:46:49 +0000
committerAndrey Uzunov <andrey.uzunov@gmail.com>2013-07-17 14:46:49 +0000
commitb43954303929b9e3980805d51322db9f9046e7c4 (patch)
tree8e3c7ed8ff9b0f50afaf02bd5e566e6c1e50b739
parent4231889ce35dd86cbd6a3872b3fcba053f1fd65c (diff)
downloadlibmicrohttpd-b43954303929b9e3980805d51322db9f9046e7c4.tar.gz
libmicrohttpd-b43954303929b9e3980805d51322db9f9046e7c4.zip
spdy: change SPDY_get_timeout to give not seconds but milliseconds as it used to be
-rw-r--r--README1
-rw-r--r--src/examples/spdy_event_loop.c17
-rw-r--r--src/examples/spdy_fileserver.c13
-rw-r--r--src/examples/spdy_response_with_callback.c14
-rw-r--r--src/include/microspdy.h2
-rw-r--r--src/microspdy/daemon.c9
-rw-r--r--src/microspdy/daemon.h2
-rw-r--r--src/microspdy/internal.c10
-rw-r--r--src/microspdy/internal.h4
-rw-r--r--src/microspdy/structures.h8
-rw-r--r--src/testspdy/test_misc.c7
-rw-r--r--src/testspdy/test_new_connection.c8
-rw-r--r--src/testspdy/test_notls.c8
-rw-r--r--src/testspdy/test_request_response.c8
-rw-r--r--src/testspdy/test_request_response_with_callback.c8
-rw-r--r--src/testspdy/test_requests_with_assets.c10
-rw-r--r--src/testspdy/test_session_timeout.c54
17 files changed, 102 insertions, 81 deletions
diff --git a/README b/README
index 18a6b591..749acc3b 100644
--- a/README
+++ b/README
@@ -103,7 +103,6 @@ be reasonably complete:
103- 8 different output queues (one for each priority) have to be implemented 103- 8 different output queues (one for each priority) have to be implemented
104together with a suitable algorithm for utilizing them. Otherwise, downloading 104together with a suitable algorithm for utilizing them. Otherwise, downloading
105a file will block all responses with same or smaller priority 105a file will block all responses with same or smaller priority
106- Change session timeout to use not seconds but something more precise
107- SPDY RST_STREAM sending on each possible error (DONE?) 106- SPDY RST_STREAM sending on each possible error (DONE?)
108- SPDY_close_session 107- SPDY_close_session
109- Find the best way for closing still opened stream (new call or existing) 108- Find the best way for closing still opened stream (new call or existing)
diff --git a/src/examples/spdy_event_loop.c b/src/examples/spdy_event_loop.c
index a716028f..e5e2a5b1 100644
--- a/src/examples/spdy_event_loop.c
+++ b/src/examples/spdy_event_loop.c
@@ -337,22 +337,17 @@ main (int argc, char *const *argv)
337 FD_ZERO(&except_fd_set); 337 FD_ZERO(&except_fd_set);
338 338
339 ret = SPDY_get_timeout(daemon, &timeoutlong); 339 ret = SPDY_get_timeout(daemon, &timeoutlong);
340 //printf("tout %i\n",timeoutlong); 340 if(SPDY_NO == ret || timeoutlong > 1000)
341 if(SPDY_NO == ret || timeoutlong > 1) 341 {
342 {
343 //do sth else
344 //sleep(1);
345
346 //try new connection
347 timeout.tv_sec = 1; 342 timeout.tv_sec = 1;
348 timeout.tv_usec = 0; 343 timeout.tv_usec = 0;
349 } 344 }
350 else 345 else
351 { 346 {
352 timeout.tv_sec = timeoutlong; 347 timeout.tv_sec = timeoutlong / 1000;
353 timeout.tv_usec = 0;//(timeoutlong % 1000) * 1000; 348 timeout.tv_usec = (timeoutlong % 1000) * 1000;
354 } 349 }
355 350
356 printf("ret=%i; timeoutlong=%i; sec=%i; usec=%i\n", ret, timeoutlong, timeout.tv_sec, timeout.tv_usec); 351 printf("ret=%i; timeoutlong=%i; sec=%i; usec=%i\n", ret, timeoutlong, timeout.tv_sec, timeout.tv_usec);
357 //raise(SIGINT); 352 //raise(SIGINT);
358 353
diff --git a/src/examples/spdy_fileserver.c b/src/examples/spdy_fileserver.c
index eea0930e..f2b8f7b0 100644
--- a/src/examples/spdy_fileserver.c
+++ b/src/examples/spdy_fileserver.c
@@ -287,7 +287,6 @@ main (int argc, char *const *argv)
287 } 287 }
288 288
289 basedir = argv[3]; 289 basedir = argv[3];
290 timeout.tv_usec = 0;
291 290
292 do 291 do
293 { 292 {
@@ -296,17 +295,15 @@ main (int argc, char *const *argv)
296 FD_ZERO(&except_fd_set); 295 FD_ZERO(&except_fd_set);
297 296
298 ret = SPDY_get_timeout(daemon, &timeoutlong); 297 ret = SPDY_get_timeout(daemon, &timeoutlong);
299 if(SPDY_NO == ret || timeoutlong > 1) 298 if(SPDY_NO == ret || timeoutlong > 1000)
300 { 299 {
301 //do sth else
302 //sleep(1);
303
304 //try new connection
305 timeout.tv_sec = 1; 300 timeout.tv_sec = 1;
301 timeout.tv_usec = 0;
306 } 302 }
307 else 303 else
308 { 304 {
309 timeout.tv_sec = timeoutlong; 305 timeout.tv_sec = timeoutlong / 1000;
306 timeout.tv_usec = (timeoutlong % 1000) * 1000;
310 } 307 }
311 308
312 maxfd = SPDY_get_fdset (daemon, 309 maxfd = SPDY_get_fdset (daemon,
diff --git a/src/examples/spdy_response_with_callback.c b/src/examples/spdy_response_with_callback.c
index 21085c78..1a029a64 100644
--- a/src/examples/spdy_response_with_callback.c
+++ b/src/examples/spdy_response_with_callback.c
@@ -180,8 +180,6 @@ main (int argc, char *const *argv)
180 return 1; 180 return 1;
181 } 181 }
182 182
183 timeout.tv_usec = 0;
184
185 do 183 do
186 { 184 {
187 FD_ZERO(&read_fd_set); 185 FD_ZERO(&read_fd_set);
@@ -189,17 +187,15 @@ main (int argc, char *const *argv)
189 FD_ZERO(&except_fd_set); 187 FD_ZERO(&except_fd_set);
190 188
191 ret = SPDY_get_timeout(daemon, &timeoutlong); 189 ret = SPDY_get_timeout(daemon, &timeoutlong);
192 if(SPDY_NO == ret || timeoutlong > 1) 190 if(SPDY_NO == ret || timeoutlong > 1000)
193 { 191 {
194 //do sth else
195 //sleep(1);
196
197 //try new connection
198 timeout.tv_sec = 1; 192 timeout.tv_sec = 1;
193 timeout.tv_usec = 0;
199 } 194 }
200 else 195 else
201 { 196 {
202 timeout.tv_sec = timeoutlong; 197 timeout.tv_sec = timeoutlong / 1000;
198 timeout.tv_usec = (timeoutlong % 1000) * 1000;
203 } 199 }
204 200
205 maxfd = SPDY_get_fdset (daemon, 201 maxfd = SPDY_get_fdset (daemon,
diff --git a/src/include/microspdy.h b/src/include/microspdy.h
index 53d833a3..272c411a 100644
--- a/src/include/microspdy.h
+++ b/src/include/microspdy.h
@@ -905,7 +905,7 @@ SPDY_get_fdset (struct SPDY_Daemon * daemon,
905 * should at most block, not the timeout value set for connections. 905 * should at most block, not the timeout value set for connections.
906 * 906 *
907 * @param daemon to query for timeout 907 * @param daemon to query for timeout
908 * @param timeout will be set to the timeout value (in seconds) 908 * @param timeout will be set to the timeout value (in milliseconds)
909 * @return SPDY_YES on success 909 * @return SPDY_YES on success
910 * SPDY_NO if no connections exist that 910 * SPDY_NO if no connections exist that
911 * would necessiate the use of a timeout right now 911 * would necessiate the use of a timeout right now
diff --git a/src/microspdy/daemon.c b/src/microspdy/daemon.c
index 69469a9d..0556c253 100644
--- a/src/microspdy/daemon.c
+++ b/src/microspdy/daemon.c
@@ -134,7 +134,7 @@ spdyf_parse_options_va (struct SPDY_Daemon *daemon,
134 switch (opt) 134 switch (opt)
135 { 135 {
136 case SPDY_DAEMON_OPTION_SESSION_TIMEOUT: 136 case SPDY_DAEMON_OPTION_SESSION_TIMEOUT:
137 daemon->session_timeout = va_arg (valist, unsigned int); 137 daemon->session_timeout = va_arg (valist, unsigned int) * 1000;
138 break; 138 break;
139 case SPDY_DAEMON_OPTION_SOCK_ADDR: 139 case SPDY_DAEMON_OPTION_SOCK_ADDR:
140 daemon->address = va_arg (valist, struct sockaddr *); 140 daemon->address = va_arg (valist, struct sockaddr *);
@@ -390,8 +390,8 @@ int
390SPDYF_get_timeout (struct SPDY_Daemon *daemon, 390SPDYF_get_timeout (struct SPDY_Daemon *daemon,
391 unsigned long long *timeout) 391 unsigned long long *timeout)
392{ 392{
393 time_t earliest_deadline = 0; 393 unsigned long long earliest_deadline = 0;
394 time_t now; 394 unsigned long long now;
395 struct SPDY_Session *pos; 395 struct SPDY_Session *pos;
396 bool have_timeout; 396 bool have_timeout;
397 397
@@ -417,10 +417,9 @@ SPDYF_get_timeout (struct SPDY_Daemon *daemon,
417 417
418 if (!have_timeout) 418 if (!have_timeout)
419 return SPDY_NO; 419 return SPDY_NO;
420 if (earliest_deadline < now) 420 if (earliest_deadline <= now)
421 *timeout = 0; 421 *timeout = 0;
422 else 422 else
423 //*timeout = 1000 * (1 + earliest_deadline - now);
424 *timeout = earliest_deadline - now; 423 *timeout = earliest_deadline - now;
425 424
426 return SPDY_YES; 425 return SPDY_YES;
diff --git a/src/microspdy/daemon.h b/src/microspdy/daemon.h
index 791c32e1..03e322b5 100644
--- a/src/microspdy/daemon.h
+++ b/src/microspdy/daemon.h
@@ -86,7 +86,7 @@ SPDYF_run (struct SPDY_Daemon *daemon);
86 * should at most block, not the timeout value set for connections. 86 * should at most block, not the timeout value set for connections.
87 * 87 *
88 * @param daemon daemon to query for timeout 88 * @param daemon daemon to query for timeout
89 * @param timeout set to the timeout (in seconds) 89 * @param timeout set to the timeout (in milliseconds)
90 * @return SPDY_YES on success, SPDY_NO if no connections exist that 90 * @return SPDY_YES on success, SPDY_NO if no connections exist that
91 * would necessiate the use of a timeout right now 91 * would necessiate the use of a timeout right now
92 */ 92 */
diff --git a/src/microspdy/internal.c b/src/microspdy/internal.c
index 458bcb2f..6bcfdbf9 100644
--- a/src/microspdy/internal.c
+++ b/src/microspdy/internal.c
@@ -26,13 +26,13 @@
26#include "structures.h" 26#include "structures.h"
27 27
28 28
29time_t 29unsigned long long
30SPDYF_monotonic_time(void) 30SPDYF_monotonic_time(void)
31{ 31{
32#ifdef HAVE_CLOCK_GETTIME 32#ifdef HAVE_CLOCK_GETTIME
33 struct timespec ts; 33 struct timespec ts;
34 if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 34 if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
35 return ts.tv_sec; 35 return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
36#endif 36#endif
37 return time(NULL); 37 return time(NULL) * 1000;
38} 38}
diff --git a/src/microspdy/internal.h b/src/microspdy/internal.h
index 7b07728c..74281577 100644
--- a/src/microspdy/internal.h
+++ b/src/microspdy/internal.h
@@ -180,9 +180,9 @@ extern void *spdyf_panic_cls;
180/** 180/**
181 * Returns monotonic time, to be used for session timeouts. 181 * Returns monotonic time, to be used for session timeouts.
182 * 182 *
183 * @return time in seconds 183 * @return time in milliseconds
184 */ 184 */
185time_t 185unsigned long long
186SPDYF_monotonic_time(void); 186SPDYF_monotonic_time(void);
187 187
188#endif 188#endif
diff --git a/src/microspdy/structures.h b/src/microspdy/structures.h
index 45e81c3b..ff4c47ff 100644
--- a/src/microspdy/structures.h
+++ b/src/microspdy/structures.h
@@ -739,9 +739,9 @@ struct SPDY_Session
739 739
740 /** 740 /**
741 * Last time this connection had any activity 741 * Last time this connection had any activity
742 * (reading or writing). 742 * (reading or writing). In milliseconds.
743 */ 743 */
744 time_t last_activity; 744 unsigned long long last_activity;
745 745
746 /** 746 /**
747 * Socket for this connection. Set to -1 if 747 * Socket for this connection. Set to -1 if
@@ -918,10 +918,10 @@ struct SPDY_Daemon
918 SPDYF_IODeinit fio_deinit; 918 SPDYF_IODeinit fio_deinit;
919 919
920 /** 920 /**
921 * After how many seconds of inactivity should 921 * After how many milliseconds of inactivity should
922 * connections time out? Zero for no timeout. 922 * connections time out? Zero for no timeout.
923 */ 923 */
924 time_t session_timeout; 924 unsigned long long session_timeout;
925 925
926 /** 926 /**
927 * Listen socket. 927 * Listen socket.
diff --git a/src/testspdy/test_misc.c b/src/testspdy/test_misc.c
index 84728d0d..a39afa66 100644
--- a/src/testspdy/test_misc.c
+++ b/src/testspdy/test_misc.c
@@ -210,7 +210,6 @@ parentproc()
210 return 1; 210 return 1;
211 } 211 }
212 212
213 timeout.tv_usec = 0;
214 create_child(); 213 create_child();
215 214
216 do 215 do
@@ -220,13 +219,15 @@ parentproc()
220 FD_ZERO(&except_fd_set); 219 FD_ZERO(&except_fd_set);
221 220
222 ret = SPDY_get_timeout(daemon, &timeoutlong); 221 ret = SPDY_get_timeout(daemon, &timeoutlong);
223 if(SPDY_NO == ret || timeoutlong > 1) 222 if(SPDY_NO == ret || timeoutlong > 1000)
224 { 223 {
225 timeout.tv_sec = 1; 224 timeout.tv_sec = 1;
225 timeout.tv_usec = 0;
226 } 226 }
227 else 227 else
228 { 228 {
229 timeout.tv_sec = timeoutlong; 229 timeout.tv_sec = timeoutlong / 1000;
230 timeout.tv_usec = (timeoutlong % 1000) * 1000;
230 } 231 }
231 232
232 maxfd = SPDY_get_fdset (daemon, 233 maxfd = SPDY_get_fdset (daemon,
diff --git a/src/testspdy/test_new_connection.c b/src/testspdy/test_new_connection.c
index 8d13004f..1a9e47a4 100644
--- a/src/testspdy/test_new_connection.c
+++ b/src/testspdy/test_new_connection.c
@@ -897,8 +897,6 @@ parentproc(int child)
897 printf("no daemon\n"); 897 printf("no daemon\n");
898 return 1; 898 return 1;
899 } 899 }
900
901 timeout.tv_usec = 0;
902 900
903 do 901 do
904 { 902 {
@@ -907,13 +905,15 @@ parentproc(int child)
907 FD_ZERO(&except_fd_set); 905 FD_ZERO(&except_fd_set);
908 906
909 ret = SPDY_get_timeout(daemon, &timeoutlong); 907 ret = SPDY_get_timeout(daemon, &timeoutlong);
910 if(SPDY_NO == ret || timeoutlong > 1) 908 if(SPDY_NO == ret || timeoutlong > 1000)
911 { 909 {
912 timeout.tv_sec = 1; 910 timeout.tv_sec = 1;
911 timeout.tv_usec = 0;
913 } 912 }
914 else 913 else
915 { 914 {
916 timeout.tv_sec = timeoutlong; 915 timeout.tv_sec = timeoutlong / 1000;
916 timeout.tv_usec = (timeoutlong % 1000) * 1000;
917 } 917 }
918 918
919 maxfd = SPDY_get_fdset (daemon, 919 maxfd = SPDY_get_fdset (daemon,
diff --git a/src/testspdy/test_notls.c b/src/testspdy/test_notls.c
index 93462cd9..ec42920e 100644
--- a/src/testspdy/test_notls.c
+++ b/src/testspdy/test_notls.c
@@ -859,8 +859,6 @@ parentproc( int port)
859 printf("no daemon\n"); 859 printf("no daemon\n");
860 return 1; 860 return 1;
861 } 861 }
862
863 timeout.tv_usec = 0;
864 862
865 do 863 do
866 { 864 {
@@ -869,13 +867,15 @@ parentproc( int port)
869 FD_ZERO(&except_fd_set); 867 FD_ZERO(&except_fd_set);
870 868
871 ret = SPDY_get_timeout(daemon, &timeoutlong); 869 ret = SPDY_get_timeout(daemon, &timeoutlong);
872 if(SPDY_NO == ret || timeoutlong > 1) 870 if(SPDY_NO == ret || timeoutlong > 1000)
873 { 871 {
874 timeout.tv_sec = 1; 872 timeout.tv_sec = 1;
873 timeout.tv_usec = 0;
875 } 874 }
876 else 875 else
877 { 876 {
878 timeout.tv_sec = timeoutlong; 877 timeout.tv_sec = timeoutlong / 1000;
878 timeout.tv_usec = (timeoutlong % 1000) * 1000;
879 } 879 }
880 880
881 maxfd = SPDY_get_fdset (daemon, 881 maxfd = SPDY_get_fdset (daemon,
diff --git a/src/testspdy/test_request_response.c b/src/testspdy/test_request_response.c
index 4591849e..6c311be3 100644
--- a/src/testspdy/test_request_response.c
+++ b/src/testspdy/test_request_response.c
@@ -908,8 +908,6 @@ parentproc( int port)
908 printf("no daemon\n"); 908 printf("no daemon\n");
909 return 1; 909 return 1;
910 } 910 }
911
912 timeout.tv_usec = 0;
913 911
914 do 912 do
915 { 913 {
@@ -918,13 +916,15 @@ parentproc( int port)
918 FD_ZERO(&except_fd_set); 916 FD_ZERO(&except_fd_set);
919 917
920 ret = SPDY_get_timeout(daemon, &timeoutlong); 918 ret = SPDY_get_timeout(daemon, &timeoutlong);
921 if(SPDY_NO == ret || timeoutlong > 1) 919 if(SPDY_NO == ret || timeoutlong > 1000)
922 { 920 {
923 timeout.tv_sec = 1; 921 timeout.tv_sec = 1;
922 timeout.tv_usec = 0;
924 } 923 }
925 else 924 else
926 { 925 {
927 timeout.tv_sec = timeoutlong; 926 timeout.tv_sec = timeoutlong / 1000;
927 timeout.tv_usec = (timeoutlong % 1000) * 1000;
928 } 928 }
929 929
930 maxfd = SPDY_get_fdset (daemon, 930 maxfd = SPDY_get_fdset (daemon,
diff --git a/src/testspdy/test_request_response_with_callback.c b/src/testspdy/test_request_response_with_callback.c
index c22917c5..6eed8eba 100644
--- a/src/testspdy/test_request_response_with_callback.c
+++ b/src/testspdy/test_request_response_with_callback.c
@@ -176,8 +176,6 @@ parentproc()
176 printf("no daemon\n"); 176 printf("no daemon\n");
177 return 1; 177 return 1;
178 } 178 }
179
180 timeout.tv_usec = 0;
181 179
182 do 180 do
183 { 181 {
@@ -186,13 +184,15 @@ parentproc()
186 FD_ZERO(&except_fd_set); 184 FD_ZERO(&except_fd_set);
187 185
188 ret = SPDY_get_timeout(daemon, &timeoutlong); 186 ret = SPDY_get_timeout(daemon, &timeoutlong);
189 if(SPDY_NO == ret || timeoutlong > 1) 187 if(SPDY_NO == ret || timeoutlong > 1000)
190 { 188 {
191 timeout.tv_sec = 1; 189 timeout.tv_sec = 1;
190 timeout.tv_usec = 0;
192 } 191 }
193 else 192 else
194 { 193 {
195 timeout.tv_sec = timeoutlong; 194 timeout.tv_sec = timeoutlong / 1000;
195 timeout.tv_usec = (timeoutlong % 1000) * 1000;
196 } 196 }
197 197
198 maxfd = SPDY_get_fdset (daemon, 198 maxfd = SPDY_get_fdset (daemon,
diff --git a/src/testspdy/test_requests_with_assets.c b/src/testspdy/test_requests_with_assets.c
index 26d309e8..6ec927e8 100644
--- a/src/testspdy/test_requests_with_assets.c
+++ b/src/testspdy/test_requests_with_assets.c
@@ -226,8 +226,6 @@ parentproc()
226 printf("no daemon\n"); 226 printf("no daemon\n");
227 return 1; 227 return 1;
228 } 228 }
229
230 timeout.tv_usec = 0;
231 229
232 do 230 do
233 { 231 {
@@ -239,15 +237,17 @@ parentproc()
239 FD_ZERO(&read_fd_set); 237 FD_ZERO(&read_fd_set);
240 FD_ZERO(&write_fd_set); 238 FD_ZERO(&write_fd_set);
241 FD_ZERO(&except_fd_set); 239 FD_ZERO(&except_fd_set);
242 240
243 ret = SPDY_get_timeout(daemon, &timeoutlong); 241 ret = SPDY_get_timeout(daemon, &timeoutlong);
244 if(SPDY_NO == ret || timeoutlong > 1) 242 if(SPDY_NO == ret || timeoutlong > 1000)
245 { 243 {
246 timeout.tv_sec = 1; 244 timeout.tv_sec = 1;
245 timeout.tv_usec = 0;
247 } 246 }
248 else 247 else
249 { 248 {
250 timeout.tv_sec = timeoutlong; 249 timeout.tv_sec = timeoutlong / 1000;
250 timeout.tv_usec = (timeoutlong % 1000) * 1000;
251 } 251 }
252 252
253 maxfd = SPDY_get_fdset (daemon, 253 maxfd = SPDY_get_fdset (daemon,
diff --git a/src/testspdy/test_session_timeout.c b/src/testspdy/test_session_timeout.c
index c5d29dc9..66872d72 100644
--- a/src/testspdy/test_session_timeout.c
+++ b/src/testspdy/test_session_timeout.c
@@ -33,6 +33,7 @@
33#include <sys/stat.h> 33#include <sys/stat.h>
34 34
35#define TIMEOUT 2 35#define TIMEOUT 2
36#define SELECT_MS_TIMEOUT 20
36 37
37int port; 38int port;
38 39
@@ -95,13 +96,16 @@ parentproc()
95 int childstatus; 96 int childstatus;
96 unsigned long long timeoutlong=0; 97 unsigned long long timeoutlong=0;
97 struct timeval timeout; 98 struct timeval timeout;
99 struct timespec ts;
98 int ret; 100 int ret;
99 fd_set read_fd_set; 101 fd_set read_fd_set;
100 fd_set write_fd_set; 102 fd_set write_fd_set;
101 fd_set except_fd_set; 103 fd_set except_fd_set;
102 int maxfd = -1; 104 int maxfd = -1;
103 struct SPDY_Daemon *daemon; 105 struct SPDY_Daemon *daemon;
104 106 unsigned long long beginning = 0;
107 unsigned long long now;
108
105 SPDY_init(); 109 SPDY_init();
106 110
107 daemon = SPDY_start_daemon(port, 111 daemon = SPDY_start_daemon(port,
@@ -120,8 +124,6 @@ parentproc()
120 printf("no daemon\n"); 124 printf("no daemon\n");
121 return 1; 125 return 1;
122 } 126 }
123
124 timeout.tv_usec = 0;
125 127
126 do 128 do
127 { 129 {
@@ -138,10 +140,32 @@ parentproc()
138 { 140 {
139 killchild("SPDY_get_timeout returned wrong SPDY_NO"); 141 killchild("SPDY_get_timeout returned wrong SPDY_NO");
140 } 142 }
141 if(timeoutlong) 143 /*if(timeoutlong)
142 { 144 {
143 killchild("SPDY_get_timeout returned wrong timeout"); 145 killchild("SPDY_get_timeout returned wrong timeout");
144 } 146 }*/
147 if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
148 now = ts.tv_nsec / 1000000 + ts.tv_sec*1000;
149 else
150 killchild("clock_gettime returned wrong value");
151 if(now - beginning > TIMEOUT*1000 + SELECT_MS_TIMEOUT)
152 {
153 printf("Started at: %ims\n",beginning);
154 printf("Now is: %ims\n",now);
155 printf("Timeout is: %i\n",TIMEOUT);
156 printf("Select Timeout is: %ims\n",SELECT_MS_TIMEOUT);
157 printf("SPDY_get_timeout gave: %ims\n",timeoutlong);
158 killchild("Timeout passed but session was not closed");
159 }
160 if(timeoutlong > beginning + TIMEOUT *1000)
161 {
162 printf("Started at: %ims\n",beginning);
163 printf("Now is: %ims\n",now);
164 printf("Timeout is: %i\n",TIMEOUT);
165 printf("Select Timeout is: %ims\n",SELECT_MS_TIMEOUT);
166 printf("SPDY_get_timeout gave: %ims\n",timeoutlong);
167 killchild("SPDY_get_timeout returned wrong timeout");
168 }
145 } 169 }
146 else 170 else
147 { 171 {
@@ -151,14 +175,20 @@ parentproc()
151 } 175 }
152 } 176 }
153 177
154 if(SPDY_NO == ret || timeoutlong > 1) 178 if(SPDY_NO == ret || timeoutlong >= 1000)
155 { 179 {
156 timeout.tv_sec = 1; 180 timeout.tv_sec = 1;
181 timeout.tv_usec = 0;
157 } 182 }
158 else 183 else
159 { 184 {
160 timeout.tv_sec = timeoutlong; 185 timeout.tv_sec = timeoutlong / 1000;
186 timeout.tv_usec = (timeoutlong % 1000) * 1000;
161 } 187 }
188
189 //ignore values
190 timeout.tv_sec = 0;
191 timeout.tv_usec = SELECT_MS_TIMEOUT * 1000;
162 192
163 maxfd = SPDY_get_fdset (daemon, 193 maxfd = SPDY_get_fdset (daemon,
164 &read_fd_set, 194 &read_fd_set,
@@ -179,12 +209,16 @@ parentproc()
179 break; 209 break;
180 default: 210 default:
181 SPDY_run(daemon); 211 SPDY_run(daemon);
182 if(do_sleep) 212 if(0 == beginning)
213 if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
214 beginning = ts.tv_nsec / 1000000 + ts.tv_sec*1000;
215 else
216 killchild("clock_gettime returned wrong number");
217 /*if(do_sleep)
183 { 218 {
184 sleep(TIMEOUT); 219 sleep(TIMEOUT);
185 do_sleep = 0; 220 do_sleep = 0;
186 } 221 }*/
187
188 break; 222 break;
189 } 223 }
190 } 224 }