aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-08-18 13:01:23 +0000
committerChristian Grothoff <christian@grothoff.org>2007-08-18 13:01:23 +0000
commit806387b6052d1892b511a9701117a33591c1aa05 (patch)
tree35d58ab338829c614cb1ab6679c73555672847be
parent6f1d61c647808174873f0f507ec215fa8512cb69 (diff)
downloadlibmicrohttpd-806387b6052d1892b511a9701117a33591c1aa05.tar.gz
libmicrohttpd-806387b6052d1892b511a9701117a33591c1aa05.zip
additional testcase and auto-repeat processing on accept
-rw-r--r--src/daemon/Makefile.am15
-rw-r--r--src/daemon/daemon.c134
-rw-r--r--src/daemon/daemontest_get.c27
-rw-r--r--src/daemon/daemontest_large_put.c388
-rw-r--r--src/daemon/daemontest_post.c27
-rw-r--r--src/daemon/daemontest_put.c26
6 files changed, 493 insertions, 124 deletions
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index 8a0aa4b2..e70583d3 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -38,9 +38,11 @@ check_PROGRAMS = \
38 daemontest_get \ 38 daemontest_get \
39 daemontest_post \ 39 daemontest_post \
40 daemontest_put \ 40 daemontest_put \
41 daemontest_large_put \
41 daemontest_get11 \ 42 daemontest_get11 \
42 daemontest_post11 \ 43 daemontest_post11 \
43 daemontest_put11 \ 44 daemontest_put11 \
45 daemontest_large_put11 \
44 daemontest_long_header 46 daemontest_long_header
45 47
46TESTS = $(check_PROGRAMS) 48TESTS = $(check_PROGRAMS)
@@ -86,6 +88,19 @@ daemontest_put11_LDADD = \
86 $(top_builddir)/src/daemon/libmicrohttpd.la \ 88 $(top_builddir)/src/daemon/libmicrohttpd.la \
87 @LIBCURL@ 89 @LIBCURL@
88 90
91
92daemontest_large_put_SOURCES = \
93 daemontest_large_put.c
94daemontest_large_put_LDADD = \
95 $(top_builddir)/src/daemon/libmicrohttpd.la \
96 @LIBCURL@
97
98daemontest_large_put11_SOURCES = \
99 daemontest_large_put.c
100daemontest_large_put11_LDADD = \
101 $(top_builddir)/src/daemon/libmicrohttpd.la \
102 @LIBCURL@
103
89daemontest_long_header_SOURCES = \ 104daemontest_long_header_SOURCES = \
90 daemontest_long_header.c 105 daemontest_long_header.c
91daemontest_long_header_LDADD = \ 106daemontest_long_header_LDADD = \
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 26b13d35..385e37c3 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -429,6 +429,7 @@ MHD_select (struct MHD_Daemon *daemon, int may_block)
429 unsigned long long ltimeout; 429 unsigned long long ltimeout;
430 int ds; 430 int ds;
431 time_t now; 431 time_t now;
432 int go_again;
432 433
433 timeout.tv_sec = 0; 434 timeout.tv_sec = 0;
434 timeout.tv_usec = 0; 435 timeout.tv_usec = 0;
@@ -436,78 +437,87 @@ MHD_select (struct MHD_Daemon *daemon, int may_block)
436 abort (); 437 abort ();
437 if (daemon->shutdown == MHD_YES) 438 if (daemon->shutdown == MHD_YES)
438 return MHD_NO; 439 return MHD_NO;
439 FD_ZERO (&rs); 440 go_again = MHD_YES;
440 FD_ZERO (&ws); 441 while (go_again == MHD_YES)
441 FD_ZERO (&es);
442 max = 0;
443
444 if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
445 {
446 /* single-threaded, go over everything */
447 if (MHD_NO == MHD_get_fdset (daemon, &rs, &ws, &es, &max))
448 return MHD_NO;
449 }
450 else
451 { 442 {
452 /* accept only, have one thread per connection */ 443 go_again = MHD_NO;
453 max = daemon->socket_fd; 444 FD_ZERO (&rs);
454 if (max == -1) 445 FD_ZERO (&ws);
446 FD_ZERO (&es);
447 max = 0;
448
449 if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
450 {
451 /* single-threaded, go over everything */
452 if (MHD_NO == MHD_get_fdset (daemon, &rs, &ws, &es, &max))
453 return MHD_NO;
454 }
455 else
456 {
457 /* accept only, have one thread per connection */
458 max = daemon->socket_fd;
459 if (max == -1)
460 return MHD_NO;
461 FD_SET (max, &rs);
462 }
463 if (may_block == MHD_NO)
464 {
465 timeout.tv_usec = 0;
466 timeout.tv_sec = 0;
467 }
468 else
469 {
470 /* ltimeout is in ms */
471 if (MHD_YES == MHD_get_timeout (daemon, &ltimeout))
472 {
473 timeout.tv_usec = (ltimeout % 1000) * 1000 * 1000;
474 timeout.tv_sec = ltimeout / 1000;
475 may_block = MHD_NO;
476 }
477 }
478 num_ready = SELECT (max + 1,
479 &rs, &ws, &es,
480 may_block == MHD_NO ? &timeout : NULL);
481 if (daemon->shutdown == MHD_YES)
455 return MHD_NO; 482 return MHD_NO;
456 FD_SET (max, &rs); 483 if (num_ready < 0)
457 }
458 if (may_block == MHD_NO)
459 {
460 timeout.tv_usec = 0;
461 timeout.tv_sec = 0;
462 }
463 else
464 {
465 /* ltimeout is in ms */
466 if (MHD_YES == MHD_get_timeout (daemon, &ltimeout))
467 { 484 {
468 timeout.tv_usec = (ltimeout % 1000) * 1000 * 1000; 485 if (errno == EINTR)
469 timeout.tv_sec = ltimeout / 1000; 486 return MHD_YES;
470 may_block = MHD_NO; 487 MHD_DLOG (daemon, "Select failed: %s\n", STRERROR (errno));
488 return MHD_NO;
471 } 489 }
472 } 490 ds = daemon->socket_fd;
473 num_ready = SELECT (max + 1, 491 if (ds == -1)
474 &rs, &ws, &es, may_block == MHD_NO ? &timeout : NULL);
475 if (daemon->shutdown == MHD_YES)
476 return MHD_NO;
477 if (num_ready < 0)
478 {
479 if (errno == EINTR)
480 return MHD_YES; 492 return MHD_YES;
481 MHD_DLOG (daemon, "Select failed: %s\n", STRERROR (errno)); 493 if (FD_ISSET (ds, &rs))
482 return MHD_NO; 494 {
483 } 495 MHD_accept_connection (daemon);
484 ds = daemon->socket_fd; 496 go_again = MHD_YES;
485 if (ds == -1) 497 }
486 return MHD_YES; 498 if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
487 if (FD_ISSET (ds, &rs))
488 MHD_accept_connection (daemon);
489 if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
490 {
491 /* do not have a thread per connection, process all connections now */
492 now = time (NULL);
493 pos = daemon->connections;
494 while (pos != NULL)
495 { 499 {
496 ds = pos->socket_fd; 500 /* do not have a thread per connection, process all connections now */
497 if (ds != -1) 501 now = time (NULL);
502 pos = daemon->connections;
503 while (pos != NULL)
498 { 504 {
499 if (FD_ISSET (ds, &rs)) 505 ds = pos->socket_fd;
500 { 506 if (ds != -1)
501 pos->last_activity = now;
502 MHD_connection_handle_read (pos);
503 }
504 if (FD_ISSET (ds, &ws))
505 { 507 {
506 pos->last_activity = now; 508 if (FD_ISSET (ds, &rs))
507 MHD_connection_handle_write (pos); 509 {
510 pos->last_activity = now;
511 MHD_connection_handle_read (pos);
512 }
513 if (FD_ISSET (ds, &ws))
514 {
515 pos->last_activity = now;
516 MHD_connection_handle_write (pos);
517 }
508 } 518 }
519 pos = pos->next;
509 } 520 }
510 pos = pos->next;
511 } 521 }
512 } 522 }
513 return MHD_YES; 523 return MHD_YES;
diff --git a/src/daemon/daemontest_get.c b/src/daemon/daemontest_get.c
index f5ef084f..e8ce1e7a 100644
--- a/src/daemon/daemontest_get.c
+++ b/src/daemon/daemontest_get.c
@@ -120,19 +120,11 @@ testInternalGet ()
120 return 2; 120 return 2;
121 } 121 }
122 curl_easy_cleanup (c); 122 curl_easy_cleanup (c);
123 MHD_stop_daemon (d);
123 if (cbc.pos != strlen ("/hello_world")) 124 if (cbc.pos != strlen ("/hello_world"))
124 { 125 return 4;
125 MHD_stop_daemon (d);
126 return 4;
127 }
128
129 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) 126 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
130 { 127 return 8;
131 MHD_stop_daemon (d);
132 return 8;
133 }
134 MHD_stop_daemon (d);
135
136 return 0; 128 return 0;
137} 129}
138 130
@@ -177,18 +169,11 @@ testMultithreadedGet ()
177 return 32; 169 return 32;
178 } 170 }
179 curl_easy_cleanup (c); 171 curl_easy_cleanup (c);
172 MHD_stop_daemon (d);
180 if (cbc.pos != strlen ("/hello_world")) 173 if (cbc.pos != strlen ("/hello_world"))
181 { 174 return 64;
182 MHD_stop_daemon (d);
183 return 64;
184 }
185 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) 175 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
186 { 176 return 128;
187 MHD_stop_daemon (d);
188 return 128;
189 }
190 MHD_stop_daemon (d);
191
192 return 0; 177 return 0;
193} 178}
194 179
diff --git a/src/daemon/daemontest_large_put.c b/src/daemon/daemontest_large_put.c
new file mode 100644
index 00000000..e176d29c
--- /dev/null
+++ b/src/daemon/daemontest_large_put.c
@@ -0,0 +1,388 @@
1/*
2 This file is part of libmicrohttpd
3 (C) 2007 Christian Grothoff
4
5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 libmicrohttpd is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with libmicrohttpd; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file daemontest_put.c
23 * @brief Testcase for libmicrohttpd PUT operations
24 * @author Christian Grothoff
25 */
26
27#include "config.h"
28#include <curl/curl.h>
29#include <microhttpd.h>
30#include <stdlib.h>
31#include <string.h>
32#include <time.h>
33
34#ifndef WINDOWS
35#include <unistd.h>
36#endif
37
38static int oneone;
39
40/**
41 * Do not make this much larger since we will hit the
42 * MHD default buffer limit and the test code is not
43 * written for incremental upload processing...
44 */
45#define PUT_SIZE (512 * 1024)
46
47static char *put_buffer;
48
49struct CBC
50{
51 char *buf;
52 size_t pos;
53 size_t size;
54};
55
56static size_t
57putBuffer (void *stream, size_t size, size_t nmemb, void *ptr)
58{
59 unsigned int *pos = ptr;
60 unsigned int wrt;
61
62 wrt = size * nmemb;
63 if (wrt > PUT_SIZE - (*pos))
64 wrt = PUT_SIZE - (*pos);
65 memcpy (stream, &put_buffer[*pos], wrt);
66 (*pos) += wrt;
67 return wrt;
68}
69
70static size_t
71copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
72{
73 struct CBC *cbc = ctx;
74
75 if (cbc->pos + size * nmemb > cbc->size)
76 return 0; /* overflow */
77 memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb);
78 cbc->pos += size * nmemb;
79 return size * nmemb;
80}
81
82static int
83ahc_echo (void *cls,
84 struct MHD_Connection *connection,
85 const char *url,
86 const char *method,
87 const char *version,
88 const char *upload_data, unsigned int *upload_data_size)
89{
90 int *done = cls;
91 struct MHD_Response *response;
92 int ret;
93
94 if (0 != strcmp ("PUT", method))
95 return MHD_NO; /* unexpected method */
96 if ((*done) == 0)
97 {
98 if (*upload_data_size != PUT_SIZE)
99 return MHD_YES; /* not yet ready */
100 if (0 == memcmp (upload_data, put_buffer, PUT_SIZE))
101 {
102 *upload_data_size = 0;
103 }
104 else
105 {
106 printf ("Invalid upload data!\n");
107 return MHD_NO;
108 }
109 *done = 1;
110 return MHD_YES;
111 }
112 response = MHD_create_response_from_data (strlen (url),
113 (void *) url, MHD_NO, MHD_YES);
114 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
115 MHD_destroy_response (response);
116 return ret;
117}
118
119
120static int
121testInternalPut ()
122{
123 struct MHD_Daemon *d;
124 CURL *c;
125 struct CBC cbc;
126 unsigned int pos = 0;
127 int done_flag = 0;
128 CURLcode errornum;
129 char buf[2048];
130
131 cbc.buf = buf;
132 cbc.size = 2048;
133 cbc.pos = 0;
134 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG,
135 1080,
136 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
137 if (d == NULL)
138 return 1;
139 c = curl_easy_init ();
140 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1080/hello_world");
141 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
142 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
143 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
144 curl_easy_setopt (c, CURLOPT_READDATA, &pos);
145 curl_easy_setopt (c, CURLOPT_UPLOAD, 1L);
146 curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE);
147 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
148 curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L);
149 if (oneone)
150 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
151 else
152 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
153 curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L);
154 // NOTE: use of CONNECTTIMEOUT without also
155 // setting NOSIGNAL results in really weird
156 // crashes on my system!
157 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
158 if (CURLE_OK != (errornum = curl_easy_perform (c)))
159 {
160 fprintf (stderr,
161 "curl_easy_perform failed: `%s'\n",
162 curl_easy_strerror (errornum));
163 curl_easy_cleanup (c);
164 MHD_stop_daemon (d);
165 return 2;
166 }
167 curl_easy_cleanup (c);
168 MHD_stop_daemon (d);
169 if (cbc.pos != strlen ("/hello_world"))
170 return 4;
171 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
172 return 8;
173 return 0;
174}
175
176static int
177testMultithreadedPut ()
178{
179 struct MHD_Daemon *d;
180 CURL *c;
181 struct CBC cbc;
182 unsigned int pos = 0;
183 int done_flag = 0;
184 CURLcode errornum;
185 char buf[2048];
186
187 cbc.buf = buf;
188 cbc.size = 2048;
189 cbc.pos = 0;
190 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG,
191 1081,
192 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
193 if (d == NULL)
194 {
195 free (cbc.buf);
196 return 16;
197 }
198 c = curl_easy_init ();
199 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1081/hello_world");
200 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
201 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
202 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
203 curl_easy_setopt (c, CURLOPT_READDATA, &pos);
204 curl_easy_setopt (c, CURLOPT_UPLOAD, 1L);
205 curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE);
206 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
207 curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L);
208 if (oneone)
209 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
210 else
211 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
212 curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L);
213 // NOTE: use of CONNECTTIMEOUT without also
214 // setting NOSIGNAL results in really weird
215 // crashes on my system!
216 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
217 if (CURLE_OK != (errornum = curl_easy_perform (c)))
218 {
219 fprintf (stderr,
220 "curl_easy_perform failed: `%s'\n",
221 curl_easy_strerror (errornum));
222 curl_easy_cleanup (c);
223 MHD_stop_daemon (d);
224 return 32;
225 }
226 curl_easy_cleanup (c);
227 MHD_stop_daemon (d);
228 if (cbc.pos != strlen ("/hello_world"))
229 return 64;
230 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
231 return 128;
232 return 0;
233}
234
235
236static int
237testExternalPut ()
238{
239 struct MHD_Daemon *d;
240 CURL *c;
241 struct CBC cbc;
242 CURLM *multi;
243 CURLMcode mret;
244 fd_set rs;
245 fd_set ws;
246 fd_set es;
247 int max;
248 int running;
249 struct CURLMsg *msg;
250 time_t start;
251 struct timeval tv;
252 unsigned int pos = 0;
253 int done_flag = 0;
254 char buf[2048];
255
256 cbc.buf = buf;
257 cbc.size = 2048;
258 cbc.pos = 0;
259 multi = NULL;
260 d = MHD_start_daemon (MHD_USE_DEBUG,
261 1082,
262 NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END);
263 if (d == NULL)
264 return 256;
265 c = curl_easy_init ();
266 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1082/hello_world");
267 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
268 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
269 curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer);
270 curl_easy_setopt (c, CURLOPT_READDATA, &pos);
271 curl_easy_setopt (c, CURLOPT_UPLOAD, 1L);
272 curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE);
273 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
274 curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L);
275 if (oneone)
276 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
277 else
278 curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
279 curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L);
280 // NOTE: use of CONNECTTIMEOUT without also
281 // setting NOSIGNAL results in really weird
282 // crashes on my system!
283 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
284
285
286 multi = curl_multi_init ();
287 if (multi == NULL)
288 {
289 curl_easy_cleanup (c);
290 MHD_stop_daemon (d);
291 return 512;
292 }
293 mret = curl_multi_add_handle (multi, c);
294 if (mret != CURLM_OK)
295 {
296 curl_multi_cleanup (multi);
297 curl_easy_cleanup (c);
298 MHD_stop_daemon (d);
299 return 1024;
300 }
301 start = time (NULL);
302 while ((time (NULL) - start < 5) && (multi != NULL))
303 {
304 max = 0;
305 FD_ZERO (&rs);
306 FD_ZERO (&ws);
307 FD_ZERO (&es);
308 curl_multi_perform (multi, &running);
309 mret = curl_multi_fdset (multi, &rs, &ws, &es, &max);
310 if (mret != CURLM_OK)
311 {
312 curl_multi_remove_handle (multi, c);
313 curl_multi_cleanup (multi);
314 curl_easy_cleanup (c);
315 MHD_stop_daemon (d);
316 return 2048;
317 }
318 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
319 {
320 curl_multi_remove_handle (multi, c);
321 curl_multi_cleanup (multi);
322 curl_easy_cleanup (c);
323 MHD_stop_daemon (d);
324 return 4096;
325 }
326 tv.tv_sec = 0;
327 tv.tv_usec = 1000;
328 select (max + 1, &rs, &ws, &es, &tv);
329 curl_multi_perform (multi, &running);
330 if (running == 0)
331 {
332 msg = curl_multi_info_read (multi, &running);
333 if (msg == NULL)
334 break;
335 if (msg->msg == CURLMSG_DONE)
336 {
337 if (msg->data.result != CURLE_OK)
338 printf ("%s failed at %s:%d: `%s'\n",
339 "curl_multi_perform",
340 __FILE__,
341 __LINE__, curl_easy_strerror (msg->data.result));
342 curl_multi_remove_handle (multi, c);
343 curl_multi_cleanup (multi);
344 curl_easy_cleanup (c);
345 c = NULL;
346 multi = NULL;
347 }
348 }
349 MHD_run (d);
350 }
351 if (multi != NULL)
352 {
353 curl_multi_remove_handle (multi, c);
354 curl_easy_cleanup (c);
355 curl_multi_cleanup (multi);
356 }
357 MHD_stop_daemon (d);
358 if (cbc.pos != strlen ("/hello_world"))
359 return 64;
360 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
361 return 128;
362 return 0;
363}
364
365
366
367int
368main (int argc, char *const *argv)
369{
370 unsigned int errorCount = 0;
371
372 oneone = NULL != strstr (argv[0], "11");
373 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
374 return 2;
375 put_buffer = malloc (PUT_SIZE);
376 memset (put_buffer, 1, PUT_SIZE);
377 if (0)
378 {
379 errorCount += testInternalPut ();
380 errorCount += testMultithreadedPut ();
381 }
382 errorCount += testExternalPut ();
383 free (put_buffer);
384 if (errorCount != 0)
385 fprintf (stderr, "Error (code: %u)\n", errorCount);
386 curl_global_cleanup ();
387 return errorCount != 0; /* 0 == pass */
388}
diff --git a/src/daemon/daemontest_post.c b/src/daemon/daemontest_post.c
index 6764450e..ec60575b 100644
--- a/src/daemon/daemontest_post.c
+++ b/src/daemon/daemontest_post.c
@@ -142,19 +142,11 @@ testInternalPost ()
142 return 2; 142 return 2;
143 } 143 }
144 curl_easy_cleanup (c); 144 curl_easy_cleanup (c);
145 MHD_stop_daemon (d);
145 if (cbc.pos != strlen ("/hello_world")) 146 if (cbc.pos != strlen ("/hello_world"))
146 { 147 return 4;
147 MHD_stop_daemon (d);
148 return 4;
149 }
150
151 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) 148 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
152 { 149 return 8;
153 MHD_stop_daemon (d);
154 return 8;
155 }
156 MHD_stop_daemon (d);
157
158 return 0; 150 return 0;
159} 151}
160 152
@@ -202,18 +194,11 @@ testMultithreadedPost ()
202 return 32; 194 return 32;
203 } 195 }
204 curl_easy_cleanup (c); 196 curl_easy_cleanup (c);
197 MHD_stop_daemon (d);
205 if (cbc.pos != strlen ("/hello_world")) 198 if (cbc.pos != strlen ("/hello_world"))
206 { 199 return 64;
207 MHD_stop_daemon (d);
208 return 64;
209 }
210 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) 200 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
211 { 201 return 128;
212 MHD_stop_daemon (d);
213 return 128;
214 }
215 MHD_stop_daemon (d);
216
217 return 0; 202 return 0;
218} 203}
219 204
diff --git a/src/daemon/daemontest_put.c b/src/daemon/daemontest_put.c
index 198eb0f8..bd3e0a52 100644
--- a/src/daemon/daemontest_put.c
+++ b/src/daemon/daemontest_put.c
@@ -156,19 +156,11 @@ testInternalPut ()
156 return 2; 156 return 2;
157 } 157 }
158 curl_easy_cleanup (c); 158 curl_easy_cleanup (c);
159 MHD_stop_daemon (d);
159 if (cbc.pos != strlen ("/hello_world")) 160 if (cbc.pos != strlen ("/hello_world"))
160 { 161 return 4;
161 MHD_stop_daemon (d);
162 return 4;
163 }
164
165 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) 162 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
166 { 163 return 8;
167 MHD_stop_daemon (d);
168 return 8;
169 }
170 MHD_stop_daemon (d);
171
172 return 0; 164 return 0;
173} 165}
174 166
@@ -220,17 +212,11 @@ testMultithreadedPut ()
220 return 32; 212 return 32;
221 } 213 }
222 curl_easy_cleanup (c); 214 curl_easy_cleanup (c);
215 MHD_stop_daemon (d);
223 if (cbc.pos != strlen ("/hello_world")) 216 if (cbc.pos != strlen ("/hello_world"))
224 { 217 return 64;
225 MHD_stop_daemon (d);
226 return 64;
227 }
228 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) 218 if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
229 { 219 return 128;
230 MHD_stop_daemon (d);
231 return 128;
232 }
233 MHD_stop_daemon (d);
234 220
235 return 0; 221 return 0;
236} 222}