[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34714 - libmicrohttpd/src/testspdy
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34714 - libmicrohttpd/src/testspdy |
Date: |
Sat, 20 Dec 2014 00:42:32 +0100 |
Author: grothoff
Date: 2014-12-20 00:42:32 +0100 (Sat, 20 Dec 2014)
New Revision: 34714
Modified:
libmicrohttpd/src/testspdy/test_session_timeout.c
Log:
-fix linker issue
Modified: libmicrohttpd/src/testspdy/test_session_timeout.c
===================================================================
--- libmicrohttpd/src/testspdy/test_session_timeout.c 2014-12-19 23:38:18 UTC
(rev 34713)
+++ libmicrohttpd/src/testspdy/test_session_timeout.c 2014-12-19 23:42:32 UTC
(rev 34714)
@@ -47,7 +47,23 @@
int closed_session;
int do_sleep;
-void
+
+
+static unsigned long long
+monotonic_time (void)
+{
+#ifdef HAVE_CLOCK_GETTIME
+#ifdef CLOCK_MONOTONIC
+ struct timespec ts;
+ if (0 == clock_gettime (CLOCK_MONOTONIC, &ts))
+ return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
+#endif
+#endif
+ return time (NULL) * 1000;
+}
+
+
+static void
killchild(char *msg)
{
printf("%s\n",msg);
@@ -55,7 +71,8 @@
exit(1);
}
-void
+
+static void
killparent(char *msg)
{
printf("%s\n",msg);
@@ -63,28 +80,30 @@
_exit(1);
}
-void
+
+static void
new_session_cb (void *cls,
- struct SPDY_Session * session)
+ struct SPDY_Session * session)
{
(void)cls;
(void)session;
-
+
if(!new_session)do_sleep = 1;
new_session = 1;
printf("new session\n");
}
-void
+
+static void
closed_session_cb (void *cls,
- struct SPDY_Session * session,
- int by_client)
+ struct SPDY_Session * session,
+ int by_client)
{
(void)cls;
(void)session;
-
+
printf("closed_session_cb called\n");
-
+
if(SPDY_YES == by_client)
{
killchild("closed by the client");
@@ -93,13 +112,14 @@
{
killchild("closed_session_cb called twice");
}
-
+
closed_session = 1;
}
-int
+
+static int
parentproc()
-{
+{
int childstatus;
unsigned long long timeoutlong=0;
struct timeval timeout;
@@ -111,9 +131,9 @@
struct SPDY_Daemon *daemon;
unsigned long long beginning = 0;
unsigned long long now;
-
+
SPDY_init();
-
+
daemon = SPDY_start_daemon(port,
DATA_DIR
"cert-and-key.pem",
DATA_DIR
"cert-and-key.pem",
@@ -125,7 +145,7 @@
SPDY_DAEMON_OPTION_SESSION_TIMEOUT,
TIMEOUT,
SPDY_DAEMON_OPTION_END);
-
+
if(NULL==daemon){
printf("no daemon\n");
return 1;
@@ -139,7 +159,7 @@
FD_ZERO(&except_fd_set);
ret = SPDY_get_timeout(daemon, &timeoutlong);
-
+
if(new_session && !closed_session)
{
if(SPDY_NO == ret)
@@ -150,7 +170,7 @@
{
killchild("SPDY_get_timeout returned wrong
timeout");
}*/
- now = SPDYF_monotonic_time ();
+ now = monotonic_time ();
if(now - beginning > TIMEOUT*1000 + SELECT_MS_TIMEOUT)
{
printf("Started at: %llums\n",beginning);
@@ -177,7 +197,7 @@
killchild("SPDY_get_timeout returned wrong
SPDY_YES");
}
}
-
+
if(SPDY_NO == ret || timeoutlong >= 1000)
{
timeout.tv_sec = 1;
@@ -188,18 +208,18 @@
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,
- &write_fd_set,
+ &write_fd_set,
&except_fd_set);
-
+
ret = select(maxfd+1, &read_fd_set, &write_fd_set,
&except_fd_set, &timeout);
-
+
switch(ret) {
case -1:
printf("select error: %i\n", errno);
@@ -214,7 +234,7 @@
SPDY_run(daemon);
if(0 == beginning)
{
- beginning = SPDYF_monotonic_time ();
+ beginning = monotonic_time ();
}
/*if(do_sleep)
{
@@ -225,27 +245,28 @@
}
}
while(waitpid(child,&childstatus,WNOHANG) != child);
-
+
if(!new_session || !closed_session)
{
killchild("child is dead, callback wasn't called");
}
ret = SPDY_get_timeout(daemon, &timeoutlong);
-
+
if(SPDY_YES == ret)
{
killchild("SPDY_get_timeout returned wrong SPDY_YES after child
died");
}
-
+
SPDY_stop_daemon(daemon);
-
+
SPDY_deinit();
-
+
return 0;
}
-int
+
+static int
childproc()
{
pid_t devnull;
@@ -292,7 +313,7 @@
child = fork();
if (-1 == child)
- {
+ {
fprintf(stderr, "can't fork, error %d\n", errno);
exit(EXIT_FAILURE);
}
@@ -303,7 +324,7 @@
_exit(ret);
}
else
- {
+ {
int ret = parentproc();
exit(ret);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34714 - libmicrohttpd/src/testspdy,
gnunet <=