diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-09-23 18:34:19 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-09-23 18:34:19 +0000 |
commit | 9c2700afc5c81f9a9199f6989633d94167f6e68a (patch) | |
tree | f57b19d3ebecf3de738cf5307a739caaa341f97a | |
parent | 9d0f953af2400c13f8a15f68e625d3d60351dd95 (diff) | |
download | libmicrohttpd-9c2700afc5c81f9a9199f6989633d94167f6e68a.tar.gz libmicrohttpd-9c2700afc5c81f9a9199f6989633d94167f6e68a.zip |
check CLOCK_MONOTONIC is defined
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/microhttpd/internal.c | 15 | ||||
-rw-r--r-- | src/microspdy/EXPORT.sym | 1 | ||||
-rw-r--r-- | src/microspdy/internal.c | 8 | ||||
-rw-r--r-- | src/spdy2http/proxy.c | 40 | ||||
-rw-r--r-- | src/testspdy/test_session_timeout.c | 12 |
6 files changed, 54 insertions, 26 deletions
@@ -1,3 +1,7 @@ | |||
1 | Mon Sep 23 20:24:48 CEST 2013 | ||
2 | Fixing build issues on OS X with CLOCK_MONOTONIC not being | ||
3 | implemented on OS X. -CG | ||
4 | |||
1 | Mon Sep 23 14:15:00 CEST 2013 | 5 | Mon Sep 23 14:15:00 CEST 2013 |
2 | Make libmicrohttpd play nicely with upcoming libgcrypt 1.6.0. -CG | 6 | Make libmicrohttpd play nicely with upcoming libgcrypt 1.6.0. -CG |
3 | 7 | ||
diff --git a/src/microhttpd/internal.c b/src/microhttpd/internal.c index 52d0979f..ef286b20 100644 --- a/src/microhttpd/internal.c +++ b/src/microhttpd/internal.c | |||
@@ -158,14 +158,19 @@ MHD_http_unescape (void *cls, | |||
158 | return wpos - val; /* = strlen(val) */ | 158 | return wpos - val; /* = strlen(val) */ |
159 | } | 159 | } |
160 | 160 | ||
161 | time_t MHD_monotonic_time(void) | 161 | |
162 | time_t | ||
163 | MHD_monotonic_time (void) | ||
162 | { | 164 | { |
163 | #ifdef HAVE_CLOCK_GETTIME | 165 | #ifdef HAVE_CLOCK_GETTIME |
164 | struct timespec ts; | 166 | #ifdef CLOCK_MONOTONIC |
165 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) | 167 | struct timespec ts; |
166 | return ts.tv_sec; | 168 | |
169 | if (0 == clock_gettime (CLOCK_MONOTONIC, &ts)) | ||
170 | return ts.tv_sec; | ||
171 | #endif | ||
167 | #endif | 172 | #endif |
168 | return time(NULL); | 173 | return time (NULL); |
169 | } | 174 | } |
170 | 175 | ||
171 | /* end of internal.c */ | 176 | /* end of internal.c */ |
diff --git a/src/microspdy/EXPORT.sym b/src/microspdy/EXPORT.sym index eb6604bc..e0bb71ad 100644 --- a/src/microspdy/EXPORT.sym +++ b/src/microspdy/EXPORT.sym | |||
@@ -1,2 +1,3 @@ | |||
1 | SPDY_start_daemon | 1 | SPDY_start_daemon |
2 | SPDY_stop_daemon | 2 | SPDY_stop_daemon |
3 | SPDYF_monotonic_time | ||
diff --git a/src/microspdy/internal.c b/src/microspdy/internal.c index 0ba83768..647be05b 100644 --- a/src/microspdy/internal.c +++ b/src/microspdy/internal.c | |||
@@ -27,12 +27,14 @@ | |||
27 | 27 | ||
28 | 28 | ||
29 | unsigned long long | 29 | unsigned long long |
30 | SPDYF_monotonic_time(void) | 30 | SPDYF_monotonic_time (void) |
31 | { | 31 | { |
32 | #ifdef HAVE_CLOCK_GETTIME | 32 | #ifdef HAVE_CLOCK_GETTIME |
33 | #ifdef CLOCK_MONOTONIC | ||
33 | struct timespec ts; | 34 | struct timespec ts; |
34 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) | 35 | if (0 == clock_gettime (CLOCK_MONOTONIC, &ts)) |
35 | return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; | 36 | return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; |
36 | #endif | 37 | #endif |
37 | return time(NULL) * 1000; | 38 | #endif |
39 | return time (NULL) * 1000; | ||
38 | } | 40 | } |
diff --git a/src/spdy2http/proxy.c b/src/spdy2http/proxy.c index c7e37f78..dc6ba351 100644 --- a/src/spdy2http/proxy.c +++ b/src/spdy2http/proxy.c | |||
@@ -244,12 +244,29 @@ parse_uri(regex_t * preg, const char * full_uri, struct URI ** uri) | |||
244 | 244 | ||
245 | (*uri)->full_uri = strdup(full_uri); | 245 | (*uri)->full_uri = strdup(full_uri); |
246 | 246 | ||
247 | asprintf(&((*uri)->scheme), "%.*s",pmatch[2].rm_eo - pmatch[2].rm_so, &full_uri[pmatch[2].rm_so]); | 247 | asprintf(&((*uri)->scheme), |
248 | asprintf(&((*uri)->host_and_port), "%.*s",pmatch[4].rm_eo - pmatch[4].rm_so, &full_uri[pmatch[4].rm_so]); | 248 | "%.*s", |
249 | asprintf(&((*uri)->path), "%.*s",pmatch[5].rm_eo - pmatch[5].rm_so, &full_uri[pmatch[5].rm_so]); | 249 | (int) (pmatch[2].rm_eo - pmatch[2].rm_so), |
250 | asprintf(&((*uri)->path_and_more), "%.*s",pmatch[9].rm_eo - pmatch[5].rm_so, &full_uri[pmatch[5].rm_so]); | 250 | &full_uri[pmatch[2].rm_so]); |
251 | asprintf(&((*uri)->query), "%.*s",pmatch[7].rm_eo - pmatch[7].rm_so, &full_uri[pmatch[7].rm_so]); | 251 | asprintf(&((*uri)->host_and_port), "%.*s", |
252 | asprintf(&((*uri)->fragment), "%.*s",pmatch[9].rm_eo - pmatch[9].rm_so, &full_uri[pmatch[9].rm_so]); | 252 | (int) (pmatch[4].rm_eo - pmatch[4].rm_so), |
253 | &full_uri[pmatch[4].rm_so]); | ||
254 | asprintf(&((*uri)->path), | ||
255 | "%.*s", | ||
256 | (int) (pmatch[5].rm_eo - pmatch[5].rm_so), | ||
257 | &full_uri[pmatch[5].rm_so]); | ||
258 | asprintf(&((*uri)->path_and_more), | ||
259 | "%.*s", | ||
260 | (int) (pmatch[9].rm_eo - pmatch[5].rm_so), | ||
261 | &full_uri[pmatch[5].rm_so]); | ||
262 | asprintf(&((*uri)->query), | ||
263 | "%.*s", | ||
264 | (int) (pmatch[7].rm_eo - pmatch[7].rm_so), | ||
265 | &full_uri[pmatch[7].rm_so]); | ||
266 | asprintf(&((*uri)->fragment), | ||
267 | "%.*s", | ||
268 | (int) (pmatch[9].rm_eo - pmatch[9].rm_so), | ||
269 | &full_uri[pmatch[9].rm_so]); | ||
253 | 270 | ||
254 | colon = strrchr((*uri)->host_and_port, ':'); | 271 | colon = strrchr((*uri)->host_and_port, ':'); |
255 | if(NULL == colon) | 272 | if(NULL == colon) |
@@ -1173,12 +1190,17 @@ run () | |||
1173 | if(glob_opt.verbose) | 1190 | if(glob_opt.verbose) |
1174 | { | 1191 | { |
1175 | 1192 | ||
1176 | struct timespec ts; | 1193 | #ifdef HAVE_CLOCK_GETTIME |
1177 | #ifdef CLOCK_MONOTONIC | 1194 | #ifdef CLOCK_MONOTONIC |
1178 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) | 1195 | struct timespec ts; |
1179 | PRINT_VERBOSE2("time now %lld %lld", (unsigned long long)ts.tv_sec, (unsigned long long)ts.tv_nsec); | 1196 | |
1197 | if (0 == clock_gettime(CLOCK_MONOTONIC, &ts)) | ||
1198 | PRINT_VERBOSE2 ("time now %lld %lld", | ||
1199 | (unsigned long long) ts.tv_sec, | ||
1200 | (unsigned long long) ts.tv_nsec); | ||
1180 | } | 1201 | } |
1181 | #endif | 1202 | #endif |
1203 | #endif | ||
1182 | } | 1204 | } |
1183 | while(loop); | 1205 | while(loop); |
1184 | 1206 | ||
diff --git a/src/testspdy/test_session_timeout.c b/src/testspdy/test_session_timeout.c index a89933b4..548a2128 100644 --- a/src/testspdy/test_session_timeout.c +++ b/src/testspdy/test_session_timeout.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "common.h" | 31 | #include "common.h" |
32 | #include <sys/time.h> | 32 | #include <sys/time.h> |
33 | #include <sys/stat.h> | 33 | #include <sys/stat.h> |
34 | #include "../microspdy/internal.h" | ||
34 | 35 | ||
35 | #define TIMEOUT 2 | 36 | #define TIMEOUT 2 |
36 | #define SELECT_MS_TIMEOUT 20 | 37 | #define SELECT_MS_TIMEOUT 20 |
@@ -102,7 +103,6 @@ parentproc() | |||
102 | int childstatus; | 103 | int childstatus; |
103 | unsigned long long timeoutlong=0; | 104 | unsigned long long timeoutlong=0; |
104 | struct timeval timeout; | 105 | struct timeval timeout; |
105 | struct timespec ts; | ||
106 | int ret; | 106 | int ret; |
107 | fd_set read_fd_set; | 107 | fd_set read_fd_set; |
108 | fd_set write_fd_set; | 108 | fd_set write_fd_set; |
@@ -150,10 +150,7 @@ parentproc() | |||
150 | { | 150 | { |
151 | killchild("SPDY_get_timeout returned wrong timeout"); | 151 | killchild("SPDY_get_timeout returned wrong timeout"); |
152 | }*/ | 152 | }*/ |
153 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) | 153 | now = SPDYF_monotonic_time (); |
154 | now = ts.tv_nsec / 1000000 + ts.tv_sec*1000; | ||
155 | else | ||
156 | killchild("clock_gettime returned wrong value"); | ||
157 | if(now - beginning > TIMEOUT*1000 + SELECT_MS_TIMEOUT) | 154 | if(now - beginning > TIMEOUT*1000 + SELECT_MS_TIMEOUT) |
158 | { | 155 | { |
159 | printf("Started at: %llums\n",beginning); | 156 | printf("Started at: %llums\n",beginning); |
@@ -217,10 +214,7 @@ parentproc() | |||
217 | SPDY_run(daemon); | 214 | SPDY_run(daemon); |
218 | if(0 == beginning) | 215 | if(0 == beginning) |
219 | { | 216 | { |
220 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) | 217 | beginning = SPDYF_monotonic_time (); |
221 | beginning = ts.tv_nsec / 1000000 + ts.tv_sec*1000; | ||
222 | else | ||
223 | killchild("clock_gettime returned wrong number"); | ||
224 | } | 218 | } |
225 | /*if(do_sleep) | 219 | /*if(do_sleep) |
226 | { | 220 | { |