diff options
author | Christian Grothoff <christian@grothoff.org> | 2008-04-13 02:54:58 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2008-04-13 02:54:58 +0000 |
commit | 72c08272fdbb426830363b0903224241157deb18 (patch) | |
tree | 7be7c5198f18edfe4b441744ff2e6ea83b896123 /src | |
parent | 359fcdda235f8ce9c625e1789e6b22bb30d592fd (diff) | |
download | libmicrohttpd-72c08272fdbb426830363b0903224241157deb18.tar.gz libmicrohttpd-72c08272fdbb426830363b0903224241157deb18.zip |
formatting
Diffstat (limited to 'src')
-rw-r--r-- | src/daemon/connection.c | 187 | ||||
-rw-r--r-- | src/testcurl/daemontest_get_chunked.c | 2 | ||||
-rw-r--r-- | src/testcurl/daemontest_long_header.c | 4 | ||||
-rw-r--r-- | src/testzzuf/daemontest_get.c | 253 | ||||
-rw-r--r-- | src/testzzuf/daemontest_get_chunked.c | 235 | ||||
-rw-r--r-- | src/testzzuf/daemontest_large_put.c | 70 | ||||
-rw-r--r-- | src/testzzuf/socat.c | 71 |
7 files changed, 413 insertions, 409 deletions
diff --git a/src/daemon/connection.c b/src/daemon/connection.c index 6246ee21..eb97c6b9 100644 --- a/src/daemon/connection.c +++ b/src/daemon/connection.c | |||
@@ -563,8 +563,7 @@ build_header_response (struct MHD_Connection *connection) | |||
563 | */ | 563 | */ |
564 | static void | 564 | static void |
565 | transmit_error_response (struct MHD_Connection *connection, | 565 | transmit_error_response (struct MHD_Connection *connection, |
566 | unsigned int status_code, | 566 | unsigned int status_code, const char *message) |
567 | const char * message) | ||
568 | { | 567 | { |
569 | struct MHD_Response *response; | 568 | struct MHD_Response *response; |
570 | 569 | ||
@@ -574,11 +573,10 @@ transmit_error_response (struct MHD_Connection *connection, | |||
574 | #if HAVE_MESSAGES | 573 | #if HAVE_MESSAGES |
575 | MHD_DLOG (connection->daemon, | 574 | MHD_DLOG (connection->daemon, |
576 | "Error %u (`%s') processing request, closing connection.\n", | 575 | "Error %u (`%s') processing request, closing connection.\n", |
577 | status_code, | 576 | status_code, message); |
578 | message); | ||
579 | #endif | 577 | #endif |
580 | response = MHD_create_response_from_data (strlen (message), | 578 | response = MHD_create_response_from_data (strlen (message), |
581 | (void*)message, MHD_NO, MHD_NO); | 579 | (void *) message, MHD_NO, MHD_NO); |
582 | MHD_queue_response (connection, status_code, response); | 580 | MHD_queue_response (connection, status_code, response); |
583 | EXTRA_CHECK (connection->response != NULL); | 581 | EXTRA_CHECK (connection->response != NULL); |
584 | MHD_destroy_response (response); | 582 | MHD_destroy_response (response); |
@@ -657,10 +655,10 @@ MHD_connection_get_fdset (struct MHD_Connection *connection, | |||
657 | && (MHD_NO == try_grow_read_buffer (connection))) | 655 | && (MHD_NO == try_grow_read_buffer (connection))) |
658 | { | 656 | { |
659 | transmit_error_response (connection, | 657 | transmit_error_response (connection, |
660 | (connection->url != NULL) | 658 | (connection->url != NULL) |
661 | ? MHD_HTTP_REQUEST_ENTITY_TOO_LARGE | 659 | ? MHD_HTTP_REQUEST_ENTITY_TOO_LARGE |
662 | : MHD_HTTP_REQUEST_URI_TOO_LONG, | 660 | : MHD_HTTP_REQUEST_URI_TOO_LONG, |
663 | REQUEST_TOO_BIG); | 661 | REQUEST_TOO_BIG); |
664 | continue; | 662 | continue; |
665 | } | 663 | } |
666 | if (MHD_NO == connection->read_closed) | 664 | if (MHD_NO == connection->read_closed) |
@@ -774,10 +772,10 @@ get_next_header_line (struct MHD_Connection *connection) | |||
774 | if (rbuf == NULL) | 772 | if (rbuf == NULL) |
775 | { | 773 | { |
776 | transmit_error_response (connection, | 774 | transmit_error_response (connection, |
777 | (connection->url != NULL) | 775 | (connection->url != NULL) |
778 | ? MHD_HTTP_REQUEST_ENTITY_TOO_LARGE | 776 | ? MHD_HTTP_REQUEST_ENTITY_TOO_LARGE |
779 | : MHD_HTTP_REQUEST_URI_TOO_LONG, | 777 | : MHD_HTTP_REQUEST_URI_TOO_LONG, |
780 | REQUEST_TOO_BIG); | 778 | REQUEST_TOO_BIG); |
781 | } | 779 | } |
782 | else | 780 | else |
783 | { | 781 | { |
@@ -816,7 +814,7 @@ connection_add_header (struct MHD_Connection *connection, | |||
816 | "Not enough memory to allocate header record!\n"); | 814 | "Not enough memory to allocate header record!\n"); |
817 | #endif | 815 | #endif |
818 | transmit_error_response (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, | 816 | transmit_error_response (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, |
819 | REQUEST_TOO_BIG); | 817 | REQUEST_TOO_BIG); |
820 | return MHD_NO; | 818 | return MHD_NO; |
821 | } | 819 | } |
822 | hdr->next = connection->headers_received; | 820 | hdr->next = connection->headers_received; |
@@ -884,7 +882,7 @@ parse_cookie_header (struct MHD_Connection *connection) | |||
884 | MHD_DLOG (connection->daemon, "Not enough memory to parse cookies!\n"); | 882 | MHD_DLOG (connection->daemon, "Not enough memory to parse cookies!\n"); |
885 | #endif | 883 | #endif |
886 | transmit_error_response (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, | 884 | transmit_error_response (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, |
887 | REQUEST_TOO_BIG); | 885 | REQUEST_TOO_BIG); |
888 | return MHD_NO; | 886 | return MHD_NO; |
889 | } | 887 | } |
890 | memcpy (cpy, hdr, strlen (hdr) + 1); | 888 | memcpy (cpy, hdr, strlen (hdr) + 1); |
@@ -1240,8 +1238,8 @@ process_broken_line (struct MHD_Connection *connection, | |||
1240 | if (last == NULL) | 1238 | if (last == NULL) |
1241 | { | 1239 | { |
1242 | transmit_error_response (connection, | 1240 | transmit_error_response (connection, |
1243 | MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, | 1241 | MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, |
1244 | REQUEST_TOO_BIG); | 1242 | REQUEST_TOO_BIG); |
1245 | return MHD_NO; | 1243 | return MHD_NO; |
1246 | } | 1244 | } |
1247 | tmp = line; | 1245 | tmp = line; |
@@ -1251,24 +1249,23 @@ process_broken_line (struct MHD_Connection *connection, | |||
1251 | connection->last = last; | 1249 | connection->last = last; |
1252 | return MHD_YES; /* possibly more than 2 lines... */ | 1250 | return MHD_YES; /* possibly more than 2 lines... */ |
1253 | } | 1251 | } |
1254 | EXTRA_CHECK ( (last != NULL) && (connection->colon != NULL) ); | 1252 | EXTRA_CHECK ((last != NULL) && (connection->colon != NULL)); |
1255 | if ( (MHD_NO == connection_add_header (connection, | 1253 | if ((MHD_NO == connection_add_header (connection, |
1256 | last, connection->colon, kind)) ) | 1254 | last, connection->colon, kind))) |
1257 | { | 1255 | { |
1258 | transmit_error_response (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, | 1256 | transmit_error_response (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, |
1259 | REQUEST_TOO_BIG); | 1257 | REQUEST_TOO_BIG); |
1260 | return MHD_NO; | 1258 | return MHD_NO; |
1261 | } | 1259 | } |
1262 | /* we still have the current line to deal with... */ | 1260 | /* we still have the current line to deal with... */ |
1263 | if (strlen (line) != 0) | 1261 | if (strlen (line) != 0) |
1264 | { | 1262 | { |
1265 | if (MHD_NO == process_header_line (connection, line)) | 1263 | if (MHD_NO == process_header_line (connection, line)) |
1266 | { | 1264 | { |
1267 | transmit_error_response(connection, | 1265 | transmit_error_response (connection, |
1268 | MHD_HTTP_BAD_REQUEST, | 1266 | MHD_HTTP_BAD_REQUEST, REQUEST_MALFORMED); |
1269 | REQUEST_MALFORMED); | 1267 | return MHD_NO; |
1270 | return MHD_NO; | 1268 | } |
1271 | } | ||
1272 | } | 1269 | } |
1273 | return MHD_YES; | 1270 | return MHD_YES; |
1274 | } | 1271 | } |
@@ -1638,16 +1635,16 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
1638 | case MHD_CONNECTION_INIT: | 1635 | case MHD_CONNECTION_INIT: |
1639 | line = get_next_header_line (connection); | 1636 | line = get_next_header_line (connection); |
1640 | if (line == NULL) | 1637 | if (line == NULL) |
1641 | { | 1638 | { |
1642 | if (connection->state != MHD_CONNECTION_INIT) | 1639 | if (connection->state != MHD_CONNECTION_INIT) |
1643 | continue; | 1640 | continue; |
1644 | if (connection->read_closed) | 1641 | if (connection->read_closed) |
1645 | { | 1642 | { |
1646 | connection->state = MHD_CONNECTION_CLOSED; | 1643 | connection->state = MHD_CONNECTION_CLOSED; |
1647 | continue; | 1644 | continue; |
1648 | } | 1645 | } |
1649 | break; | 1646 | break; |
1650 | } | 1647 | } |
1651 | if (MHD_NO == parse_initial_message_line (connection, line)) | 1648 | if (MHD_NO == parse_initial_message_line (connection, line)) |
1652 | connection->state = MHD_CONNECTION_CLOSED; | 1649 | connection->state = MHD_CONNECTION_CLOSED; |
1653 | else | 1650 | else |
@@ -1656,46 +1653,46 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
1656 | case MHD_CONNECTION_URL_RECEIVED: | 1653 | case MHD_CONNECTION_URL_RECEIVED: |
1657 | line = get_next_header_line (connection); | 1654 | line = get_next_header_line (connection); |
1658 | if (line == NULL) | 1655 | if (line == NULL) |
1659 | { | 1656 | { |
1660 | if (connection->state != MHD_CONNECTION_URL_RECEIVED) | 1657 | if (connection->state != MHD_CONNECTION_URL_RECEIVED) |
1661 | continue; | 1658 | continue; |
1662 | if (connection->read_closed) | 1659 | if (connection->read_closed) |
1663 | { | 1660 | { |
1664 | connection->state = MHD_CONNECTION_CLOSED; | 1661 | connection->state = MHD_CONNECTION_CLOSED; |
1665 | continue; | 1662 | continue; |
1666 | } | 1663 | } |
1667 | break; | 1664 | break; |
1668 | } | 1665 | } |
1669 | if (strlen (line) == 0) | 1666 | if (strlen (line) == 0) |
1670 | { | 1667 | { |
1671 | connection->state = MHD_CONNECTION_HEADERS_RECEIVED; | 1668 | connection->state = MHD_CONNECTION_HEADERS_RECEIVED; |
1672 | continue; | 1669 | continue; |
1673 | } | 1670 | } |
1674 | if (MHD_NO == process_header_line (connection, line)) | 1671 | if (MHD_NO == process_header_line (connection, line)) |
1675 | { | 1672 | { |
1676 | transmit_error_response(connection, | 1673 | transmit_error_response (connection, |
1677 | MHD_HTTP_BAD_REQUEST, | 1674 | MHD_HTTP_BAD_REQUEST, |
1678 | REQUEST_MALFORMED); | 1675 | REQUEST_MALFORMED); |
1679 | break; | 1676 | break; |
1680 | } | 1677 | } |
1681 | connection->state = MHD_CONNECTION_HEADER_PART_RECEIVED; | 1678 | connection->state = MHD_CONNECTION_HEADER_PART_RECEIVED; |
1682 | continue; | 1679 | continue; |
1683 | case MHD_CONNECTION_HEADER_PART_RECEIVED: | 1680 | case MHD_CONNECTION_HEADER_PART_RECEIVED: |
1684 | line = get_next_header_line (connection); | 1681 | line = get_next_header_line (connection); |
1685 | if (line == NULL) | 1682 | if (line == NULL) |
1686 | { | 1683 | { |
1687 | if (connection->state != MHD_CONNECTION_HEADER_PART_RECEIVED) | 1684 | if (connection->state != MHD_CONNECTION_HEADER_PART_RECEIVED) |
1688 | continue; | 1685 | continue; |
1689 | if (connection->read_closed) | 1686 | if (connection->read_closed) |
1690 | { | 1687 | { |
1691 | connection->state = MHD_CONNECTION_CLOSED; | 1688 | connection->state = MHD_CONNECTION_CLOSED; |
1692 | continue; | 1689 | continue; |
1693 | } | 1690 | } |
1694 | break; | 1691 | break; |
1695 | } | 1692 | } |
1696 | if (MHD_NO == | 1693 | if (MHD_NO == |
1697 | process_broken_line (connection, line, MHD_HEADER_KIND)) | 1694 | process_broken_line (connection, line, MHD_HEADER_KIND)) |
1698 | continue; | 1695 | continue; |
1699 | if (strlen (line) == 0) | 1696 | if (strlen (line) == 0) |
1700 | { | 1697 | { |
1701 | connection->state = MHD_CONNECTION_HEADERS_RECEIVED; | 1698 | connection->state = MHD_CONNECTION_HEADERS_RECEIVED; |
@@ -1751,46 +1748,46 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
1751 | case MHD_CONNECTION_BODY_RECEIVED: | 1748 | case MHD_CONNECTION_BODY_RECEIVED: |
1752 | line = get_next_header_line (connection); | 1749 | line = get_next_header_line (connection); |
1753 | if (line == NULL) | 1750 | if (line == NULL) |
1754 | { | 1751 | { |
1755 | if (connection->state != MHD_CONNECTION_BODY_RECEIVED) | 1752 | if (connection->state != MHD_CONNECTION_BODY_RECEIVED) |
1756 | continue; | 1753 | continue; |
1757 | if (connection->read_closed) | 1754 | if (connection->read_closed) |
1758 | { | 1755 | { |
1759 | connection->state = MHD_CONNECTION_CLOSED; | 1756 | connection->state = MHD_CONNECTION_CLOSED; |
1760 | continue; | 1757 | continue; |
1761 | } | 1758 | } |
1762 | break; | 1759 | break; |
1763 | } | 1760 | } |
1764 | if (strlen (line) == 0) | 1761 | if (strlen (line) == 0) |
1765 | { | 1762 | { |
1766 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; | 1763 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; |
1767 | continue; | 1764 | continue; |
1768 | } | 1765 | } |
1769 | if (MHD_NO == process_header_line (connection, line)) | 1766 | if (MHD_NO == process_header_line (connection, line)) |
1770 | { | 1767 | { |
1771 | transmit_error_response(connection, | 1768 | transmit_error_response (connection, |
1772 | MHD_HTTP_BAD_REQUEST, | 1769 | MHD_HTTP_BAD_REQUEST, |
1773 | REQUEST_MALFORMED); | 1770 | REQUEST_MALFORMED); |
1774 | break; | 1771 | break; |
1775 | } | 1772 | } |
1776 | connection->state = MHD_CONNECTION_FOOTER_PART_RECEIVED; | 1773 | connection->state = MHD_CONNECTION_FOOTER_PART_RECEIVED; |
1777 | continue; | 1774 | continue; |
1778 | case MHD_CONNECTION_FOOTER_PART_RECEIVED: | 1775 | case MHD_CONNECTION_FOOTER_PART_RECEIVED: |
1779 | line = get_next_header_line (connection); | 1776 | line = get_next_header_line (connection); |
1780 | if (line == NULL) | 1777 | if (line == NULL) |
1781 | { | 1778 | { |
1782 | if (connection->state != MHD_CONNECTION_FOOTER_PART_RECEIVED) | 1779 | if (connection->state != MHD_CONNECTION_FOOTER_PART_RECEIVED) |
1783 | continue; | 1780 | continue; |
1784 | if (connection->read_closed) | 1781 | if (connection->read_closed) |
1785 | { | 1782 | { |
1786 | connection->state = MHD_CONNECTION_CLOSED; | 1783 | connection->state = MHD_CONNECTION_CLOSED; |
1787 | continue; | 1784 | continue; |
1788 | } | 1785 | } |
1789 | break; | 1786 | break; |
1790 | } | 1787 | } |
1791 | if (MHD_NO == | 1788 | if (MHD_NO == |
1792 | process_broken_line (connection, line, MHD_FOOTER_KIND)) | 1789 | process_broken_line (connection, line, MHD_FOOTER_KIND)) |
1793 | continue; | 1790 | continue; |
1794 | if (strlen (line) == 0) | 1791 | if (strlen (line) == 0) |
1795 | { | 1792 | { |
1796 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; | 1793 | connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; |
diff --git a/src/testcurl/daemontest_get_chunked.c b/src/testcurl/daemontest_get_chunked.c index ba8550b7..e88c86ad 100644 --- a/src/testcurl/daemontest_get_chunked.c +++ b/src/testcurl/daemontest_get_chunked.c | |||
@@ -353,7 +353,7 @@ main (int argc, char *const *argv) | |||
353 | return 2; | 353 | return 2; |
354 | errorCount += testInternalGet (); | 354 | errorCount += testInternalGet (); |
355 | errorCount += testMultithreadedGet (); | 355 | errorCount += testMultithreadedGet (); |
356 | errorCount += testExternalGet (); | 356 | errorCount += testExternalGet (); |
357 | if (errorCount != 0) | 357 | if (errorCount != 0) |
358 | fprintf (stderr, "Error (code: %u)\n", errorCount); | 358 | fprintf (stderr, "Error (code: %u)\n", errorCount); |
359 | curl_global_cleanup (); | 359 | curl_global_cleanup (); |
diff --git a/src/testcurl/daemontest_long_header.c b/src/testcurl/daemontest_long_header.c index bfdc02e8..385b9776 100644 --- a/src/testcurl/daemontest_long_header.c +++ b/src/testcurl/daemontest_long_header.c | |||
@@ -99,7 +99,7 @@ testLongUrlGet () | |||
99 | cbc.buf = buf; | 99 | cbc.buf = buf; |
100 | cbc.size = 2048; | 100 | cbc.size = 2048; |
101 | cbc.pos = 0; | 101 | cbc.pos = 0; |
102 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */, | 102 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */ , |
103 | 1080, | 103 | 1080, |
104 | &apc_all, | 104 | &apc_all, |
105 | NULL, | 105 | NULL, |
@@ -219,7 +219,7 @@ testLongHeaderGet () | |||
219 | MHD_stop_daemon (d); | 219 | MHD_stop_daemon (d); |
220 | free (url); | 220 | free (url); |
221 | if (code != MHD_HTTP_REQUEST_ENTITY_TOO_LARGE) | 221 | if (code != MHD_HTTP_REQUEST_ENTITY_TOO_LARGE) |
222 | return 128; | 222 | return 128; |
223 | return 0; | 223 | return 0; |
224 | } | 224 | } |
225 | 225 | ||
diff --git a/src/testzzuf/daemontest_get.c b/src/testzzuf/daemontest_get.c index d7b11f3e..ac43f75e 100644 --- a/src/testzzuf/daemontest_get.c +++ b/src/testzzuf/daemontest_get.c | |||
@@ -112,33 +112,34 @@ testInternalGet () | |||
112 | cbc.buf = buf; | 112 | cbc.buf = buf; |
113 | cbc.size = 2048; | 113 | cbc.size = 2048; |
114 | cbc.pos = 0; | 114 | cbc.pos = 0; |
115 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */, | 115 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */ , |
116 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 116 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
117 | if (d == NULL) | 117 | if (d == NULL) |
118 | return 1; | 118 | return 1; |
119 | zzuf_socat_start(); | 119 | zzuf_socat_start (); |
120 | for (i=0;i<LOOP_COUNT;i++) { | 120 | for (i = 0; i < LOOP_COUNT; i++) |
121 | fprintf(stderr, "."); | 121 | { |
122 | c = curl_easy_init (); | 122 | fprintf (stderr, "."); |
123 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 123 | c = curl_easy_init (); |
124 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 124 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
125 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 125 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
126 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 126 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
127 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 127 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
128 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 128 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
129 | if (oneone) | 129 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
130 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 130 | if (oneone) |
131 | else | 131 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
132 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | 132 | else |
133 | // NOTE: use of CONNECTTIMEOUT without also | 133 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
134 | // setting NOSIGNAL results in really weird | 134 | // NOTE: use of CONNECTTIMEOUT without also |
135 | // crashes on my system! | 135 | // setting NOSIGNAL results in really weird |
136 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 136 | // crashes on my system! |
137 | curl_easy_perform (c); | 137 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
138 | curl_easy_cleanup (c); | 138 | curl_easy_perform (c); |
139 | } | 139 | curl_easy_cleanup (c); |
140 | fprintf(stderr, "\n"); | 140 | } |
141 | zzuf_socat_stop(); | 141 | fprintf (stderr, "\n"); |
142 | zzuf_socat_stop (); | ||
142 | MHD_stop_daemon (d); | 143 | MHD_stop_daemon (d); |
143 | return 0; | 144 | return 0; |
144 | } | 145 | } |
@@ -155,33 +156,34 @@ testMultithreadedGet () | |||
155 | cbc.buf = buf; | 156 | cbc.buf = buf; |
156 | cbc.size = 2048; | 157 | cbc.size = 2048; |
157 | cbc.pos = 0; | 158 | cbc.pos = 0; |
158 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION /* | MHD_USE_DEBUG */, | 159 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION /* | MHD_USE_DEBUG */ , |
159 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 160 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
160 | if (d == NULL) | 161 | if (d == NULL) |
161 | return 16; | 162 | return 16; |
162 | zzuf_socat_start(); | 163 | zzuf_socat_start (); |
163 | for (i=0;i<LOOP_COUNT;i++) { | 164 | for (i = 0; i < LOOP_COUNT; i++) |
164 | fprintf(stderr, "."); | 165 | { |
165 | c = curl_easy_init (); | 166 | fprintf (stderr, "."); |
166 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 167 | c = curl_easy_init (); |
167 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 168 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
168 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 169 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
169 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 170 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
170 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 171 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
171 | if (oneone) | 172 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
172 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 173 | if (oneone) |
173 | else | 174 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
174 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | 175 | else |
175 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 176 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
176 | // NOTE: use of CONNECTTIMEOUT without also | 177 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
177 | // setting NOSIGNAL results in really weird | 178 | // NOTE: use of CONNECTTIMEOUT without also |
178 | // crashes on my system! | 179 | // setting NOSIGNAL results in really weird |
179 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 180 | // crashes on my system! |
180 | curl_easy_perform (c); | 181 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
181 | curl_easy_cleanup (c); | 182 | curl_easy_perform (c); |
182 | } | 183 | curl_easy_cleanup (c); |
183 | fprintf(stderr, "\n"); | 184 | } |
184 | zzuf_socat_stop(); | 185 | fprintf (stderr, "\n"); |
186 | zzuf_socat_stop (); | ||
185 | MHD_stop_daemon (d); | 187 | MHD_stop_daemon (d); |
186 | return 0; | 188 | return 0; |
187 | } | 189 | } |
@@ -209,7 +211,7 @@ testExternalGet () | |||
209 | cbc.buf = buf; | 211 | cbc.buf = buf; |
210 | cbc.size = 2048; | 212 | cbc.size = 2048; |
211 | cbc.pos = 0; | 213 | cbc.pos = 0; |
212 | d = MHD_start_daemon (MHD_NO_FLAG /* | MHD_USE_DEBUG*/, | 214 | d = MHD_start_daemon (MHD_NO_FLAG /* | MHD_USE_DEBUG */ , |
213 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 215 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
214 | if (d == NULL) | 216 | if (d == NULL) |
215 | return 256; | 217 | return 256; |
@@ -220,82 +222,83 @@ testExternalGet () | |||
220 | MHD_stop_daemon (d); | 222 | MHD_stop_daemon (d); |
221 | return 512; | 223 | return 512; |
222 | } | 224 | } |
223 | zzuf_socat_start(); | 225 | zzuf_socat_start (); |
224 | for (i=0;i<LOOP_COUNT;i++) { | 226 | for (i = 0; i < LOOP_COUNT; i++) |
225 | fprintf(stderr, "."); | 227 | { |
226 | c = curl_easy_init (); | 228 | fprintf (stderr, "."); |
227 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 229 | c = curl_easy_init (); |
228 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 230 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
229 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 231 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
230 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 232 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
231 | if (oneone) | 233 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
232 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 234 | if (oneone) |
233 | else | 235 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
234 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | 236 | else |
235 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 237 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
236 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 238 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
237 | // NOTE: use of CONNECTTIMEOUT without also | 239 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
238 | // setting NOSIGNAL results in really weird | 240 | // NOTE: use of CONNECTTIMEOUT without also |
239 | // crashes on my system! | 241 | // setting NOSIGNAL results in really weird |
240 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 242 | // crashes on my system! |
241 | mret = curl_multi_add_handle (multi, c); | 243 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
242 | if (mret != CURLM_OK) | 244 | mret = curl_multi_add_handle (multi, c); |
243 | { | 245 | if (mret != CURLM_OK) |
244 | curl_multi_cleanup (multi); | 246 | { |
245 | curl_easy_cleanup (c); | 247 | curl_multi_cleanup (multi); |
246 | zzuf_socat_stop(); | 248 | curl_easy_cleanup (c); |
247 | MHD_stop_daemon (d); | 249 | zzuf_socat_stop (); |
248 | return 1024; | 250 | MHD_stop_daemon (d); |
249 | } | 251 | return 1024; |
250 | start = time (NULL); | 252 | } |
251 | while ((time (NULL) - start < 5) && (c != NULL)) | 253 | start = time (NULL); |
252 | { | 254 | while ((time (NULL) - start < 5) && (c != NULL)) |
253 | max = 0; | 255 | { |
254 | FD_ZERO (&rs); | 256 | max = 0; |
255 | FD_ZERO (&ws); | 257 | FD_ZERO (&rs); |
256 | FD_ZERO (&es); | 258 | FD_ZERO (&ws); |
257 | curl_multi_perform (multi, &running); | 259 | FD_ZERO (&es); |
258 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); | 260 | curl_multi_perform (multi, &running); |
259 | if (mret != CURLM_OK) | 261 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); |
260 | { | 262 | if (mret != CURLM_OK) |
261 | curl_multi_remove_handle (multi, c); | 263 | { |
262 | curl_multi_cleanup (multi); | 264 | curl_multi_remove_handle (multi, c); |
263 | curl_easy_cleanup (c); | 265 | curl_multi_cleanup (multi); |
264 | zzuf_socat_stop(); | 266 | curl_easy_cleanup (c); |
265 | MHD_stop_daemon (d); | 267 | zzuf_socat_stop (); |
266 | return 2048; | 268 | MHD_stop_daemon (d); |
267 | } | 269 | return 2048; |
268 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) | 270 | } |
269 | { | 271 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) |
270 | curl_multi_remove_handle (multi, c); | 272 | { |
271 | curl_multi_cleanup (multi); | 273 | curl_multi_remove_handle (multi, c); |
272 | curl_easy_cleanup (c); | 274 | curl_multi_cleanup (multi); |
273 | zzuf_socat_stop(); | 275 | curl_easy_cleanup (c); |
274 | MHD_stop_daemon (d); | 276 | zzuf_socat_stop (); |
275 | return 4096; | 277 | MHD_stop_daemon (d); |
276 | } | 278 | return 4096; |
277 | tv.tv_sec = 0; | 279 | } |
278 | tv.tv_usec = 1000; | 280 | tv.tv_sec = 0; |
279 | select (max + 1, &rs, &ws, &es, &tv); | 281 | tv.tv_usec = 1000; |
280 | curl_multi_perform (multi, &running); | 282 | select (max + 1, &rs, &ws, &es, &tv); |
281 | if (running == 0) | 283 | curl_multi_perform (multi, &running); |
282 | { | 284 | if (running == 0) |
283 | curl_multi_info_read (multi, &running); | 285 | { |
284 | curl_multi_remove_handle (multi, c); | 286 | curl_multi_info_read (multi, &running); |
285 | curl_easy_cleanup (c); | 287 | curl_multi_remove_handle (multi, c); |
286 | c = NULL; | 288 | curl_easy_cleanup (c); |
287 | } | 289 | c = NULL; |
288 | MHD_run (d); | 290 | } |
289 | } | 291 | MHD_run (d); |
290 | if (c != NULL) | 292 | } |
291 | { | 293 | if (c != NULL) |
292 | curl_multi_remove_handle (multi, c); | 294 | { |
293 | curl_easy_cleanup (c); | 295 | curl_multi_remove_handle (multi, c); |
294 | } | 296 | curl_easy_cleanup (c); |
295 | } | 297 | } |
296 | fprintf(stderr, "\n"); | 298 | } |
299 | fprintf (stderr, "\n"); | ||
297 | curl_multi_cleanup (multi); | 300 | curl_multi_cleanup (multi); |
298 | zzuf_socat_stop(); | 301 | zzuf_socat_stop (); |
299 | MHD_stop_daemon (d); | 302 | MHD_stop_daemon (d); |
300 | return 0; | 303 | return 0; |
301 | } | 304 | } |
@@ -312,7 +315,7 @@ main (int argc, char *const *argv) | |||
312 | return 2; | 315 | return 2; |
313 | errorCount += testInternalGet (); | 316 | errorCount += testInternalGet (); |
314 | errorCount += testMultithreadedGet (); | 317 | errorCount += testMultithreadedGet (); |
315 | errorCount += testExternalGet (); | 318 | errorCount += testExternalGet (); |
316 | if (errorCount != 0) | 319 | if (errorCount != 0) |
317 | fprintf (stderr, "Error (code: %u)\n", errorCount); | 320 | fprintf (stderr, "Error (code: %u)\n", errorCount); |
318 | curl_global_cleanup (); | 321 | curl_global_cleanup (); |
diff --git a/src/testzzuf/daemontest_get_chunked.c b/src/testzzuf/daemontest_get_chunked.c index 4110d874..ca94beb0 100644 --- a/src/testzzuf/daemontest_get_chunked.c +++ b/src/testzzuf/daemontest_get_chunked.c | |||
@@ -139,30 +139,31 @@ testInternalGet () | |||
139 | cbc.buf = buf; | 139 | cbc.buf = buf; |
140 | cbc.size = 2048; | 140 | cbc.size = 2048; |
141 | cbc.pos = 0; | 141 | cbc.pos = 0; |
142 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */, | 142 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */ , |
143 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 143 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
144 | if (d == NULL) | 144 | if (d == NULL) |
145 | return 1; | 145 | return 1; |
146 | zzuf_socat_start(); | 146 | zzuf_socat_start (); |
147 | for (i=0;i<LOOP_COUNT;i++) { | 147 | for (i = 0; i < LOOP_COUNT; i++) |
148 | fprintf(stderr, "."); | 148 | { |
149 | c = curl_easy_init (); | 149 | fprintf (stderr, "."); |
150 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 150 | c = curl_easy_init (); |
151 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 151 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
152 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 152 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
153 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 153 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
154 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 154 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
155 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 155 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
156 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 156 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
157 | // NOTE: use of CONNECTTIMEOUT without also | 157 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
158 | // setting NOSIGNAL results in really weird | 158 | // NOTE: use of CONNECTTIMEOUT without also |
159 | // crashes on my system! | 159 | // setting NOSIGNAL results in really weird |
160 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 160 | // crashes on my system! |
161 | curl_easy_perform (c); | 161 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
162 | curl_easy_cleanup (c); | 162 | curl_easy_perform (c); |
163 | } | 163 | curl_easy_cleanup (c); |
164 | fprintf(stderr, "\n"); | 164 | } |
165 | zzuf_socat_stop(); | 165 | fprintf (stderr, "\n"); |
166 | zzuf_socat_stop (); | ||
166 | MHD_stop_daemon (d); | 167 | MHD_stop_daemon (d); |
167 | return 0; | 168 | return 0; |
168 | } | 169 | } |
@@ -175,34 +176,35 @@ testMultithreadedGet () | |||
175 | char buf[2048]; | 176 | char buf[2048]; |
176 | struct CBC cbc; | 177 | struct CBC cbc; |
177 | int i; | 178 | int i; |
178 | 179 | ||
179 | cbc.buf = buf; | 180 | cbc.buf = buf; |
180 | cbc.size = 2048; | 181 | cbc.size = 2048; |
181 | cbc.pos = 0; | 182 | cbc.pos = 0; |
182 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION /* | MHD_USE_DEBUG */, | 183 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION /* | MHD_USE_DEBUG */ , |
183 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 184 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
184 | if (d == NULL) | 185 | if (d == NULL) |
185 | return 16; | 186 | return 16; |
186 | zzuf_socat_start(); | 187 | zzuf_socat_start (); |
187 | for (i=0;i<LOOP_COUNT;i++) { | 188 | for (i = 0; i < LOOP_COUNT; i++) |
188 | fprintf(stderr, "."); | 189 | { |
189 | c = curl_easy_init (); | 190 | fprintf (stderr, "."); |
190 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 191 | c = curl_easy_init (); |
191 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 192 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
192 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 193 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
193 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 194 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
194 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 195 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
195 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 196 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
196 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 197 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
197 | // NOTE: use of CONNECTTIMEOUT without also | 198 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
198 | // setting NOSIGNAL results in really weird | 199 | // NOTE: use of CONNECTTIMEOUT without also |
199 | // crashes on my system! | 200 | // setting NOSIGNAL results in really weird |
200 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 201 | // crashes on my system! |
201 | curl_easy_perform (c); | 202 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
202 | curl_easy_cleanup (c); | 203 | curl_easy_perform (c); |
203 | } | 204 | curl_easy_cleanup (c); |
204 | fprintf(stderr, "\n"); | 205 | } |
205 | zzuf_socat_stop(); | 206 | fprintf (stderr, "\n"); |
207 | zzuf_socat_stop (); | ||
206 | MHD_stop_daemon (d); | 208 | MHD_stop_daemon (d); |
207 | return 0; | 209 | return 0; |
208 | } | 210 | } |
@@ -230,7 +232,7 @@ testExternalGet () | |||
230 | cbc.buf = buf; | 232 | cbc.buf = buf; |
231 | cbc.size = 2048; | 233 | cbc.size = 2048; |
232 | cbc.pos = 0; | 234 | cbc.pos = 0; |
233 | d = MHD_start_daemon (MHD_NO_FLAG /* | MHD_USE_DEBUG */, | 235 | d = MHD_start_daemon (MHD_NO_FLAG /* | MHD_USE_DEBUG */ , |
234 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 236 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
235 | if (d == NULL) | 237 | if (d == NULL) |
236 | return 256; | 238 | return 256; |
@@ -241,79 +243,80 @@ testExternalGet () | |||
241 | MHD_stop_daemon (d); | 243 | MHD_stop_daemon (d); |
242 | return 512; | 244 | return 512; |
243 | } | 245 | } |
244 | zzuf_socat_start(); | 246 | zzuf_socat_start (); |
245 | for (i=0;i<LOOP_COUNT;i++) { | 247 | for (i = 0; i < LOOP_COUNT; i++) |
246 | fprintf(stderr, "."); | 248 | { |
247 | c = curl_easy_init (); | 249 | fprintf (stderr, "."); |
248 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 250 | c = curl_easy_init (); |
249 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 251 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
250 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 252 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
251 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 253 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
252 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 254 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
253 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 255 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
254 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 256 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
255 | // NOTE: use of CONNECTTIMEOUT without also | 257 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
256 | // setting NOSIGNAL results in really weird | 258 | // NOTE: use of CONNECTTIMEOUT without also |
257 | // crashes on my system! | 259 | // setting NOSIGNAL results in really weird |
258 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 260 | // crashes on my system! |
259 | mret = curl_multi_add_handle (multi, c); | 261 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
260 | if (mret != CURLM_OK) | 262 | mret = curl_multi_add_handle (multi, c); |
261 | { | 263 | if (mret != CURLM_OK) |
262 | curl_multi_cleanup (multi); | 264 | { |
263 | curl_easy_cleanup (c); | 265 | curl_multi_cleanup (multi); |
264 | zzuf_socat_stop(); | 266 | curl_easy_cleanup (c); |
265 | MHD_stop_daemon (d); | 267 | zzuf_socat_stop (); |
266 | return 1024; | 268 | MHD_stop_daemon (d); |
267 | } | 269 | return 1024; |
268 | start = time (NULL); | 270 | } |
269 | while ((time (NULL) - start < 5) && (c != NULL)) | 271 | start = time (NULL); |
270 | { | 272 | while ((time (NULL) - start < 5) && (c != NULL)) |
271 | max = 0; | 273 | { |
272 | FD_ZERO (&rs); | 274 | max = 0; |
273 | FD_ZERO (&ws); | 275 | FD_ZERO (&rs); |
274 | FD_ZERO (&es); | 276 | FD_ZERO (&ws); |
275 | curl_multi_perform (multi, &running); | 277 | FD_ZERO (&es); |
276 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); | 278 | curl_multi_perform (multi, &running); |
277 | if (mret != CURLM_OK) | 279 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); |
278 | { | 280 | if (mret != CURLM_OK) |
279 | curl_multi_remove_handle (multi, c); | 281 | { |
280 | curl_multi_cleanup (multi); | 282 | curl_multi_remove_handle (multi, c); |
281 | curl_easy_cleanup (c); | 283 | curl_multi_cleanup (multi); |
282 | zzuf_socat_stop(); | 284 | curl_easy_cleanup (c); |
283 | MHD_stop_daemon (d); | 285 | zzuf_socat_stop (); |
284 | return 2048; | 286 | MHD_stop_daemon (d); |
285 | } | 287 | return 2048; |
286 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) | 288 | } |
287 | { | 289 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) |
288 | curl_multi_remove_handle (multi, c); | 290 | { |
289 | curl_multi_cleanup (multi); | 291 | curl_multi_remove_handle (multi, c); |
290 | curl_easy_cleanup (c); | 292 | curl_multi_cleanup (multi); |
291 | zzuf_socat_stop(); | 293 | curl_easy_cleanup (c); |
292 | MHD_stop_daemon (d); | 294 | zzuf_socat_stop (); |
293 | return 4096; | 295 | MHD_stop_daemon (d); |
294 | } | 296 | return 4096; |
295 | tv.tv_sec = 0; | 297 | } |
296 | tv.tv_usec = 1000; | 298 | tv.tv_sec = 0; |
297 | select (max + 1, &rs, &ws, &es, &tv); | 299 | tv.tv_usec = 1000; |
298 | curl_multi_perform (multi, &running); | 300 | select (max + 1, &rs, &ws, &es, &tv); |
299 | if (running == 0) | 301 | curl_multi_perform (multi, &running); |
300 | { | 302 | if (running == 0) |
301 | curl_multi_info_read (multi, &running); | 303 | { |
302 | curl_multi_remove_handle (multi, c); | 304 | curl_multi_info_read (multi, &running); |
303 | curl_easy_cleanup (c); | 305 | curl_multi_remove_handle (multi, c); |
304 | c = NULL; | 306 | curl_easy_cleanup (c); |
305 | } | 307 | c = NULL; |
306 | MHD_run (d); | 308 | } |
307 | } | 309 | MHD_run (d); |
308 | if (c != NULL) | 310 | } |
309 | { | 311 | if (c != NULL) |
310 | curl_multi_remove_handle (multi, c); | 312 | { |
311 | curl_easy_cleanup (c); | 313 | curl_multi_remove_handle (multi, c); |
312 | } | 314 | curl_easy_cleanup (c); |
313 | } | 315 | } |
314 | fprintf(stderr, "\n"); | 316 | } |
317 | fprintf (stderr, "\n"); | ||
315 | curl_multi_cleanup (multi); | 318 | curl_multi_cleanup (multi); |
316 | zzuf_socat_stop(); | 319 | zzuf_socat_stop (); |
317 | MHD_stop_daemon (d); | 320 | MHD_stop_daemon (d); |
318 | return 0; | 321 | return 0; |
319 | } | 322 | } |
diff --git a/src/testzzuf/daemontest_large_put.c b/src/testzzuf/daemontest_large_put.c index b0c7bf37..72399c72 100644 --- a/src/testzzuf/daemontest_large_put.c +++ b/src/testzzuf/daemontest_large_put.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | (C) 2007 Christian Grothoff | 3 | (C) 2007, 2008 Christian Grothoff |
4 | 4 | ||
5 | libmicrohttpd is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -35,6 +35,18 @@ | |||
35 | #include <unistd.h> | 35 | #include <unistd.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include "socat.c" | ||
39 | |||
40 | /** | ||
41 | * A larger loop count will run more random tests -- | ||
42 | * which would be good, except that it may take too | ||
43 | * long for most user's patience. So this small | ||
44 | * value is the default. | ||
45 | */ | ||
46 | #define LOOP_COUNT 10 | ||
47 | |||
48 | #define CURL_TIMEOUT 50L | ||
49 | |||
38 | static int oneone; | 50 | static int oneone; |
39 | 51 | ||
40 | /** | 52 | /** |
@@ -133,8 +145,8 @@ testInternalPut () | |||
133 | struct CBC cbc; | 145 | struct CBC cbc; |
134 | unsigned int pos = 0; | 146 | unsigned int pos = 0; |
135 | int done_flag = 0; | 147 | int done_flag = 0; |
136 | CURLcode errornum; | ||
137 | char buf[2048]; | 148 | char buf[2048]; |
149 | int i; | ||
138 | 150 | ||
139 | cbc.buf = buf; | 151 | cbc.buf = buf; |
140 | cbc.size = 2048; | 152 | cbc.size = 2048; |
@@ -144,40 +156,34 @@ testInternalPut () | |||
144 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); | 156 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); |
145 | if (d == NULL) | 157 | if (d == NULL) |
146 | return 1; | 158 | return 1; |
147 | c = curl_easy_init (); | 159 | for (i = 0; i < LOOP_COUNT; i++) |
148 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1080/hello_world"); | ||
149 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
150 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
151 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | ||
152 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | ||
153 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | ||
154 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | ||
155 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
156 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); | ||
157 | if (oneone) | ||
158 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
159 | else | ||
160 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
161 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); | ||
162 | // NOTE: use of CONNECTTIMEOUT without also | ||
163 | // setting NOSIGNAL results in really weird | ||
164 | // crashes on my system! | ||
165 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
166 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | ||
167 | { | 160 | { |
168 | fprintf (stderr, | 161 | fprintf (stderr, "."); |
169 | "curl_easy_perform failed: `%s'\n", | 162 | |
170 | curl_easy_strerror (errornum)); | 163 | c = curl_easy_init (); |
164 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1080/hello_world"); | ||
165 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
166 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
167 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | ||
168 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | ||
169 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | ||
170 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | ||
171 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
172 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | ||
173 | if (oneone) | ||
174 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
175 | else | ||
176 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
177 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | ||
178 | // NOTE: use of CONNECTTIMEOUT without also | ||
179 | // setting NOSIGNAL results in really weird | ||
180 | // crashes on my system! | ||
181 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
182 | curl_easy_perform (c); | ||
171 | curl_easy_cleanup (c); | 183 | curl_easy_cleanup (c); |
172 | MHD_stop_daemon (d); | ||
173 | return 2; | ||
174 | } | 184 | } |
175 | curl_easy_cleanup (c); | 185 | fprintf (stderr, "\n"); |
176 | MHD_stop_daemon (d); | 186 | MHD_stop_daemon (d); |
177 | if (cbc.pos != strlen ("/hello_world")) | ||
178 | return 4; | ||
179 | if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) | ||
180 | return 8; | ||
181 | return 0; | 187 | return 0; |
182 | } | 188 | } |
183 | 189 | ||
diff --git a/src/testzzuf/socat.c b/src/testzzuf/socat.c index b8948575..0933010b 100644 --- a/src/testzzuf/socat.c +++ b/src/testzzuf/socat.c | |||
@@ -33,9 +33,10 @@ | |||
33 | static pid_t zzuf_pid; | 33 | static pid_t zzuf_pid; |
34 | 34 | ||
35 | static void | 35 | static void |
36 | zzuf_socat_start() { | 36 | zzuf_socat_start () |
37 | { | ||
37 | int status; | 38 | int status; |
38 | char * const args[] = { | 39 | char *const args[] = { |
39 | "zzuf", | 40 | "zzuf", |
40 | "--ratio=0.0:0.75", | 41 | "--ratio=0.0:0.75", |
41 | "-n", | 42 | "-n", |
@@ -45,54 +46,48 @@ zzuf_socat_start() { | |||
45 | "TCP4:127.0.0.1:11080", | 46 | "TCP4:127.0.0.1:11080", |
46 | NULL, | 47 | NULL, |
47 | }; | 48 | }; |
48 | zzuf_pid = fork(); | 49 | zzuf_pid = fork (); |
49 | if (zzuf_pid == -1) { | 50 | if (zzuf_pid == -1) |
50 | fprintf(stderr, | 51 | { |
51 | "fork failed: %s\n", | 52 | fprintf (stderr, "fork failed: %s\n", strerror (errno)); |
52 | strerror(errno)); | 53 | exit (1); |
53 | exit(1); | 54 | } |
54 | } | ||
55 | if (zzuf_pid != 0) | 55 | if (zzuf_pid != 0) |
56 | { | 56 | { |
57 | sleep(1); /* allow zzuf and socat to start */ | 57 | sleep (1); /* allow zzuf and socat to start */ |
58 | status = 0; | 58 | status = 0; |
59 | if (0 < waitpid(zzuf_pid, &status, WNOHANG)) | 59 | if (0 < waitpid (zzuf_pid, &status, WNOHANG)) |
60 | { | 60 | { |
61 | if (WIFEXITED(status)) | 61 | if (WIFEXITED (status)) |
62 | fprintf(stderr, | 62 | fprintf (stderr, |
63 | "zzuf died with status code %d!\n", | 63 | "zzuf died with status code %d!\n", |
64 | WEXITSTATUS(status)); | 64 | WEXITSTATUS (status)); |
65 | if (WIFSIGNALED(status)) | 65 | if (WIFSIGNALED (status)) |
66 | fprintf(stderr, | 66 | fprintf (stderr, |
67 | "zzuf died from signal %d!\n", | 67 | "zzuf died from signal %d!\n", WTERMSIG (status)); |
68 | WTERMSIG(status)); | 68 | exit (1); |
69 | exit(1); | 69 | } |
70 | } | ||
71 | return; | 70 | return; |
72 | } | 71 | } |
73 | setpgrp(); | 72 | setpgrp (); |
74 | execvp("zzuf", | 73 | execvp ("zzuf", args); |
75 | args); | 74 | fprintf (stderr, "execution of `zzuf' failed: %s\n", strerror (errno)); |
76 | fprintf(stderr, | 75 | zzuf_pid = 0; /* fork failed */ |
77 | "execution of `zzuf' failed: %s\n", | 76 | exit (1); |
78 | strerror(errno)); | ||
79 | zzuf_pid = 0; /* fork failed */ | ||
80 | exit(1); | ||
81 | } | 77 | } |
82 | 78 | ||
83 | 79 | ||
84 | static void | 80 | static void |
85 | zzuf_socat_stop() { | 81 | zzuf_socat_stop () |
82 | { | ||
86 | int status; | 83 | int status; |
87 | if (zzuf_pid != 0) | 84 | if (zzuf_pid != 0) |
88 | { | 85 | { |
89 | if (0 != killpg(zzuf_pid, SIGINT)) | 86 | if (0 != killpg (zzuf_pid, SIGINT)) |
90 | fprintf(stderr, | 87 | fprintf (stderr, "Failed to killpg: %s\n", strerror (errno)); |
91 | "Failed to killpg: %s\n", | 88 | kill (zzuf_pid, SIGINT); |
92 | strerror(errno)); | 89 | waitpid (zzuf_pid, &status, 0); |
93 | kill(zzuf_pid, SIGINT); | 90 | sleep (1); /* allow socat to also die in peace */ |
94 | waitpid(zzuf_pid, &status, 0); | ||
95 | sleep(1); /* allow socat to also die in peace */ | ||
96 | } | 91 | } |
97 | } | 92 | } |
98 | 93 | ||