aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/test_upgrade.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-03-02 21:45:17 +0100
committerChristian Grothoff <christian@grothoff.org>2018-03-02 21:45:26 +0100
commit0ebdff94d461abd4328cf45a6281c15139a045eb (patch)
treef87e851c2c1f519732787706ed4b90ab85f58b1f /src/microhttpd/test_upgrade.c
parent73532f78bb3a1a07c091ef7123b3ab49347c0b95 (diff)
downloadlibmicrohttpd-0ebdff94d461abd4328cf45a6281c15139a045eb.tar.gz
libmicrohttpd-0ebdff94d461abd4328cf45a6281c15139a045eb.zip
fix test_upgrade transient failures (#5189)
Diffstat (limited to 'src/microhttpd/test_upgrade.c')
-rw-r--r--src/microhttpd/test_upgrade.c92
1 files changed, 67 insertions, 25 deletions
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c
index 1b018ad4..6c26104e 100644
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@ -447,7 +447,8 @@ notify_completed_cb (void *cls,
447{ 447{
448 pthread_t* ppth = *con_cls; 448 pthread_t* ppth = *con_cls;
449 449
450 (void)cls; (void)connection; /* Unused. Silent compiler warning. */ 450 (void) cls;
451 (void) connection; /* Unused. Silent compiler warning. */
451 if ( (toe != MHD_REQUEST_TERMINATED_COMPLETED_OK) && 452 if ( (toe != MHD_REQUEST_TERMINATED_COMPLETED_OK) &&
452 (toe != MHD_REQUEST_TERMINATED_CLIENT_ABORT) && 453 (toe != MHD_REQUEST_TERMINATED_CLIENT_ABORT) &&
453 (toe != MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN) ) 454 (toe != MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN) )
@@ -474,13 +475,14 @@ log_cb (void *cls,
474 const char *uri, 475 const char *uri,
475 struct MHD_Connection *connection) 476 struct MHD_Connection *connection)
476{ 477{
477 pthread_t* ppth; 478 pthread_t *ppth;
478 (void)cls; (void)connection; /* Unused. Silent compiler warning. */
479 479
480 (void) cls;
481 (void) connection; /* Unused. Silent compiler warning. */
480 if (0 != strcmp (uri, 482 if (0 != strcmp (uri,
481 "/")) 483 "/"))
482 abort (); 484 abort ();
483 ppth = (pthread_t*) malloc (sizeof(pthread_t)); 485 ppth = malloc (sizeof (pthread_t));
484 if (NULL == ppth) 486 if (NULL == ppth)
485 abort(); 487 abort();
486 *ppth = pthread_self (); 488 *ppth = pthread_self ();
@@ -514,8 +516,9 @@ notify_connection_cb (void *cls,
514 enum MHD_ConnectionNotificationCode toe) 516 enum MHD_ConnectionNotificationCode toe)
515{ 517{
516 static int started; 518 static int started;
517 (void)cls; (void)connection; /* Unused. Silent compiler warning. */
518 519
520 (void) cls;
521 (void) connection; /* Unused. Silent compiler warning. */
519 switch (toe) 522 switch (toe)
520 { 523 {
521 case MHD_CONNECTION_NOTIFY_STARTED: 524 case MHD_CONNECTION_NOTIFY_STARTED:
@@ -773,7 +776,11 @@ upgrade_cb (void *cls,
773 MHD_socket sock, 776 MHD_socket sock,
774 struct MHD_UpgradeResponseHandle *urh) 777 struct MHD_UpgradeResponseHandle *urh)
775{ 778{
776 (void)cls; (void)connection; (void)con_cls; (void)extra_in; /* Unused. Silent compiler warning. */ 779 (void) cls;
780 (void) connection;
781 (void) con_cls;
782 (void) extra_in; /* Unused. Silent compiler warning. */
783
777 usock = wr_create_from_plain_sckt (sock); 784 usock = wr_create_from_plain_sckt (sock);
778 if (0 != extra_in_size) 785 if (0 != extra_in_size)
779 abort (); 786 abort ();
@@ -836,8 +843,12 @@ ahc_upgrade (void *cls,
836{ 843{
837 struct MHD_Response *resp; 844 struct MHD_Response *resp;
838 int ret; 845 int ret;
839 (void)cls;(void)url;(void)method; /* Unused. Silent compiler warning. */ 846 (void) cls;
840 (void)version;(void)upload_data;(void)upload_data_size; /* Unused. Silent compiler warning. */ 847 (void) url;
848 (void) method; /* Unused. Silent compiler warning. */
849 (void) version;
850 (void) upload_data;
851 (void) upload_data_size; /* Unused. Silent compiler warning. */
841 852
842 if (NULL == *con_cls) 853 if (NULL == *con_cls)
843 abort (); 854 abort ();
@@ -1061,7 +1072,8 @@ test_upgrade (int flags,
1061 { 1072 {
1062#if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID) 1073#if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID)
1063 MHD_socket tls_fork_sock; 1074 MHD_socket tls_fork_sock;
1064 if (-1 == (pid = gnutlscli_connect (&tls_fork_sock, dinfo->port))) 1075 if (-1 == (pid = gnutlscli_connect (&tls_fork_sock,
1076 dinfo->port)))
1065 { 1077 {
1066 MHD_stop_daemon (d); 1078 MHD_stop_daemon (d);
1067 return 4; 1079 return 4;
@@ -1105,7 +1117,8 @@ main (int argc,
1105 test_tls = has_in_name(argv[0], "_tls"); 1117 test_tls = has_in_name(argv[0], "_tls");
1106 1118
1107 verbose = 1; 1119 verbose = 1;
1108 if (has_param(argc, argv, "-q") || has_param(argc, argv, "--quiet")) 1120 if (has_param(argc, argv, "-q") ||
1121 has_param(argc, argv, "--quiet"))
1109 verbose = 0; 1122 verbose = 0;
1110 1123
1111 if (test_tls) 1124 if (test_tls)
@@ -1154,13 +1167,16 @@ main (int argc,
1154 1167
1155 /* run tests */ 1168 /* run tests */
1156 if (verbose) 1169 if (verbose)
1157 printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n", test_tls ? "TLS" : "plain"); 1170 printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n",
1171 test_tls ? "TLS" : "plain");
1158 /* try external select */ 1172 /* try external select */
1159 res = test_upgrade (0, 1173 res = test_upgrade (0,
1160 0); 1174 0);
1161 error_count += res; 1175 error_count += res;
1162 if (res) 1176 if (res)
1163 fprintf (stderr, "FAILED: Upgrade with external select, return code %d.\n", res); 1177 fprintf (stderr,
1178 "FAILED: Upgrade with external select, return code %d.\n",
1179 res);
1164 else if (verbose) 1180 else if (verbose)
1165 printf ("PASSED: Upgrade with external select.\n"); 1181 printf ("PASSED: Upgrade with external select.\n");
1166 1182
@@ -1169,7 +1185,9 @@ main (int argc,
1169 0); 1185 0);
1170 error_count += res; 1186 error_count += res;
1171 if (res) 1187 if (res)
1172 fprintf (stderr, "FAILED: Upgrade with external 'auto', return code %d.\n", res); 1188 fprintf (stderr,
1189 "FAILED: Upgrade with external 'auto', return code %d.\n",
1190 res);
1173 else if (verbose) 1191 else if (verbose)
1174 printf ("PASSED: Upgrade with external 'auto'.\n"); 1192 printf ("PASSED: Upgrade with external 'auto'.\n");
1175 1193
@@ -1178,7 +1196,9 @@ main (int argc,
1178 0); 1196 0);
1179 error_count += res; 1197 error_count += res;
1180 if (res) 1198 if (res)
1181 fprintf (stderr, "FAILED: Upgrade with external select with EPOLL, return code %d.\n", res); 1199 fprintf (stderr,
1200 "FAILED: Upgrade with external select with EPOLL, return code %d.\n",
1201 res);
1182 else if (verbose) 1202 else if (verbose)
1183 printf ("PASSED: Upgrade with external select with EPOLL.\n"); 1203 printf ("PASSED: Upgrade with external select with EPOLL.\n");
1184#endif 1204#endif
@@ -1188,7 +1208,9 @@ main (int argc,
1188 0); 1208 0);
1189 error_count += res; 1209 error_count += res;
1190 if (res) 1210 if (res)
1191 fprintf (stderr, "FAILED: Upgrade with thread per connection, return code %d.\n", res); 1211 fprintf (stderr,
1212 "FAILED: Upgrade with thread per connection, return code %d.\n",
1213 res);
1192 else if (verbose) 1214 else if (verbose)
1193 printf ("PASSED: Upgrade with thread per connection.\n"); 1215 printf ("PASSED: Upgrade with thread per connection.\n");
1194 1216
@@ -1196,7 +1218,9 @@ main (int argc,
1196 0); 1218 0);
1197 error_count += res; 1219 error_count += res;
1198 if (res) 1220 if (res)
1199 fprintf (stderr, "FAILED: Upgrade with thread per connection and 'auto', return code %d.\n", res); 1221 fprintf (stderr,
1222 "FAILED: Upgrade with thread per connection and 'auto', return code %d.\n",
1223 res);
1200 else if (verbose) 1224 else if (verbose)
1201 printf ("PASSED: Upgrade with thread per connection and 'auto'.\n"); 1225 printf ("PASSED: Upgrade with thread per connection and 'auto'.\n");
1202#ifdef HAVE_POLL 1226#ifdef HAVE_POLL
@@ -1204,7 +1228,9 @@ main (int argc,
1204 0); 1228 0);
1205 error_count += res; 1229 error_count += res;
1206 if (res) 1230 if (res)
1207 fprintf (stderr, "FAILED: Upgrade with thread per connection and poll, return code %d.\n", res); 1231 fprintf (stderr,
1232 "FAILED: Upgrade with thread per connection and poll, return code %d.\n",
1233 res);
1208 else if (verbose) 1234 else if (verbose)
1209 printf ("PASSED: Upgrade with thread per connection and poll.\n"); 1235 printf ("PASSED: Upgrade with thread per connection and poll.\n");
1210#endif /* HAVE_POLL */ 1236#endif /* HAVE_POLL */
@@ -1214,28 +1240,36 @@ main (int argc,
1214 0); 1240 0);
1215 error_count += res; 1241 error_count += res;
1216 if (res) 1242 if (res)
1217 fprintf (stderr, "FAILED: Upgrade with internal select, return code %d.\n", res); 1243 fprintf (stderr,
1244 "FAILED: Upgrade with internal select, return code %d.\n",
1245 res);
1218 else if (verbose) 1246 else if (verbose)
1219 printf ("PASSED: Upgrade with internal select.\n"); 1247 printf ("PASSED: Upgrade with internal select.\n");
1220 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD, 1248 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD,
1221 2); 1249 2);
1222 error_count += res; 1250 error_count += res;
1223 if (res) 1251 if (res)
1224 fprintf (stderr, "FAILED: Upgrade with internal select with thread pool, return code %d.\n", res); 1252 fprintf (stderr,
1253 "FAILED: Upgrade with internal select with thread pool, return code %d.\n",
1254 res);
1225 else if (verbose) 1255 else if (verbose)
1226 printf ("PASSED: Upgrade with internal select with thread pool.\n"); 1256 printf ("PASSED: Upgrade with internal select with thread pool.\n");
1227 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, 1257 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD,
1228 0); 1258 0);
1229 error_count += res; 1259 error_count += res;
1230 if (res) 1260 if (res)
1231 fprintf (stderr, "FAILED: Upgrade with internal 'auto' return code %d.\n", res); 1261 fprintf (stderr,
1262 "FAILED: Upgrade with internal 'auto' return code %d.\n",
1263 res);
1232 else if (verbose) 1264 else if (verbose)
1233 printf ("PASSED: Upgrade with internal 'auto'.\n"); 1265 printf ("PASSED: Upgrade with internal 'auto'.\n");
1234 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, 1266 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD,
1235 2); 1267 2);
1236 error_count += res; 1268 error_count += res;
1237 if (res) 1269 if (res)
1238 fprintf (stderr, "FAILED: Upgrade with internal 'auto' with thread pool, return code %d.\n", res); 1270 fprintf (stderr,
1271 "FAILED: Upgrade with internal 'auto' with thread pool, return code %d.\n",
1272 res);
1239 else if (verbose) 1273 else if (verbose)
1240 printf ("PASSED: Upgrade with internal 'auto' with thread pool.\n"); 1274 printf ("PASSED: Upgrade with internal 'auto' with thread pool.\n");
1241#ifdef HAVE_POLL 1275#ifdef HAVE_POLL
@@ -1243,13 +1277,17 @@ main (int argc,
1243 0); 1277 0);
1244 error_count += res; 1278 error_count += res;
1245 if (res) 1279 if (res)
1246 fprintf (stderr, "FAILED: Upgrade with internal poll, return code %d.\n", res); 1280 fprintf (stderr,
1281 "FAILED: Upgrade with internal poll, return code %d.\n",
1282 res);
1247 else if (verbose) 1283 else if (verbose)
1248 printf ("PASSED: Upgrade with internal poll.\n"); 1284 printf ("PASSED: Upgrade with internal poll.\n");
1249 res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD, 1285 res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD,
1250 2); 1286 2);
1251 if (res) 1287 if (res)
1252 fprintf (stderr, "FAILED: Upgrade with internal poll with thread pool, return code %d.\n", res); 1288 fprintf (stderr,
1289 "FAILED: Upgrade with internal poll with thread pool, return code %d.\n",
1290 res);
1253 else if (verbose) 1291 else if (verbose)
1254 printf ("PASSED: Upgrade with internal poll with thread pool.\n"); 1292 printf ("PASSED: Upgrade with internal poll with thread pool.\n");
1255#endif 1293#endif
@@ -1257,13 +1295,17 @@ main (int argc,
1257 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, 1295 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD,
1258 0); 1296 0);
1259 if (res) 1297 if (res)
1260 fprintf (stderr, "FAILED: Upgrade with internal epoll, return code %d.\n", res); 1298 fprintf (stderr,
1299 "FAILED: Upgrade with internal epoll, return code %d.\n",
1300 res);
1261 else if (verbose) 1301 else if (verbose)
1262 printf ("PASSED: Upgrade with internal epoll.\n"); 1302 printf ("PASSED: Upgrade with internal epoll.\n");
1263 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, 1303 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD,
1264 2); 1304 2);
1265 if (res) 1305 if (res)
1266 fprintf (stderr, "FAILED: Upgrade with internal epoll, return code %d.\n", res); 1306 fprintf (stderr,
1307 "FAILED: Upgrade with internal epoll, return code %d.\n",
1308 res);
1267 else if (verbose) 1309 else if (verbose)
1268 printf ("PASSED: Upgrade with internal epoll.\n"); 1310 printf ("PASSED: Upgrade with internal epoll.\n");
1269#endif 1311#endif