diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-20 00:25:22 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-20 00:25:22 +0000 |
commit | a4030d4473d4237aa9dad30d7812cd1c9e764dba (patch) | |
tree | 58dd38d8ae6691d1aad0b1d15bdde41a7ca0613e | |
parent | b457435a8845782708575236f2a7e67537330e6f (diff) | |
download | libmicrohttpd-a4030d4473d4237aa9dad30d7812cd1c9e764dba.tar.gz libmicrohttpd-a4030d4473d4237aa9dad30d7812cd1c9e764dba.zip |
-check RVals
-rw-r--r-- | src/testspdy/test_misc.c | 46 | ||||
-rw-r--r-- | src/testspdy/test_proxies.c | 24 | ||||
-rw-r--r-- | src/testspdy/test_request_response.c | 80 | ||||
-rw-r--r-- | src/testspdy/test_session_timeout.c | 4 |
4 files changed, 83 insertions, 71 deletions
diff --git a/src/testspdy/test_misc.c b/src/testspdy/test_misc.c index d8198061..2387f2c0 100644 --- a/src/testspdy/test_misc.c +++ b/src/testspdy/test_misc.c | |||
@@ -68,7 +68,7 @@ create_child() | |||
68 | 68 | ||
69 | child = fork(); | 69 | child = fork(); |
70 | if (-1 == child) | 70 | if (-1 == child) |
71 | { | 71 | { |
72 | fprintf(stderr, "can't fork, error %d\n", errno); | 72 | fprintf(stderr, "can't fork, error %d\n", errno); |
73 | exit(EXIT_FAILURE); | 73 | exit(EXIT_FAILURE); |
74 | } | 74 | } |
@@ -79,6 +79,8 @@ create_child() | |||
79 | char *uri; | 79 | char *uri; |
80 | fflush(stdout); | 80 | fflush(stdout); |
81 | devnull = open("/dev/null", O_WRONLY); | 81 | devnull = open("/dev/null", O_WRONLY); |
82 | if (-1 == devnull) | ||
83 | abort (); | ||
82 | if (1 != devnull) | 84 | if (1 != devnull) |
83 | { | 85 | { |
84 | dup2(devnull, 1); | 86 | dup2(devnull, 1); |
@@ -100,7 +102,7 @@ response_done_callback(void *cls, | |||
100 | { | 102 | { |
101 | (void)status; | 103 | (void)status; |
102 | (void)streamopened; | 104 | (void)streamopened; |
103 | 105 | ||
104 | if(strcmp(cls,"/main.css")) | 106 | if(strcmp(cls,"/main.css")) |
105 | { | 107 | { |
106 | session1 = SPDY_get_session_for_request(request); | 108 | session1 = SPDY_get_session_for_request(request); |
@@ -109,7 +111,7 @@ response_done_callback(void *cls, | |||
109 | printf("SPDY_get_session_for_request failed\n"); | 111 | printf("SPDY_get_session_for_request failed\n"); |
110 | killchild(); | 112 | killchild(); |
111 | } | 113 | } |
112 | 114 | ||
113 | char *session_cls = strdup(SESSION_CLS); | 115 | char *session_cls = strdup(SESSION_CLS); |
114 | SPDY_set_cls_to_session(session1,session_cls); | 116 | SPDY_set_cls_to_session(session1,session_cls); |
115 | } | 117 | } |
@@ -122,7 +124,7 @@ response_done_callback(void *cls, | |||
122 | killchild(); | 124 | killchild(); |
123 | } | 125 | } |
124 | printf("SPDY_get_session_for_request tested...\n"); | 126 | printf("SPDY_get_session_for_request tested...\n"); |
125 | 127 | ||
126 | void *session_cls = SPDY_get_cls_from_session(session2); | 128 | void *session_cls = SPDY_get_cls_from_session(session2); |
127 | if(NULL == session_cls || strcmp(session_cls, SESSION_CLS)) | 129 | if(NULL == session_cls || strcmp(session_cls, SESSION_CLS)) |
128 | { | 130 | { |
@@ -131,7 +133,7 @@ response_done_callback(void *cls, | |||
131 | } | 133 | } |
132 | printf("SPDY_set_cls_to_session tested...\n"); | 134 | printf("SPDY_set_cls_to_session tested...\n"); |
133 | printf("SPDY_get_cls_from_session tested...\n"); | 135 | printf("SPDY_get_cls_from_session tested...\n"); |
134 | 136 | ||
135 | void *request_cls = SPDY_get_cls_from_request(request); | 137 | void *request_cls = SPDY_get_cls_from_request(request); |
136 | if(NULL == request_cls || strcmp(request_cls, REQUEST_CLS)) | 138 | if(NULL == request_cls || strcmp(request_cls, REQUEST_CLS)) |
137 | { | 139 | { |
@@ -141,7 +143,7 @@ response_done_callback(void *cls, | |||
141 | printf("SPDY_set_cls_to_request tested...\n"); | 143 | printf("SPDY_set_cls_to_request tested...\n"); |
142 | printf("SPDY_get_cls_from_request tested...\n"); | 144 | printf("SPDY_get_cls_from_request tested...\n"); |
143 | } | 145 | } |
144 | 146 | ||
145 | SPDY_destroy_request(request); | 147 | SPDY_destroy_request(request); |
146 | SPDY_destroy_response(response); | 148 | SPDY_destroy_response(response); |
147 | free(cls); | 149 | free(cls); |
@@ -168,10 +170,10 @@ standard_request_handler(void *cls, | |||
168 | (void)method; | 170 | (void)method; |
169 | (void)version; | 171 | (void)version; |
170 | (void)more; | 172 | (void)more; |
171 | 173 | ||
172 | struct SPDY_Response *response=NULL; | 174 | struct SPDY_Response *response=NULL; |
173 | char *cls_path = strdup(path); | 175 | char *cls_path = strdup(path); |
174 | 176 | ||
175 | if(strcmp(path,"/main.css")==0) | 177 | if(strcmp(path,"/main.css")==0) |
176 | { | 178 | { |
177 | char *request_cls = strdup(REQUEST_CLS); | 179 | char *request_cls = strdup(REQUEST_CLS); |
@@ -182,12 +184,12 @@ standard_request_handler(void *cls, | |||
182 | { | 184 | { |
183 | response = SPDY_build_response(200,NULL,SPDY_HTTP_VERSION_1_1,NULL,HTML,strlen(HTML)); | 185 | response = SPDY_build_response(200,NULL,SPDY_HTTP_VERSION_1_1,NULL,HTML,strlen(HTML)); |
184 | } | 186 | } |
185 | 187 | ||
186 | if(NULL==response){ | 188 | if(NULL==response){ |
187 | fprintf(stdout,"no response obj\n"); | 189 | fprintf(stdout,"no response obj\n"); |
188 | killchild(); | 190 | killchild(); |
189 | } | 191 | } |
190 | 192 | ||
191 | if(SPDY_queue_response(request,response,true,false,&response_done_callback,cls_path)!=SPDY_YES) | 193 | if(SPDY_queue_response(request,response,true,false,&response_done_callback,cls_path)!=SPDY_YES) |
192 | { | 194 | { |
193 | fprintf(stdout,"queue\n"); | 195 | fprintf(stdout,"queue\n"); |
@@ -197,7 +199,7 @@ standard_request_handler(void *cls, | |||
197 | 199 | ||
198 | int | 200 | int |
199 | parentproc() | 201 | parentproc() |
200 | { | 202 | { |
201 | int childstatus; | 203 | int childstatus; |
202 | unsigned long long timeoutlong=0; | 204 | unsigned long long timeoutlong=0; |
203 | struct timeval timeout; | 205 | struct timeval timeout; |
@@ -207,7 +209,7 @@ parentproc() | |||
207 | fd_set except_fd_set; | 209 | fd_set except_fd_set; |
208 | int maxfd = -1; | 210 | int maxfd = -1; |
209 | struct SPDY_Daemon *daemon; | 211 | struct SPDY_Daemon *daemon; |
210 | 212 | ||
211 | daemon = SPDY_start_daemon(port, | 213 | daemon = SPDY_start_daemon(port, |
212 | DATA_DIR "cert-and-key.pem", | 214 | DATA_DIR "cert-and-key.pem", |
213 | DATA_DIR "cert-and-key.pem", | 215 | DATA_DIR "cert-and-key.pem", |
@@ -219,12 +221,12 @@ parentproc() | |||
219 | SPDY_DAEMON_OPTION_SESSION_TIMEOUT, | 221 | SPDY_DAEMON_OPTION_SESSION_TIMEOUT, |
220 | 1800, | 222 | 1800, |
221 | SPDY_DAEMON_OPTION_END); | 223 | SPDY_DAEMON_OPTION_END); |
222 | 224 | ||
223 | if(NULL==daemon){ | 225 | if(NULL==daemon){ |
224 | printf("no daemon\n"); | 226 | printf("no daemon\n"); |
225 | return 1; | 227 | return 1; |
226 | } | 228 | } |
227 | 229 | ||
228 | create_child(); | 230 | create_child(); |
229 | 231 | ||
230 | do | 232 | do |
@@ -244,14 +246,14 @@ parentproc() | |||
244 | timeout.tv_sec = timeoutlong / 1000; | 246 | timeout.tv_sec = timeoutlong / 1000; |
245 | timeout.tv_usec = (timeoutlong % 1000) * 1000; | 247 | timeout.tv_usec = (timeoutlong % 1000) * 1000; |
246 | } | 248 | } |
247 | 249 | ||
248 | maxfd = SPDY_get_fdset (daemon, | 250 | maxfd = SPDY_get_fdset (daemon, |
249 | &read_fd_set, | 251 | &read_fd_set, |
250 | &write_fd_set, | 252 | &write_fd_set, |
251 | &except_fd_set); | 253 | &except_fd_set); |
252 | 254 | ||
253 | ret = select(maxfd+1, &read_fd_set, &write_fd_set, &except_fd_set, &timeout); | 255 | ret = select(maxfd+1, &read_fd_set, &write_fd_set, &except_fd_set, &timeout); |
254 | 256 | ||
255 | switch(ret) { | 257 | switch(ret) { |
256 | case -1: | 258 | case -1: |
257 | printf("select error: %i\n", errno); | 259 | printf("select error: %i\n", errno); |
@@ -268,7 +270,7 @@ parentproc() | |||
268 | while(waitpid(child,&childstatus,WNOHANG) != child); | 270 | while(waitpid(child,&childstatus,WNOHANG) != child); |
269 | 271 | ||
270 | SPDY_stop_daemon(daemon); | 272 | SPDY_stop_daemon(daemon); |
271 | 273 | ||
272 | return WEXITSTATUS(childstatus); | 274 | return WEXITSTATUS(childstatus); |
273 | } | 275 | } |
274 | 276 | ||
@@ -278,10 +280,10 @@ main() | |||
278 | { | 280 | { |
279 | port = get_port(13123); | 281 | port = get_port(13123); |
280 | SPDY_init(); | 282 | SPDY_init(); |
281 | 283 | ||
282 | int ret = parentproc(); | 284 | int ret = parentproc(); |
283 | 285 | ||
284 | SPDY_deinit(); | 286 | SPDY_deinit(); |
285 | 287 | ||
286 | return ret; | 288 | return ret; |
287 | } | 289 | } |
diff --git a/src/testspdy/test_proxies.c b/src/testspdy/test_proxies.c index 751c2a7a..ee810649 100644 --- a/src/testspdy/test_proxies.c +++ b/src/testspdy/test_proxies.c | |||
@@ -80,7 +80,7 @@ pid_t au_fork() | |||
80 | if (child == -1) | 80 | if (child == -1) |
81 | { | 81 | { |
82 | killchildren(); | 82 | killchildren(); |
83 | 83 | ||
84 | killproc(parent,"fork failed\n"); | 84 | killproc(parent,"fork failed\n"); |
85 | } | 85 | } |
86 | 86 | ||
@@ -93,7 +93,7 @@ int main() | |||
93 | //pid_t child; | 93 | //pid_t child; |
94 | int childstatus; | 94 | int childstatus; |
95 | pid_t wpid; | 95 | pid_t wpid; |
96 | 96 | ||
97 | parent = getpid(); | 97 | parent = getpid(); |
98 | mhd_port = get_port(4000); | 98 | mhd_port = get_port(4000); |
99 | spdy2http_port = get_port(4100); | 99 | spdy2http_port = get_port(4100); |
@@ -119,8 +119,8 @@ int main() | |||
119 | //killchildren(); | 119 | //killchildren(); |
120 | _exit(1); | 120 | _exit(1); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | child_spdy2http = au_fork(); | 124 | child_spdy2http = au_fork(); |
125 | if (child_spdy2http == 0) | 125 | if (child_spdy2http == 0) |
126 | { | 126 | { |
@@ -144,7 +144,7 @@ int main() | |||
144 | //killchildren(); | 144 | //killchildren(); |
145 | _exit(1); | 145 | _exit(1); |
146 | } | 146 | } |
147 | 147 | ||
148 | child_mhd2spdy = au_fork(); | 148 | child_mhd2spdy = au_fork(); |
149 | if (child_mhd2spdy == 0) | 149 | if (child_mhd2spdy == 0) |
150 | { | 150 | { |
@@ -168,7 +168,7 @@ int main() | |||
168 | //killchildren(); | 168 | //killchildren(); |
169 | _exit(1); | 169 | _exit(1); |
170 | } | 170 | } |
171 | 171 | ||
172 | child_curl = au_fork(); | 172 | child_curl = au_fork(); |
173 | if (child_curl == 0) | 173 | if (child_curl == 0) |
174 | { | 174 | { |
@@ -181,12 +181,14 @@ int main() | |||
181 | 181 | ||
182 | close(1); | 182 | close(1); |
183 | devnull = open("/dev/null", O_WRONLY); | 183 | devnull = open("/dev/null", O_WRONLY); |
184 | if (-1 == devnull) | ||
185 | abort (); | ||
184 | if (1 != devnull) | 186 | if (1 != devnull) |
185 | { | 187 | { |
186 | dup2(devnull, 1); | 188 | dup2(devnull, 1); |
187 | close(devnull); | 189 | close(devnull); |
188 | } | 190 | } |
189 | 191 | ||
190 | asprintf (&cmd, "curl --proxy http://127.0.0.1:%i http://127.0.0.1:%i/", mhd2spdy_port, mhd_port); | 192 | asprintf (&cmd, "curl --proxy http://127.0.0.1:%i http://127.0.0.1:%i/", mhd2spdy_port, mhd_port); |
191 | sleep(3); | 193 | sleep(3); |
192 | p = popen(cmd, "r"); | 194 | p = popen(cmd, "r"); |
@@ -205,7 +207,7 @@ int main() | |||
205 | //killchildren(); | 207 | //killchildren(); |
206 | _exit(1); | 208 | _exit(1); |
207 | } | 209 | } |
208 | 210 | ||
209 | do | 211 | do |
210 | { | 212 | { |
211 | wpid = waitpid(child_mhd,&childstatus,WNOHANG); | 213 | wpid = waitpid(child_mhd,&childstatus,WNOHANG); |
@@ -215,7 +217,7 @@ int main() | |||
215 | killchildren(); | 217 | killchildren(); |
216 | return 1; | 218 | return 1; |
217 | } | 219 | } |
218 | 220 | ||
219 | wpid = waitpid(child_spdy2http,&childstatus,WNOHANG); | 221 | wpid = waitpid(child_spdy2http,&childstatus,WNOHANG); |
220 | if(wpid == child_spdy2http) | 222 | if(wpid == child_spdy2http) |
221 | { | 223 | { |
@@ -223,7 +225,7 @@ int main() | |||
223 | killchildren(); | 225 | killchildren(); |
224 | return 1; | 226 | return 1; |
225 | } | 227 | } |
226 | 228 | ||
227 | wpid = waitpid(child_mhd2spdy,&childstatus,WNOHANG); | 229 | wpid = waitpid(child_mhd2spdy,&childstatus,WNOHANG); |
228 | if(wpid == child_mhd2spdy) | 230 | if(wpid == child_mhd2spdy) |
229 | { | 231 | { |
@@ -231,7 +233,7 @@ int main() | |||
231 | killchildren(); | 233 | killchildren(); |
232 | return 1; | 234 | return 1; |
233 | } | 235 | } |
234 | 236 | ||
235 | if(waitpid(child_curl,&childstatus,WNOHANG) == child_curl) | 237 | if(waitpid(child_curl,&childstatus,WNOHANG) == child_curl) |
236 | { | 238 | { |
237 | killchildren(); | 239 | killchildren(); |
diff --git a/src/testspdy/test_request_response.c b/src/testspdy/test_request_response.c index 07ed236b..de918984 100644 --- a/src/testspdy/test_request_response.c +++ b/src/testspdy/test_request_response.c | |||
@@ -39,7 +39,7 @@ char *rcvbuf; | |||
39 | int rcvbuf_c = 0; | 39 | int rcvbuf_c = 0; |
40 | 40 | ||
41 | int session_closed_called = 0; | 41 | int session_closed_called = 0; |
42 | 42 | ||
43 | void | 43 | void |
44 | killchild(int pid, char *message) | 44 | killchild(int pid, char *message) |
45 | { | 45 | { |
@@ -55,7 +55,7 @@ killparent(int pid, char *message) | |||
55 | kill(pid, SIGKILL); | 55 | kill(pid, SIGKILL); |
56 | _exit(1); | 56 | _exit(1); |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | ||
60 | /***** | 60 | /***** |
61 | * start of code needed to utilize spdylay | 61 | * start of code needed to utilize spdylay |
@@ -131,6 +131,8 @@ static char* strcopy(const char *s, size_t len) | |||
131 | { | 131 | { |
132 | char *dst; | 132 | char *dst; |
133 | dst = malloc(len+1); | 133 | dst = malloc(len+1); |
134 | if (NULL == dst) | ||
135 | abort (); | ||
134 | memcpy(dst, s, len); | 136 | memcpy(dst, s, len); |
135 | dst[len] = '\0'; | 137 | dst[len] = '\0'; |
136 | return dst; | 138 | return dst; |
@@ -204,7 +206,7 @@ static ssize_t send_callback(spdylay_session *session, | |||
204 | { | 206 | { |
205 | (void)session; | 207 | (void)session; |
206 | (void)flags; | 208 | (void)flags; |
207 | 209 | ||
208 | struct Connection *connection; | 210 | struct Connection *connection; |
209 | ssize_t rv; | 211 | ssize_t rv; |
210 | connection = (struct Connection*)user_data; | 212 | connection = (struct Connection*)user_data; |
@@ -236,7 +238,7 @@ static ssize_t recv_callback(spdylay_session *session, | |||
236 | { | 238 | { |
237 | (void)session; | 239 | (void)session; |
238 | (void)flags; | 240 | (void)flags; |
239 | 241 | ||
240 | struct Connection *connection; | 242 | struct Connection *connection; |
241 | ssize_t rv; | 243 | ssize_t rv; |
242 | connection = (struct Connection*)user_data; | 244 | connection = (struct Connection*)user_data; |
@@ -270,7 +272,7 @@ static void before_ctrl_send_callback(spdylay_session *session, | |||
270 | void *user_data) | 272 | void *user_data) |
271 | { | 273 | { |
272 | (void)user_data; | 274 | (void)user_data; |
273 | 275 | ||
274 | if(type == SPDYLAY_SYN_STREAM) { | 276 | if(type == SPDYLAY_SYN_STREAM) { |
275 | struct Request *req; | 277 | struct Request *req; |
276 | int stream_id = frame->syn_stream.stream_id; | 278 | int stream_id = frame->syn_stream.stream_id; |
@@ -287,7 +289,7 @@ static void on_ctrl_send_callback(spdylay_session *session, | |||
287 | spdylay_frame *frame, void *user_data) | 289 | spdylay_frame *frame, void *user_data) |
288 | { | 290 | { |
289 | (void)user_data; | 291 | (void)user_data; |
290 | 292 | ||
291 | char **nv; | 293 | char **nv; |
292 | const char *name = NULL; | 294 | const char *name = NULL; |
293 | int32_t stream_id; | 295 | int32_t stream_id; |
@@ -360,7 +362,7 @@ static void on_stream_close_callback(spdylay_session *session, | |||
360 | { | 362 | { |
361 | (void)user_data; | 363 | (void)user_data; |
362 | (void)status_code; | 364 | (void)status_code; |
363 | 365 | ||
364 | struct Request *req; | 366 | struct Request *req; |
365 | req = spdylay_session_get_stream_user_data(session, stream_id); | 367 | req = spdylay_session_get_stream_user_data(session, stream_id); |
366 | if(req) { | 368 | if(req) { |
@@ -385,7 +387,7 @@ static void on_data_chunk_recv_callback(spdylay_session *session, uint8_t flags, | |||
385 | { | 387 | { |
386 | (void)user_data; | 388 | (void)user_data; |
387 | (void)flags; | 389 | (void)flags; |
388 | 390 | ||
389 | struct Request *req; | 391 | struct Request *req; |
390 | req = spdylay_session_get_stream_user_data(session, stream_id); | 392 | req = spdylay_session_get_stream_user_data(session, stream_id); |
391 | if(req) { | 393 | if(req) { |
@@ -409,13 +411,13 @@ static void on_data_chunk_recv_callback(spdylay_session *session, uint8_t flags, | |||
409 | } else { | 411 | } else { |
410 | /* TODO add support gzip */ | 412 | /* TODO add support gzip */ |
411 | fwrite(data, 1, len, stdout); | 413 | fwrite(data, 1, len, stdout); |
412 | 414 | ||
413 | //check if the data is correct | 415 | //check if the data is correct |
414 | //if(strcmp(RESPONSE_BODY, data) != 0) | 416 | //if(strcmp(RESPONSE_BODY, data) != 0) |
415 | //killparent(parent, "\nreceived data is not the same"); | 417 | //killparent(parent, "\nreceived data is not the same"); |
416 | if(len + rcvbuf_c > strlen(RESPONSE_BODY)) | 418 | if(len + rcvbuf_c > strlen(RESPONSE_BODY)) |
417 | killparent(parent, "\nreceived data is not the same"); | 419 | killparent(parent, "\nreceived data is not the same"); |
418 | 420 | ||
419 | strcpy(rcvbuf + rcvbuf_c,(char*)data); | 421 | strcpy(rcvbuf + rcvbuf_c,(char*)data); |
420 | rcvbuf_c+=len; | 422 | rcvbuf_c+=len; |
421 | } | 423 | } |
@@ -452,7 +454,7 @@ static int select_next_proto_cb(SSL* ssl, | |||
452 | void *arg) | 454 | void *arg) |
453 | { | 455 | { |
454 | (void)ssl; | 456 | (void)ssl; |
455 | 457 | ||
456 | int rv; | 458 | int rv; |
457 | uint16_t *spdy_proto_version; | 459 | uint16_t *spdy_proto_version; |
458 | /* spdylay_select_next_protocol() selects SPDY protocol version the | 460 | /* spdylay_select_next_protocol() selects SPDY protocol version the |
@@ -655,6 +657,8 @@ static void fetch_uri(const struct URI *uri) | |||
655 | 657 | ||
656 | /* Establish connection and setup SSL */ | 658 | /* Establish connection and setup SSL */ |
657 | fd = connect_to(req.host, req.port); | 659 | fd = connect_to(req.host, req.port); |
660 | if (-1 == fd) | ||
661 | abort (); | ||
658 | ssl_ctx = SSL_CTX_new(SSLv23_client_method()); | 662 | ssl_ctx = SSL_CTX_new(SSLv23_client_method()); |
659 | if(ssl_ctx == NULL) { | 663 | if(ssl_ctx == NULL) { |
660 | dief("SSL_CTX_new", ERR_error_string(ERR_get_error(), NULL)); | 664 | dief("SSL_CTX_new", ERR_error_string(ERR_get_error(), NULL)); |
@@ -799,7 +803,7 @@ static int parse_uri(struct URI *res, const char *uri) | |||
799 | /***** | 803 | /***** |
800 | * end of code needed to utilize spdylay | 804 | * end of code needed to utilize spdylay |
801 | */ | 805 | */ |
802 | 806 | ||
803 | 807 | ||
804 | /***** | 808 | /***** |
805 | * start of code needed to utilize microspdy | 809 | * start of code needed to utilize microspdy |
@@ -826,26 +830,26 @@ standard_request_handler(void *cls, | |||
826 | (void)headers; | 830 | (void)headers; |
827 | (void)method; | 831 | (void)method; |
828 | (void)version; | 832 | (void)version; |
829 | 833 | ||
830 | struct SPDY_Response *response=NULL; | 834 | struct SPDY_Response *response=NULL; |
831 | 835 | ||
832 | if(strcmp(CLS,cls)!=0) | 836 | if(strcmp(CLS,cls)!=0) |
833 | { | 837 | { |
834 | killchild(child,"wrong cls"); | 838 | killchild(child,"wrong cls"); |
835 | } | 839 | } |
836 | 840 | ||
837 | if(false != more){ | 841 | if(false != more){ |
838 | fprintf(stdout,"more has wrong value\n"); | 842 | fprintf(stdout,"more has wrong value\n"); |
839 | exit(5); | 843 | exit(5); |
840 | } | 844 | } |
841 | 845 | ||
842 | response = SPDY_build_response(200,NULL,SPDY_HTTP_VERSION_1_1,NULL,RESPONSE_BODY,strlen(RESPONSE_BODY)); | 846 | response = SPDY_build_response(200,NULL,SPDY_HTTP_VERSION_1_1,NULL,RESPONSE_BODY,strlen(RESPONSE_BODY)); |
843 | 847 | ||
844 | if(NULL==response){ | 848 | if(NULL==response){ |
845 | fprintf(stdout,"no response obj\n"); | 849 | fprintf(stdout,"no response obj\n"); |
846 | exit(3); | 850 | exit(3); |
847 | } | 851 | } |
848 | 852 | ||
849 | if(SPDY_queue_response(request,response,true,false,NULL,(void*)strdup(path))!=SPDY_YES) | 853 | if(SPDY_queue_response(request,response,true,false,NULL,(void*)strdup(path))!=SPDY_YES) |
850 | { | 854 | { |
851 | fprintf(stdout,"queue\n"); | 855 | fprintf(stdout,"queue\n"); |
@@ -859,12 +863,12 @@ session_closed_handler (void *cls, | |||
859 | int by_client) | 863 | int by_client) |
860 | { | 864 | { |
861 | printf("session_closed_handler called\n"); | 865 | printf("session_closed_handler called\n"); |
862 | 866 | ||
863 | if(strcmp(CLS,cls)!=0) | 867 | if(strcmp(CLS,cls)!=0) |
864 | { | 868 | { |
865 | killchild(child,"wrong cls"); | 869 | killchild(child,"wrong cls"); |
866 | } | 870 | } |
867 | 871 | ||
868 | if(SPDY_YES != by_client) | 872 | if(SPDY_YES != by_client) |
869 | { | 873 | { |
870 | //killchild(child,"wrong by_client"); | 874 | //killchild(child,"wrong by_client"); |
@@ -874,12 +878,12 @@ session_closed_handler (void *cls, | |||
874 | { | 878 | { |
875 | printf("session closed by client\n"); | 879 | printf("session closed by client\n"); |
876 | } | 880 | } |
877 | 881 | ||
878 | if(NULL == session) | 882 | if(NULL == session) |
879 | { | 883 | { |
880 | killchild(child,"session is NULL"); | 884 | killchild(child,"session is NULL"); |
881 | } | 885 | } |
882 | 886 | ||
883 | session_closed_called = 1; | 887 | session_closed_called = 1; |
884 | } | 888 | } |
885 | 889 | ||
@@ -887,7 +891,7 @@ session_closed_handler (void *cls, | |||
887 | /***** | 891 | /***** |
888 | * end of code needed to utilize microspdy | 892 | * end of code needed to utilize microspdy |
889 | */ | 893 | */ |
890 | 894 | ||
891 | //child process | 895 | //child process |
892 | void | 896 | void |
893 | childproc(int port) | 897 | childproc(int port) |
@@ -896,7 +900,7 @@ childproc(int port) | |||
896 | struct sigaction act; | 900 | struct sigaction act; |
897 | int rv; | 901 | int rv; |
898 | char *uristr; | 902 | char *uristr; |
899 | 903 | ||
900 | memset(&act, 0, sizeof(struct sigaction)); | 904 | memset(&act, 0, sizeof(struct sigaction)); |
901 | act.sa_handler = SIG_IGN; | 905 | act.sa_handler = SIG_IGN; |
902 | sigaction(SIGPIPE, &act, 0); | 906 | sigaction(SIGPIPE, &act, 0); |
@@ -913,7 +917,7 @@ childproc(int port) | |||
913 | killparent(parent,"parse_uri failed"); | 917 | killparent(parent,"parse_uri failed"); |
914 | } | 918 | } |
915 | fetch_uri(&uri); | 919 | fetch_uri(&uri); |
916 | 920 | ||
917 | if(strcmp(rcvbuf, RESPONSE_BODY)) | 921 | if(strcmp(rcvbuf, RESPONSE_BODY)) |
918 | killparent(parent,"received data is different"); | 922 | killparent(parent,"received data is different"); |
919 | } | 923 | } |
@@ -931,14 +935,14 @@ parentproc( int port) | |||
931 | fd_set except_fd_set; | 935 | fd_set except_fd_set; |
932 | int maxfd = -1; | 936 | int maxfd = -1; |
933 | struct SPDY_Daemon *daemon; | 937 | struct SPDY_Daemon *daemon; |
934 | 938 | ||
935 | SPDY_init(); | 939 | SPDY_init(); |
936 | 940 | ||
937 | daemon = SPDY_start_daemon(port, | 941 | daemon = SPDY_start_daemon(port, |
938 | DATA_DIR "cert-and-key.pem", | 942 | DATA_DIR "cert-and-key.pem", |
939 | DATA_DIR "cert-and-key.pem", | 943 | DATA_DIR "cert-and-key.pem", |
940 | NULL,&session_closed_handler,&standard_request_handler,NULL,CLS,SPDY_DAEMON_OPTION_END); | 944 | NULL,&session_closed_handler,&standard_request_handler,NULL,CLS,SPDY_DAEMON_OPTION_END); |
941 | 945 | ||
942 | if(NULL==daemon){ | 946 | if(NULL==daemon){ |
943 | printf("no daemon\n"); | 947 | printf("no daemon\n"); |
944 | return 1; | 948 | return 1; |
@@ -961,14 +965,14 @@ parentproc( int port) | |||
961 | timeout.tv_sec = timeoutlong / 1000; | 965 | timeout.tv_sec = timeoutlong / 1000; |
962 | timeout.tv_usec = (timeoutlong % 1000) * 1000; | 966 | timeout.tv_usec = (timeoutlong % 1000) * 1000; |
963 | } | 967 | } |
964 | 968 | ||
965 | maxfd = SPDY_get_fdset (daemon, | 969 | maxfd = SPDY_get_fdset (daemon, |
966 | &read_fd_set, | 970 | &read_fd_set, |
967 | &write_fd_set, | 971 | &write_fd_set, |
968 | &except_fd_set); | 972 | &except_fd_set); |
969 | 973 | ||
970 | ret = select(maxfd+1, &read_fd_set, &write_fd_set, &except_fd_set, &timeout); | 974 | ret = select(maxfd+1, &read_fd_set, &write_fd_set, &except_fd_set, &timeout); |
971 | 975 | ||
972 | switch(ret) { | 976 | switch(ret) { |
973 | case -1: | 977 | case -1: |
974 | printf("select error: %i\n", errno); | 978 | printf("select error: %i\n", errno); |
@@ -990,9 +994,9 @@ parentproc( int port) | |||
990 | SPDY_run(daemon); | 994 | SPDY_run(daemon); |
991 | 995 | ||
992 | SPDY_stop_daemon(daemon); | 996 | SPDY_stop_daemon(daemon); |
993 | 997 | ||
994 | SPDY_deinit(); | 998 | SPDY_deinit(); |
995 | 999 | ||
996 | return WEXITSTATUS(childstatus); | 1000 | return WEXITSTATUS(childstatus); |
997 | } | 1001 | } |
998 | 1002 | ||
@@ -1000,21 +1004,21 @@ int main() | |||
1000 | { | 1004 | { |
1001 | int port = get_port(12123); | 1005 | int port = get_port(12123); |
1002 | parent = getpid(); | 1006 | parent = getpid(); |
1003 | 1007 | ||
1004 | child = fork(); | 1008 | child = fork(); |
1005 | if (child == -1) | 1009 | if (child == -1) |
1006 | { | 1010 | { |
1007 | fprintf(stderr, "can't fork, error %d\n", errno); | 1011 | fprintf(stderr, "can't fork, error %d\n", errno); |
1008 | exit(EXIT_FAILURE); | 1012 | exit(EXIT_FAILURE); |
1009 | } | 1013 | } |
1010 | 1014 | ||
1011 | if (child == 0) | 1015 | if (child == 0) |
1012 | { | 1016 | { |
1013 | childproc(port); | 1017 | childproc(port); |
1014 | _exit(0); | 1018 | _exit(0); |
1015 | } | 1019 | } |
1016 | else | 1020 | else |
1017 | { | 1021 | { |
1018 | int ret = parentproc(port); | 1022 | int ret = parentproc(port); |
1019 | if(1 == session_closed_called && 0 == ret) | 1023 | if(1 == session_closed_called && 0 == ret) |
1020 | exit(0); | 1024 | exit(0); |
diff --git a/src/testspdy/test_session_timeout.c b/src/testspdy/test_session_timeout.c index e34bf674..71af8629 100644 --- a/src/testspdy/test_session_timeout.c +++ b/src/testspdy/test_session_timeout.c | |||
@@ -283,12 +283,16 @@ childproc() | |||
283 | close(devnull); | 283 | close(devnull); |
284 | }*/ | 284 | }*/ |
285 | devnull = open("/dev/null", O_WRONLY); | 285 | devnull = open("/dev/null", O_WRONLY); |
286 | if (-1 == devnull) | ||
287 | abort (); | ||
286 | if (1 != devnull) | 288 | if (1 != devnull) |
287 | { | 289 | { |
288 | dup2(devnull, 1); | 290 | dup2(devnull, 1); |
289 | close(devnull); | 291 | close(devnull); |
290 | } | 292 | } |
291 | devnull = open("/dev/null", O_WRONLY); | 293 | devnull = open("/dev/null", O_WRONLY); |
294 | if (-1 == devnull) | ||
295 | abort (); | ||
292 | if (2 != devnull) | 296 | if (2 != devnull) |
293 | { | 297 | { |
294 | dup2(devnull, 2); | 298 | dup2(devnull, 2); |