aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhil <phil.buschmann@tum.de>2018-01-11 10:21:52 +0100
committerPhil <phil.buschmann@tum.de>2018-01-11 10:21:52 +0100
commit60c963315271ce4314b708bef519eb4fb64f0979 (patch)
tree93e5b2a48279b32568531485eed21229b3c374c5 /src
parentafb2171eb752d82918048b393fda6f01f863b49a (diff)
parentbca8edf17fc90862e7267ff22b70a1b7dc94ec96 (diff)
downloadgnunet-60c963315271ce4314b708bef519eb4fb64f0979.tar.gz
gnunet-60c963315271ce4314b708bef519eb4fb64f0979.zip
Merge remote-tracking branch 'gnunet/master' into identity_oidc
Diffstat (limited to 'src')
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c10
-rw-r--r--src/fs/gnunet-service-fs_cp.c4
-rw-r--r--src/gns/gnunet-gns-proxy.c19
-rw-r--r--src/identity/plugin_rest_identity.c3
-rw-r--r--src/include/gnunet_crypto_lib.h2
-rw-r--r--src/rest/gnunet-rest-server.c49
-rw-r--r--src/rps/test_rps.c74
-rw-r--r--src/util/scheduler.c105
8 files changed, 172 insertions, 94 deletions
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index da78a03c4..05555e693 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -59,7 +59,10 @@
59 */ 59 */
60#define IDLE_PATH_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2) 60#define IDLE_PATH_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2)
61 61
62 62/**
63 * Queue size when we start dropping OOO messages.
64 */
65#define MAX_OOO_QUEUE_SIZE 100
63 66
64 67
65/** 68/**
@@ -1464,6 +1467,11 @@ GCP_send_ooo (struct CadetPeer *cp,
1464 GNUNET_MQ_discard (env); 1467 GNUNET_MQ_discard (env);
1465 return; 1468 return;
1466 } 1469 }
1470 if (GNUNET_MQ_get_length (cp->core_mq) > MAX_OOO_QUEUE_SIZE)
1471 {
1472 GNUNET_MQ_discard (env);
1473 return;
1474 }
1467 GNUNET_MQ_notify_sent (env, 1475 GNUNET_MQ_notify_sent (env,
1468 &mqm_send_done, 1476 &mqm_send_done,
1469 cp); 1477 cp);
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index 817aed257..6e28ca606 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -1230,7 +1230,9 @@ handle_p2p_get (void *cls,
1230 GNUNET_NO); 1230 GNUNET_NO);
1231 return; 1231 return;
1232 } 1232 }
1233 if (cp->ppd.pending_replies + cp->delay_queue_size > MAX_QUEUE_PER_PEER) 1233 unsigned int queue_size = GNUNET_MQ_get_length (cp->mq);
1234 queue_size += cp->ppd.pending_replies + cp->delay_queue_size;
1235 if (queue_size > MAX_QUEUE_PER_PEER)
1234 { 1236 {
1235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1237 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1236 "Peer `%s' has too many replies queued already. Dropping query.\n", 1238 "Peer `%s' has too many replies queued already. Dropping query.\n",
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 3af571eba..25092dcf0 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -1957,8 +1957,10 @@ mhd_log_callback (void *cls,
1957 } 1957 }
1958 s5r->url = GNUNET_strdup (url); 1958 s5r->url = GNUNET_strdup (url);
1959 if (NULL != s5r->timeout_task) 1959 if (NULL != s5r->timeout_task)
1960 {
1960 GNUNET_SCHEDULER_cancel (s5r->timeout_task); 1961 GNUNET_SCHEDULER_cancel (s5r->timeout_task);
1961 s5r->timeout_task = NULL; 1962 s5r->timeout_task = NULL;
1963 }
1962 GNUNET_assert (s5r->state == SOCKS5_SOCKET_WITH_MHD); 1964 GNUNET_assert (s5r->state == SOCKS5_SOCKET_WITH_MHD);
1963 return s5r; 1965 return s5r;
1964} 1966}
@@ -2060,7 +2062,10 @@ schedule_httpd (struct MhdHttpList *hd)
2060 wws = NULL; 2062 wws = NULL;
2061 } 2063 }
2062 if (NULL != hd->httpd_task) 2064 if (NULL != hd->httpd_task)
2065 {
2063 GNUNET_SCHEDULER_cancel (hd->httpd_task); 2066 GNUNET_SCHEDULER_cancel (hd->httpd_task);
2067 hd->httpd_task = NULL;
2068 }
2064 if ( (MHD_YES != haveto) && 2069 if ( (MHD_YES != haveto) &&
2065 (-1 == max) && 2070 (-1 == max) &&
2066 (hd != httpd) ) 2071 (hd != httpd) )
@@ -2108,8 +2113,7 @@ do_httpd (void *cls)
2108static void 2113static void
2109run_mhd_now (struct MhdHttpList *hd) 2114run_mhd_now (struct MhdHttpList *hd)
2110{ 2115{
2111 if (NULL != 2116 if (NULL != hd->httpd_task)
2112 hd->httpd_task)
2113 GNUNET_SCHEDULER_cancel (hd->httpd_task); 2117 GNUNET_SCHEDULER_cancel (hd->httpd_task);
2114 hd->httpd_task = GNUNET_SCHEDULER_add_now (&do_httpd, 2118 hd->httpd_task = GNUNET_SCHEDULER_add_now (&do_httpd,
2115 hd); 2119 hd);
@@ -2891,18 +2895,17 @@ do_accept (void *cls)
2891 struct GNUNET_NETWORK_Handle *s; 2895 struct GNUNET_NETWORK_Handle *s;
2892 struct Socks5Request *s5r; 2896 struct Socks5Request *s5r;
2893 2897
2894 if (lsock == lsock4) 2898 GNUNET_assert (NULL != lsock);
2895 ltask4 = NULL;
2896 else
2897 ltask6 = NULL;
2898 if (lsock == lsock4) 2899 if (lsock == lsock4)
2899 ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, 2900 ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
2900 lsock, 2901 lsock,
2901 &do_accept, lsock); 2902 &do_accept, lsock);
2902 else 2903 else if (lsock == lsock6)
2903 ltask6 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, 2904 ltask6 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
2904 lsock, 2905 lsock,
2905 &do_accept, lsock); 2906 &do_accept, lsock);
2907 else
2908 GNUNET_assert (0);
2906 s = GNUNET_NETWORK_socket_accept (lsock, NULL, NULL); 2909 s = GNUNET_NETWORK_socket_accept (lsock, NULL, NULL);
2907 if (NULL == s) 2910 if (NULL == s)
2908 { 2911 {
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index 33804143d..6044d0641 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -241,7 +241,10 @@ cleanup_handle (struct RequestHandle *handle)
241 if (NULL != handle->name) 241 if (NULL != handle->name)
242 GNUNET_free (handle->name); 242 GNUNET_free (handle->name);
243 if (NULL != handle->timeout_task) 243 if (NULL != handle->timeout_task)
244 {
244 GNUNET_SCHEDULER_cancel (handle->timeout_task); 245 GNUNET_SCHEDULER_cancel (handle->timeout_task);
246 handle->timeout_task = NULL;
247 }
245 if (NULL != handle->identity_handle) 248 if (NULL != handle->identity_handle)
246 GNUNET_IDENTITY_disconnect (handle->identity_handle); 249 GNUNET_IDENTITY_disconnect (handle->identity_handle);
247 if (NULL != handle->subsys) 250 if (NULL != handle->subsys)
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index e886a561c..f46afa6cc 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -363,7 +363,7 @@ struct GNUNET_CRYPTO_PaillierPublicKey
363 363
364 364
365/** 365/**
366 * Paillier public key. 366 * Paillier private key.
367 */ 367 */
368struct GNUNET_CRYPTO_PaillierPrivateKey 368struct GNUNET_CRYPTO_PaillierPrivateKey
369{ 369{
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c
index 5415937a7..c14b09819 100644
--- a/src/rest/gnunet-rest-server.c
+++ b/src/rest/gnunet-rest-server.c
@@ -154,11 +154,14 @@ do_httpd (void *cls);
154static void 154static void
155run_mhd_now () 155run_mhd_now ()
156{ 156{
157 if (NULL != 157 if (NULL != httpd_task)
158 httpd_task) 158 {
159 GNUNET_SCHEDULER_cancel (httpd_task); 159 GNUNET_SCHEDULER_cancel (httpd_task);
160 httpd_task = NULL;
161 }
160 httpd_task = GNUNET_SCHEDULER_add_now (&do_httpd, 162 httpd_task = GNUNET_SCHEDULER_add_now (&do_httpd,
161 NULL); 163 NULL);
164
162} 165}
163 166
164/** 167/**
@@ -449,7 +452,18 @@ kill_httpd ()
449 GNUNET_SCHEDULER_cancel (ltask6); 452 GNUNET_SCHEDULER_cancel (ltask6);
450 ltask6 = NULL; 453 ltask6 = NULL;
451 } 454 }
452} 455
456 if (NULL != lsock4)
457 {
458 GNUNET_NETWORK_socket_close (lsock4);
459 lsock4 = NULL;
460 }
461 if (NULL != lsock6)
462 {
463 GNUNET_NETWORK_socket_close (lsock6);
464 lsock6 = NULL;
465 }
466 }
453 467
454 468
455/** 469/**
@@ -499,7 +513,10 @@ schedule_httpd ()
499 wws = NULL; 513 wws = NULL;
500 } 514 }
501 if (NULL != httpd_task) 515 if (NULL != httpd_task)
516 {
502 GNUNET_SCHEDULER_cancel (httpd_task); 517 GNUNET_SCHEDULER_cancel (httpd_task);
518 httpd_task = NULL;
519 }
503 if ( (MHD_YES == haveto) || 520 if ( (MHD_YES == haveto) ||
504 (-1 != max)) 521 (-1 != max))
505 { 522 {
@@ -507,6 +524,7 @@ schedule_httpd ()
507 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 524 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
508 tv, wrs, wws, 525 tv, wrs, wws,
509 &do_httpd, NULL); 526 &do_httpd, NULL);
527
510 } 528 }
511 if (NULL != wrs) 529 if (NULL != wrs)
512 GNUNET_NETWORK_fdset_destroy (wrs); 530 GNUNET_NETWORK_fdset_destroy (wrs);
@@ -543,18 +561,23 @@ do_accept (void *cls)
543 const struct sockaddr *addr; 561 const struct sockaddr *addr;
544 socklen_t len; 562 socklen_t len;
545 563
564 GNUNET_assert (NULL != lsock);
546 if (lsock == lsock4) 565 if (lsock == lsock4)
547 ltask4 = NULL; 566 {
548 else
549 ltask6 = NULL;
550 if (lsock == lsock4)
551 ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, 567 ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
552 lsock, 568 lsock,
553 &do_accept, lsock); 569 &do_accept, lsock);
554 else 570
571 }
572 else if (lsock == lsock6)
573 {
555 ltask6 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, 574 ltask6 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
556 lsock, 575 lsock,
557 &do_accept, lsock); 576 &do_accept, lsock);
577
578 }
579 else
580 GNUNET_assert (0);
558 s = GNUNET_NETWORK_socket_accept (lsock, NULL, NULL); 581 s = GNUNET_NETWORK_socket_accept (lsock, NULL, NULL);
559 if (NULL == s) 582 if (NULL == s)
560 { 583 {
@@ -759,6 +782,7 @@ run (void *cls,
759 { 782 {
760 ltask6 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, 783 ltask6 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
761 lsock6, &do_accept, lsock6); 784 lsock6, &do_accept, lsock6);
785
762 } 786 }
763 } 787 }
764 lsock4 = bind_v4 (); 788 lsock4 = bind_v4 ();
@@ -778,6 +802,7 @@ run (void *cls,
778 { 802 {
779 ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, 803 ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
780 lsock4, &do_accept, lsock4); 804 lsock4, &do_accept, lsock4);
805
781 } 806 }
782 } 807 }
783 if ( (NULL == lsock4) && 808 if ( (NULL == lsock4) &&
@@ -824,10 +849,10 @@ main (int argc, char *const *argv)
824{ 849{
825 struct GNUNET_GETOPT_CommandLineOption options[] = { 850 struct GNUNET_GETOPT_CommandLineOption options[] = {
826 GNUNET_GETOPT_option_ulong ('p', 851 GNUNET_GETOPT_option_ulong ('p',
827 "port", 852 "port",
828 "PORT", 853 "PORT",
829 gettext_noop ("listen on specified port (default: 7776)"), 854 gettext_noop ("listen on specified port (default: 7776)"),
830 &port), 855 &port),
831 GNUNET_GETOPT_OPTION_END 856 GNUNET_GETOPT_OPTION_END
832 }; 857 };
833 static const char* err_page = 858 static const char* err_page =
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 2cc1ac62e..6189557f6 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -325,6 +325,34 @@ typedef void (*PostTest) (void *cls, struct GNUNET_RPS_Handle *h);
325 */ 325 */
326typedef int (*EvaluationCallback) (void); 326typedef int (*EvaluationCallback) (void);
327 327
328/**
329 * @brief Do we have Churn?
330 */
331enum OPTION_CHURN {
332 /**
333 * @brief If we have churn this is set
334 */
335 HAVE_CHURN,
336 /**
337 * @brief If we have no churn this is set
338 */
339 HAVE_NO_CHURN,
340};
341
342/**
343 * @brief Is it ok to quit the test before the timeout?
344 */
345enum OPTION_QUICK_QUIT {
346 /**
347 * @brief It is ok for the test to quit before the timeout triggers
348 */
349 HAVE_QUICK_QUIT,
350
351 /**
352 * @brief It is NOT ok for the test to quit before the timeout triggers
353 */
354 HAVE_NO_QUICK_QUIT,
355};
328 356
329/** 357/**
330 * Structure to define a single test 358 * Structure to define a single test
@@ -377,9 +405,14 @@ struct SingleTestRun
377 uint32_t num_requests; 405 uint32_t num_requests;
378 406
379 /** 407 /**
380 * Run with churn 408 * Run with (-out) churn
381 */ 409 */
382 int have_churn; 410 enum OPTION_CHURN have_churn;
411
412 /**
413 * Quit test before timeout?
414 */
415 enum OPTION_QUICK_QUIT have_quick_quit;
383} cur_test_run; 416} cur_test_run;
384 417
385/** 418/**
@@ -801,8 +834,9 @@ default_reply_handle (void *cls,
801 rps_peer->num_recv_ids++; 834 rps_peer->num_recv_ids++;
802 } 835 }
803 836
804 if (0 == evaluate ()) 837 if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit)
805 { 838 {
839 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n");
806 GNUNET_assert (NULL != shutdown_task); 840 GNUNET_assert (NULL != shutdown_task);
807 GNUNET_SCHEDULER_cancel (shutdown_task); 841 GNUNET_SCHEDULER_cancel (shutdown_task);
808 shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL); 842 shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL);
@@ -1143,7 +1177,7 @@ churn_test_cb (struct RPSPeer *rps_peer)
1143 } 1177 }
1144 1178
1145 /* Start churn */ 1179 /* Start churn */
1146 if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) 1180 if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task)
1147 { 1181 {
1148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1149 "Starting churn task\n"); 1183 "Starting churn task\n");
@@ -1265,8 +1299,6 @@ manage_service_wrapper (unsigned int i, unsigned int j,
1265 struct OpListEntry *entry; 1299 struct OpListEntry *entry;
1266 uint32_t prob; 1300 uint32_t prob;
1267 1301
1268 GNUNET_assert (GNUNET_YES == rps_peers[j].online);
1269
1270 /* make sure that management operation is not already scheduled */ 1302 /* make sure that management operation is not already scheduled */
1271 if (NULL != rps_peers[j].entry_op_manage) 1303 if (NULL != rps_peers[j].entry_op_manage)
1272 { 1304 {
@@ -1288,10 +1320,6 @@ manage_service_wrapper (unsigned int i, unsigned int j,
1288 GNUNET_i2s (rps_peers[j].peer_id), 1320 GNUNET_i2s (rps_peers[j].peer_id),
1289 (PEER_GO_OFFLINE == delta) ? "offline" : "online"); 1321 (PEER_GO_OFFLINE == delta) ? "offline" : "online");
1290 1322
1291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1292 "testbed_peers points to %p, peer 0 to %p\n",
1293 testbed_peers, testbed_peers[0]);
1294
1295 if (PEER_GO_OFFLINE == delta) 1323 if (PEER_GO_OFFLINE == delta)
1296 cancel_pending_req_rep (&rps_peers[j]); 1324 cancel_pending_req_rep (&rps_peers[j]);
1297 entry = make_oplist_entry (); 1325 entry = make_oplist_entry ();
@@ -1441,7 +1469,7 @@ profiler_cb (struct RPSPeer *rps_peer)
1441 } 1469 }
1442 1470
1443 /* Start churn */ 1471 /* Start churn */
1444 if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) 1472 if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task)
1445 { 1473 {
1446 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1474 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1447 "Starting churn task\n"); 1475 "Starting churn task\n");
@@ -1621,7 +1649,7 @@ main (int argc, char *argv[])
1621 cur_test_run.pre_test = NULL; 1649 cur_test_run.pre_test = NULL;
1622 cur_test_run.reply_handle = default_reply_handle; 1650 cur_test_run.reply_handle = default_reply_handle;
1623 cur_test_run.eval_cb = default_eval_cb; 1651 cur_test_run.eval_cb = default_eval_cb;
1624 cur_test_run.have_churn = GNUNET_YES; 1652 cur_test_run.have_churn = HAVE_CHURN;
1625 churn_task = NULL; 1653 churn_task = NULL;
1626 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); 1654 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30);
1627 1655
@@ -1656,7 +1684,7 @@ main (int argc, char *argv[])
1656 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test single request\n"); 1684 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test single request\n");
1657 cur_test_run.name = "test-rps-single-req"; 1685 cur_test_run.name = "test-rps-single-req";
1658 cur_test_run.main_test = single_req_cb; 1686 cur_test_run.main_test = single_req_cb;
1659 cur_test_run.have_churn = GNUNET_NO; 1687 cur_test_run.have_churn = HAVE_NO_CHURN;
1660 } 1688 }
1661 1689
1662 else if (strstr (argv[0], "_delayed_reqs") != NULL) 1690 else if (strstr (argv[0], "_delayed_reqs") != NULL)
@@ -1664,7 +1692,7 @@ main (int argc, char *argv[])
1664 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test delayed requests\n"); 1692 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test delayed requests\n");
1665 cur_test_run.name = "test-rps-delayed-reqs"; 1693 cur_test_run.name = "test-rps-delayed-reqs";
1666 cur_test_run.main_test = delay_req_cb; 1694 cur_test_run.main_test = delay_req_cb;
1667 cur_test_run.have_churn = GNUNET_NO; 1695 cur_test_run.have_churn = HAVE_NO_CHURN;
1668 } 1696 }
1669 1697
1670 else if (strstr (argv[0], "_seed_big") != NULL) 1698 else if (strstr (argv[0], "_seed_big") != NULL)
@@ -1674,7 +1702,7 @@ main (int argc, char *argv[])
1674 cur_test_run.name = "test-rps-seed-big"; 1702 cur_test_run.name = "test-rps-seed-big";
1675 cur_test_run.main_test = seed_big_cb; 1703 cur_test_run.main_test = seed_big_cb;
1676 cur_test_run.eval_cb = no_eval; 1704 cur_test_run.eval_cb = no_eval;
1677 cur_test_run.have_churn = GNUNET_NO; 1705 cur_test_run.have_churn = HAVE_NO_CHURN;
1678 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); 1706 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
1679 } 1707 }
1680 1708
@@ -1683,7 +1711,7 @@ main (int argc, char *argv[])
1683 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on a single peer\n"); 1711 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on a single peer\n");
1684 cur_test_run.name = "test-rps-single-peer-seed"; 1712 cur_test_run.name = "test-rps-single-peer-seed";
1685 cur_test_run.main_test = single_peer_seed_cb; 1713 cur_test_run.main_test = single_peer_seed_cb;
1686 cur_test_run.have_churn = GNUNET_NO; 1714 cur_test_run.have_churn = HAVE_NO_CHURN;
1687 } 1715 }
1688 1716
1689 else if (strstr (argv[0], "_seed_request") != NULL) 1717 else if (strstr (argv[0], "_seed_request") != NULL)
@@ -1691,7 +1719,7 @@ main (int argc, char *argv[])
1691 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on multiple peers\n"); 1719 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on multiple peers\n");
1692 cur_test_run.name = "test-rps-seed-request"; 1720 cur_test_run.name = "test-rps-seed-request";
1693 cur_test_run.main_test = seed_req_cb; 1721 cur_test_run.main_test = seed_req_cb;
1694 cur_test_run.have_churn = GNUNET_NO; 1722 cur_test_run.have_churn = HAVE_NO_CHURN;
1695 } 1723 }
1696 1724
1697 else if (strstr (argv[0], "_seed") != NULL) 1725 else if (strstr (argv[0], "_seed") != NULL)
@@ -1700,7 +1728,7 @@ main (int argc, char *argv[])
1700 cur_test_run.name = "test-rps-seed"; 1728 cur_test_run.name = "test-rps-seed";
1701 cur_test_run.main_test = seed_cb; 1729 cur_test_run.main_test = seed_cb;
1702 cur_test_run.eval_cb = no_eval; 1730 cur_test_run.eval_cb = no_eval;
1703 cur_test_run.have_churn = GNUNET_NO; 1731 cur_test_run.have_churn = HAVE_NO_CHURN;
1704 } 1732 }
1705 1733
1706 else if (strstr (argv[0], "_req_cancel") != NULL) 1734 else if (strstr (argv[0], "_req_cancel") != NULL)
@@ -1710,7 +1738,7 @@ main (int argc, char *argv[])
1710 num_peers = 1; 1738 num_peers = 1;
1711 cur_test_run.main_test = req_cancel_cb; 1739 cur_test_run.main_test = req_cancel_cb;
1712 cur_test_run.eval_cb = no_eval; 1740 cur_test_run.eval_cb = no_eval;
1713 cur_test_run.have_churn = GNUNET_NO; 1741 cur_test_run.have_churn = HAVE_NO_CHURN;
1714 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); 1742 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
1715 } 1743 }
1716 1744
@@ -1723,7 +1751,8 @@ main (int argc, char *argv[])
1723 cur_test_run.main_test = churn_test_cb; 1751 cur_test_run.main_test = churn_test_cb;
1724 cur_test_run.reply_handle = default_reply_handle; 1752 cur_test_run.reply_handle = default_reply_handle;
1725 cur_test_run.eval_cb = default_eval_cb; 1753 cur_test_run.eval_cb = default_eval_cb;
1726 cur_test_run.have_churn = GNUNET_YES; 1754 cur_test_run.have_churn = HAVE_CHURN;
1755 cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
1727 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); 1756 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
1728 } 1757 }
1729 1758
@@ -1740,8 +1769,9 @@ main (int argc, char *argv[])
1740 cur_test_run.eval_cb = profiler_eval; 1769 cur_test_run.eval_cb = profiler_eval;
1741 cur_test_run.request_interval = 2; 1770 cur_test_run.request_interval = 2;
1742 cur_test_run.num_requests = 5; 1771 cur_test_run.num_requests = 5;
1743 cur_test_run.have_churn = GNUNET_YES; 1772 cur_test_run.have_churn = HAVE_CHURN;
1744 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); 1773 cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
1774 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300);
1745 1775
1746 /* 'Clean' directory */ 1776 /* 'Clean' directory */
1747 (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); 1777 (void) GNUNET_DISK_directory_remove ("/tmp/rps/");
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 9d37231e7..279a4ed02 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -1659,8 +1659,7 @@ GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay,
1659 1659
1660 1660
1661void 1661void
1662extract_handles (struct GNUNET_SCHEDULER_Task *t, 1662extract_handles (const struct GNUNET_NETWORK_FDSet *fdset,
1663 const struct GNUNET_NETWORK_FDSet *fdset,
1664 const struct GNUNET_NETWORK_Handle ***ntarget, 1663 const struct GNUNET_NETWORK_Handle ***ntarget,
1665 unsigned int *extracted_nhandles, 1664 unsigned int *extracted_nhandles,
1666 const struct GNUNET_DISK_FileHandle ***ftarget, 1665 const struct GNUNET_DISK_FileHandle ***ftarget,
@@ -1673,7 +1672,6 @@ extract_handles (struct GNUNET_SCHEDULER_Task *t,
1673 unsigned int nhandles_len; 1672 unsigned int nhandles_len;
1674 unsigned int fhandles_len; 1673 unsigned int fhandles_len;
1675 1674
1676 (void) t;
1677 nhandles = NULL; 1675 nhandles = NULL;
1678 fhandles = NULL; 1676 fhandles = NULL;
1679 nhandles_len = 0; 1677 nhandles_len = 0;
@@ -1748,57 +1746,63 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio,
1748 void *task_cls) 1746 void *task_cls)
1749{ 1747{
1750 struct GNUNET_SCHEDULER_Task *t; 1748 struct GNUNET_SCHEDULER_Task *t;
1751 const struct GNUNET_NETWORK_Handle **read_nhandles; 1749 const struct GNUNET_NETWORK_Handle **read_nhandles = NULL;
1752 const struct GNUNET_NETWORK_Handle **write_nhandles; 1750 const struct GNUNET_NETWORK_Handle **write_nhandles = NULL;
1753 const struct GNUNET_DISK_FileHandle **read_fhandles; 1751 const struct GNUNET_DISK_FileHandle **read_fhandles = NULL;
1754 const struct GNUNET_DISK_FileHandle **write_fhandles; 1752 const struct GNUNET_DISK_FileHandle **write_fhandles = NULL;
1755 unsigned int read_nhandles_len, write_nhandles_len, 1753 unsigned int read_nhandles_len = 0;
1756 read_fhandles_len, write_fhandles_len; 1754 unsigned int write_nhandles_len = 0;
1757 int no_fdsets = (NULL == rs) && (NULL == ws); 1755 unsigned int read_fhandles_len = 0;
1758 int no_socket_descriptors = 1756 unsigned int write_fhandles_len = 0;
1759 ((NULL != rs) && (0 == rs->nsds)) && ((NULL != ws) && (0 == ws->nsds)); 1757
1760
1761 if (no_fdsets || no_socket_descriptors)
1762 return GNUNET_SCHEDULER_add_delayed_with_priority (delay,
1763 prio,
1764 task,
1765 task_cls);
1766 /* scheduler must be running */ 1758 /* scheduler must be running */
1767 GNUNET_assert (NULL != scheduler_driver); 1759 GNUNET_assert (NULL != scheduler_driver);
1768 GNUNET_assert (NULL != active_task); 1760 GNUNET_assert (NULL != active_task);
1769 GNUNET_assert (NULL != task); 1761 GNUNET_assert (NULL != task);
1770 t = GNUNET_new (struct GNUNET_SCHEDULER_Task); 1762 int no_rs = (NULL == rs);
1771 t->callback = task; 1763 int no_ws = (NULL == ws);
1772 t->callback_cls = task_cls; 1764 int empty_rs = (NULL != rs) && (0 == rs->nsds);
1773 t->read_fd = -1; 1765 int empty_ws = (NULL != ws) && (0 == ws->nsds);
1774 t->write_fd = -1; 1766 int no_fds = (no_rs && no_ws) ||
1775 t->own_handles = GNUNET_YES; 1767 (empty_rs && empty_ws) ||
1776 read_nhandles = NULL; 1768 (no_rs && empty_ws) ||
1777 write_nhandles = NULL; 1769 (no_ws && empty_rs);
1778 read_fhandles = NULL; 1770 if (! no_fds)
1779 write_fhandles = NULL;
1780 read_nhandles_len = 0;
1781 write_nhandles_len = 0;
1782 read_fhandles_len = 0;
1783 write_fhandles_len = 0;
1784 if (NULL != rs)
1785 {
1786 extract_handles (t,
1787 rs,
1788 &read_nhandles,
1789 &read_nhandles_len,
1790 &read_fhandles,
1791 &read_fhandles_len);
1792 }
1793 if (NULL != ws)
1794 { 1771 {
1795 extract_handles (t, 1772 if (NULL != rs)
1796 ws, 1773 {
1797 &write_nhandles, 1774 extract_handles (rs,
1798 &write_nhandles_len, 1775 &read_nhandles,
1799 &write_fhandles, 1776 &read_nhandles_len,
1800 &write_fhandles_len); 1777 &read_fhandles,
1778 &read_fhandles_len);
1779 }
1780 if (NULL != ws)
1781 {
1782 extract_handles (ws,
1783 &write_nhandles,
1784 &write_nhandles_len,
1785 &write_fhandles,
1786 &write_fhandles_len);
1787 }
1801 } 1788 }
1789 /**
1790 * here we consider the case that a GNUNET_NETWORK_FDSet might be empty
1791 * although its maximum FD number (nsds) is greater than 0. We handle
1792 * this case gracefully because some libraries such as libmicrohttpd
1793 * only provide a hint what the maximum FD number in an FD set might be
1794 * and not the exact FD number (see e.g. gnunet-rest-service.c)
1795 */
1796 int no_fds_extracted = (0 == read_nhandles_len) &&
1797 (0 == read_fhandles_len) &&
1798 (0 == write_nhandles_len) &&
1799 (0 == write_fhandles_len);
1800 if (no_fds || no_fds_extracted)
1801 return GNUNET_SCHEDULER_add_delayed_with_priority (delay,
1802 prio,
1803 task,
1804 task_cls);
1805 t = GNUNET_new (struct GNUNET_SCHEDULER_Task);
1802 init_fd_info (t, 1806 init_fd_info (t,
1803 read_nhandles, 1807 read_nhandles,
1804 read_nhandles_len, 1808 read_nhandles_len,
@@ -1808,6 +1812,9 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio,
1808 read_fhandles_len, 1812 read_fhandles_len,
1809 write_fhandles, 1813 write_fhandles,
1810 write_fhandles_len); 1814 write_fhandles_len);
1815 t->callback = task;
1816 t->callback_cls = task_cls;
1817 t->own_handles = GNUNET_YES;
1811 /* free the arrays of pointers to network / file handles, the actual 1818 /* free the arrays of pointers to network / file handles, the actual
1812 * handles will be freed in destroy_task */ 1819 * handles will be freed in destroy_task */
1813 GNUNET_array_grow (read_nhandles, read_nhandles_len, 0); 1820 GNUNET_array_grow (read_nhandles, read_nhandles_len, 0);
@@ -2006,7 +2013,7 @@ GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh)
2006 if (GNUNET_OK != del_result) 2013 if (GNUNET_OK != del_result)
2007 { 2014 {
2008 LOG (GNUNET_ERROR_TYPE_ERROR, 2015 LOG (GNUNET_ERROR_TYPE_ERROR,
2009 "driver could not delete task\n"); 2016 "driver could not delete task %p\n", pos);
2010 GNUNET_assert (0); 2017 GNUNET_assert (0);
2011 } 2018 }
2012 } 2019 }