aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-01-08 07:58:36 +0100
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-01-08 07:58:36 +0100
commit3f52ce03cb13118bef9a6fbe380f229e2cbec45f (patch)
tree0f986c12192fcdd5d05fe575f66f01a0cf5ddf4e /src
parent7ad94d1427d304483e9bf1cf1d12065f8e41d712 (diff)
parent0120859e1ea2f0591602f446d4bc054e9230c801 (diff)
downloadgnunet-3f52ce03cb13118bef9a6fbe380f229e2cbec45f.tar.gz
gnunet-3f52ce03cb13118bef9a6fbe380f229e2cbec45f.zip
Merge branch 'master' of git+ssh://gnunet.org/gnunet
Diffstat (limited to 'src')
-rw-r--r--src/fs/fs_search.c19
-rw-r--r--src/fs/fs_uri.c25
-rw-r--r--src/gns/gnunet-dns2gns.c45
-rw-r--r--src/include/gnunet_fs_service.h3
-rw-r--r--src/include/gnunet_network_lib.h2
-rw-r--r--src/nat/gnunet-nat.c12
-rw-r--r--src/nse/gnunet-nse-profiler.c19
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c6
-rw-r--r--src/psycstore/psycstore_api.c3
-rw-r--r--src/rps/test_rps.c212
-rw-r--r--src/set/gnunet-service-set_union.c9
-rw-r--r--src/social/gnunet-service-social.c75
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c4
-rw-r--r--src/transport/plugin_transport_tcp.c7
-rw-r--r--src/util/common_allocation.c5
-rw-r--r--src/util/configuration.c1
-rw-r--r--src/util/crypto_hash.c6
-rw-r--r--src/util/network.c86
-rw-r--r--src/util/scheduler.c17
19 files changed, 406 insertions, 150 deletions
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 8c6f5edcf..83aae2fc5 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -568,7 +568,13 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
568 568
569 /* check if new */ 569 /* check if new */
570 GNUNET_assert (NULL != sc); 570 GNUNET_assert (NULL != sc);
571 GNUNET_FS_uri_to_key (uri, &key); 571 if (GNUNET_OK !=
572 GNUNET_FS_uri_to_key (uri,
573 &key))
574 {
575 GNUNET_break_op (0);
576 return;
577 }
572 if (GNUNET_SYSERR == 578 if (GNUNET_SYSERR ==
573 GNUNET_CONTAINER_multihashmap_get_multiple (ent->results, 579 GNUNET_CONTAINER_multihashmap_get_multiple (ent->results,
574 &key, 580 &key,
@@ -680,8 +686,15 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc,
680 686
681 /* check if new */ 687 /* check if new */
682 GNUNET_assert (NULL != sc); 688 GNUNET_assert (NULL != sc);
683 GNUNET_FS_uri_to_key (uri, &key); 689 if (GNUNET_OK !=
684 GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, &uri->data.chk.chk.query, 690 GNUNET_FS_uri_to_key (uri,
691 &key))
692 {
693 GNUNET_break (0);
694 return;
695 }
696 GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key,
697 &uri->data.chk.chk.query,
685 &key); 698 &key);
686 if (GNUNET_SYSERR == 699 if (GNUNET_SYSERR ==
687 GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, &key, 700 GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, &key,
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index 11968b750..b90c75981 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -96,8 +96,9 @@
96 * 96 *
97 * @param uri uri to convert to a unique key 97 * @param uri uri to convert to a unique key
98 * @param key where to store the unique key 98 * @param key where to store the unique key
99 * @return #GNUNET_OK on success
99 */ 100 */
100void 101int
101GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, 102GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
102 struct GNUNET_HashCode *key) 103 struct GNUNET_HashCode *key)
103{ 104{
@@ -105,25 +106,35 @@ GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
105 { 106 {
106 case GNUNET_FS_URI_CHK: 107 case GNUNET_FS_URI_CHK:
107 *key = uri->data.chk.chk.query; 108 *key = uri->data.chk.chk.query;
108 return; 109 return GNUNET_OK;
109 case GNUNET_FS_URI_SKS: 110 case GNUNET_FS_URI_SKS:
110 GNUNET_CRYPTO_hash (uri->data.sks.identifier, 111 GNUNET_CRYPTO_hash (uri->data.sks.identifier,
111 strlen (uri->data.sks.identifier), key); 112 strlen (uri->data.sks.identifier),
112 break; 113 key);
114 return GNUNET_OK;
113 case GNUNET_FS_URI_KSK: 115 case GNUNET_FS_URI_KSK:
114 if (uri->data.ksk.keywordCount > 0) 116 if (uri->data.ksk.keywordCount > 0)
117 {
115 GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0], 118 GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0],
116 strlen (uri->data.ksk.keywords[0]), key); 119 strlen (uri->data.ksk.keywords[0]),
120 key);
121 return GNUNET_OK;
122 }
123 else
124 {
125 memset (key, 0, sizeof (struct GNUNET_HashCode));
126 return GNUNET_SYSERR;
127 }
117 break; 128 break;
118 case GNUNET_FS_URI_LOC: 129 case GNUNET_FS_URI_LOC:
119 GNUNET_CRYPTO_hash (&uri->data.loc.fi, 130 GNUNET_CRYPTO_hash (&uri->data.loc.fi,
120 sizeof (struct FileIdentifier) + 131 sizeof (struct FileIdentifier) +
121 sizeof (struct GNUNET_PeerIdentity), 132 sizeof (struct GNUNET_PeerIdentity),
122 key); 133 key);
123 break; 134 return GNUNET_OK;
124 default: 135 default:
125 memset (key, 0, sizeof (struct GNUNET_HashCode)); 136 memset (key, 0, sizeof (struct GNUNET_HashCode));
126 break; 137 return GNUNET_SYSERR;
127 } 138 }
128} 139}
129 140
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index 424677d14..2f0de030d 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -533,14 +533,21 @@ read_dns4 (void *cls)
533 } 533 }
534 { 534 {
535 char buf[size + 1]; 535 char buf[size + 1];
536 ssize_t sret;
536 537
537 addrlen = sizeof (v4); 538 addrlen = sizeof (v4);
538 GNUNET_break (size == 539 sret = GNUNET_NETWORK_socket_recvfrom (listen_socket4,
539 GNUNET_NETWORK_socket_recvfrom (listen_socket4, 540 buf,
540 buf, 541 size + 1,
541 size + 1, 542 (struct sockaddr *) &v4,
542 (struct sockaddr *) &v4, 543 &addrlen);
543 &addrlen)); 544 if (0 > sret)
545 {
546 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
547 "recvfrom");
548 return;
549 }
550 GNUNET_break (size == (size_t) sret);
544 handle_request (listen_socket4, 551 handle_request (listen_socket4,
545 &v4, 552 &v4,
546 addrlen, 553 addrlen,
@@ -579,16 +586,26 @@ read_dns6 (void *cls)
579 } 586 }
580 { 587 {
581 char buf[size]; 588 char buf[size];
589 ssize_t sret;
582 590
583 addrlen = sizeof (v6); 591 addrlen = sizeof (v6);
584 GNUNET_break (size == 592 sret = GNUNET_NETWORK_socket_recvfrom (listen_socket6,
585 GNUNET_NETWORK_socket_recvfrom (listen_socket6, 593 buf,
586 buf, 594 size,
587 size, 595 (struct sockaddr *) &v6,
588 (struct sockaddr *) &v6, 596 &addrlen);
589 &addrlen)); 597 if (0 > sret)
590 handle_request (listen_socket6, &v6, addrlen, 598 {
591 buf, size); 599 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
600 "recvfrom");
601 return;
602 }
603 GNUNET_break (size == (size_t) sret);
604 handle_request (listen_socket6,
605 &v6,
606 addrlen,
607 buf,
608 size);
592 } 609 }
593} 610}
594 611
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index ac418072e..cbad374b5 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -109,8 +109,9 @@ typedef int
109 * 109 *
110 * @param uri uri to convert to a unique key 110 * @param uri uri to convert to a unique key
111 * @param key wherer to store the unique key 111 * @param key wherer to store the unique key
112 * @return #GNUNET_OK on success
112 */ 113 */
113void 114int
114GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, 115GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri,
115 struct GNUNET_HashCode *key); 116 struct GNUNET_HashCode *key);
116 117
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h
index 9e692bbbf..2c344749f 100644
--- a/src/include/gnunet_network_lib.h
+++ b/src/include/gnunet_network_lib.h
@@ -53,7 +53,7 @@ struct GNUNET_NETWORK_FDSet
53{ 53{
54 54
55 /** 55 /**
56 * Maximum number of any socket socket descriptor in the set (plus one) 56 * Maximum number of any socket descriptor in the set (plus one)
57 */ 57 */
58 int nsds; 58 int nsds;
59 59
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c
index b3cf2e946..72f343627 100644
--- a/src/nat/gnunet-nat.c
+++ b/src/nat/gnunet-nat.c
@@ -377,10 +377,16 @@ run (void *cls,
377 ls = GNUNET_NETWORK_socket_create (af, 377 ls = GNUNET_NETWORK_socket_create (af,
378 SOCK_DGRAM, 378 SOCK_DGRAM,
379 IPPROTO_UDP); 379 IPPROTO_UDP);
380 if (NULL == ls)
381 {
382 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
383 "Failed to create socket\n");
384 goto fail_and_shutdown;
385 }
380 if (GNUNET_OK != 386 if (GNUNET_OK !=
381 GNUNET_NETWORK_socket_bind (ls, 387 GNUNET_NETWORK_socket_bind (ls,
382 local_sa, 388 local_sa,
383 local_len)) 389 local_len))
384 { 390 {
385 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 391 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
386 "Failed to bind to %s: %s\n", 392 "Failed to bind to %s: %s\n",
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c
index 4a10022e3..b665812e5 100644
--- a/src/nse/gnunet-nse-profiler.c
+++ b/src/nse/gnunet-nse-profiler.c
@@ -374,13 +374,14 @@ nse_disconnect_adapter (void *cls,
374 */ 374 */
375static int 375static int
376stat_iterator (void *cls, 376stat_iterator (void *cls,
377 const char *subsystem, 377 const char *subsystem,
378 const char *name, 378 const char *name,
379 uint64_t value, int is_persistent) 379 uint64_t value,
380 int is_persistent)
380{ 381{
381 char *output_buffer; 382 char *output_buffer;
382 struct GNUNET_TIME_Absolute now; 383 struct GNUNET_TIME_Absolute now;
383 size_t size; 384 int size;
384 unsigned int flag; 385 unsigned int flag;
385 386
386 GNUNET_assert (NULL != data_file); 387 GNUNET_assert (NULL != data_file);
@@ -390,8 +391,14 @@ stat_iterator (void *cls,
390 flag = 1; 391 flag = 1;
391 size = GNUNET_asprintf (&output_buffer, "%llu %llu %u\n", 392 size = GNUNET_asprintf (&output_buffer, "%llu %llu %u\n",
392 now.abs_value_us / 1000LL / 1000LL, 393 now.abs_value_us / 1000LL / 1000LL,
393 value, flag); 394 value, flag);
394 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size)) 395 if (0 > size)
396 {
397 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Error formatting output buffer.\n");
398 GNUNET_free (output_buffer);
399 return GNUNET_SYSERR;
400 }
401 if (size != GNUNET_DISK_file_write (data_file, output_buffer, (size_t) size))
395 { 402 {
396 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); 403 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
397 GNUNET_free (output_buffer); 404 GNUNET_free (output_buffer);
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index bdb6e5e0d..6b39149be 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -1146,12 +1146,12 @@ handle_hello (void *cls,
1146 struct GNUNET_SERVICE_Client *client = cls; 1146 struct GNUNET_SERVICE_Client *client = cls;
1147 struct GNUNET_PeerIdentity pid; 1147 struct GNUNET_PeerIdentity pid;
1148 1148
1149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1150 "HELLO message received for peer `%s'\n",
1151 GNUNET_i2s (&pid));
1152 GNUNET_assert (GNUNET_OK == 1149 GNUNET_assert (GNUNET_OK ==
1153 GNUNET_HELLO_get_id (hello, 1150 GNUNET_HELLO_get_id (hello,
1154 &pid)); 1151 &pid));
1152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1153 "HELLO message received for peer `%s'\n",
1154 GNUNET_i2s (&pid));
1155 add_host_to_known_hosts (&pid); 1155 add_host_to_known_hosts (&pid);
1156 update_hello (&pid, 1156 update_hello (&pid,
1157 hello); 1157 hello);
diff --git a/src/psycstore/psycstore_api.c b/src/psycstore/psycstore_api.c
index 16f4a1ae9..5a4865dce 100644
--- a/src/psycstore/psycstore_api.c
+++ b/src/psycstore/psycstore_api.c
@@ -362,6 +362,9 @@ do_connect (struct GNUNET_PSYCSTORE_Handle *h)
362static void 362static void
363reconnect (void *cls) 363reconnect (void *cls)
364{ 364{
365 struct GNUNET_PSYCSTORE_Handle *h = cls;
366
367 h->reconnect_task = NULL;
365 do_connect (cls); 368 do_connect (cls);
366} 369}
367 370
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 0114a19fe..2cc1ac62e 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -62,6 +62,19 @@ static unsigned int mal_type = 0;
62 */ 62 */
63static struct GNUNET_TESTBED_Peer **testbed_peers; 63static struct GNUNET_TESTBED_Peer **testbed_peers;
64 64
65/**
66 * @brief Indicates whether peer should go off- or online
67 */
68enum PEER_ONLINE_DELTA {
69 /**
70 * @brief Indicates peer going online
71 */
72 PEER_GO_ONLINE = 1,
73 /**
74 * @brief Indicates peer going offline
75 */
76 PEER_GO_OFFLINE = -1,
77};
65 78
66/** 79/**
67 * Operation map entry 80 * Operation map entry
@@ -84,10 +97,10 @@ struct OpListEntry
84 struct GNUNET_TESTBED_Operation *op; 97 struct GNUNET_TESTBED_Operation *op;
85 98
86 /** 99 /**
87 * Depending on whether we start or stop NSE service at the peer set this to 1 100 * Depending on whether we start or stop RPS service at the peer, set this to
88 * or -1 101 * #PEER_GO_ONLINE (1) or #PEER_GO_OFFLINE (-1)
89 */ 102 */
90 int delta; 103 enum PEER_ONLINE_DELTA delta;
91 104
92 /** 105 /**
93 * Index of the regarding peer 106 * Index of the regarding peer
@@ -188,7 +201,7 @@ struct RPSPeer
188 int online; 201 int online;
189 202
190 /** 203 /**
191 * Number of Peer IDs to request 204 * Number of Peer IDs to request during the whole test
192 */ 205 */
193 unsigned int num_ids_to_request; 206 unsigned int num_ids_to_request;
194 207
@@ -218,6 +231,11 @@ struct RPSPeer
218 * Number of received PeerIDs 231 * Number of received PeerIDs
219 */ 232 */
220 unsigned int num_recv_ids; 233 unsigned int num_recv_ids;
234
235 /**
236 * Pending operation on that peer
237 */
238 const struct OpListEntry *entry_op_manage;
221}; 239};
222 240
223 241
@@ -259,6 +277,11 @@ static int ok;
259/** 277/**
260 * Identifier for the churn task that runs periodically 278 * Identifier for the churn task that runs periodically
261 */ 279 */
280static struct GNUNET_SCHEDULER_Task *shutdown_task;
281
282/**
283 * Identifier for the churn task that runs periodically
284 */
262static struct GNUNET_SCHEDULER_Task *churn_task; 285static struct GNUNET_SCHEDULER_Task *churn_task;
263 286
264/** 287/**
@@ -267,13 +290,21 @@ static struct GNUNET_SCHEDULER_Task *churn_task;
267typedef void (*InitPeer) (struct RPSPeer *rps_peer); 290typedef void (*InitPeer) (struct RPSPeer *rps_peer);
268 291
269/** 292/**
270 * Called directly after connecting to the service 293 * @brief Called directly after connecting to the service
294 *
295 * @param rps_peer Specific peer the function is called on
296 * @param h the handle to the rps service
271 */ 297 */
272typedef void (*PreTest) (void *cls, struct GNUNET_RPS_Handle *h); 298typedef void (*PreTest) (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h);
273 299
274/** 300/**
301 * @brief Executes functions to test the api/service for a given peer
302 *
275 * Called from within #rps_connect_complete_cb () 303 * Called from within #rps_connect_complete_cb ()
276 * Executes functions to test the api/service 304 * Implemented by #churn_test_cb, #profiler_cb, #mal_cb, #single_req_cb,
305 * #delay_req_cb, #seed_big_cb, #single_peer_seed_cb, #seed_cb, #req_cancel_cb
306 *
307 * @param rps_peer the peer the task runs on
277 */ 308 */
278typedef void (*MainTest) (struct RPSPeer *rps_peer); 309typedef void (*MainTest) (struct RPSPeer *rps_peer);
279 310
@@ -306,7 +337,7 @@ struct SingleTestRun
306 char *name; 337 char *name;
307 338
308 /** 339 /**
309 * Called to initialise peer 340 * Called with a single peer in order to initialise that peer
310 */ 341 */
311 InitPeer init_peer; 342 InitPeer init_peer;
312 343
@@ -316,7 +347,7 @@ struct SingleTestRun
316 PreTest pre_test; 347 PreTest pre_test;
317 348
318 /** 349 /**
319 * Function to execute the functions to be tested 350 * Main function for each peer
320 */ 351 */
321 MainTest main_test; 352 MainTest main_test;
322 353
@@ -502,6 +533,8 @@ shutdown_op (void *cls)
502{ 533{
503 unsigned int i; 534 unsigned int i;
504 535
536 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
537 "Shutdown task scheduled, going down.\n");
505 in_shutdown = GNUNET_YES; 538 in_shutdown = GNUNET_YES;
506 if (NULL != churn_task) 539 if (NULL != churn_task)
507 { 540 {
@@ -583,6 +616,11 @@ info_cb (void *cb_cls,
583{ 616{
584 struct OpListEntry *entry = (struct OpListEntry *) cb_cls; 617 struct OpListEntry *entry = (struct OpListEntry *) cb_cls;
585 618
619 if (GNUNET_YES == in_shutdown)
620 {
621 return;
622 }
623
586 if (NULL == pinfo || NULL != emsg) 624 if (NULL == pinfo || NULL != emsg)
587 { 625 {
588 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); 626 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg);
@@ -632,6 +670,11 @@ rps_connect_complete_cb (void *cls,
632 struct RPSPeer *rps_peer = cls; 670 struct RPSPeer *rps_peer = cls;
633 struct GNUNET_RPS_Handle *rps = ca_result; 671 struct GNUNET_RPS_Handle *rps = ca_result;
634 672
673 if (GNUNET_YES == in_shutdown)
674 {
675 return;
676 }
677
635 rps_peer->rps_handle = rps; 678 rps_peer->rps_handle = rps;
636 rps_peer->online = GNUNET_YES; 679 rps_peer->online = GNUNET_YES;
637 num_peers_online++; 680 num_peers_online++;
@@ -760,7 +803,10 @@ default_reply_handle (void *cls,
760 803
761 if (0 == evaluate ()) 804 if (0 == evaluate ())
762 { 805 {
763 GNUNET_SCHEDULER_shutdown (); 806 GNUNET_assert (NULL != shutdown_task);
807 GNUNET_SCHEDULER_cancel (shutdown_task);
808 shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL);
809 GNUNET_assert (NULL!= shutdown_task);
764 } 810 }
765} 811}
766 812
@@ -904,12 +950,20 @@ static void mal_init_peer (struct RPSPeer *rps_peer)
904 rps_peer->num_ids_to_request = 1; 950 rps_peer->num_ids_to_request = 1;
905} 951}
906 952
953
954/**
955 * @brief Set peers to (non-)malicious before execution
956 *
957 * Of signature #PreTest
958 *
959 * @param rps_peer the peer to set (non-) malicious
960 * @param h the handle to the service
961 */
907static void 962static void
908mal_pre (void *cls, struct GNUNET_RPS_Handle *h) 963mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
909{ 964{
910 #ifdef ENABLE_MALICIOUS 965 #ifdef ENABLE_MALICIOUS
911 uint32_t num_mal_peers; 966 uint32_t num_mal_peers;
912 struct RPSPeer *rps_peer = (struct RPSPeer *) cls;
913 967
914 GNUNET_assert ( (1 >= portion) && 968 GNUNET_assert ( (1 >= portion) &&
915 (0 < portion) ); 969 (0 < portion) );
@@ -934,6 +988,11 @@ mal_cb (struct RPSPeer *rps_peer)
934{ 988{
935 uint32_t num_mal_peers; 989 uint32_t num_mal_peers;
936 990
991 if (GNUNET_YES == in_shutdown)
992 {
993 return;
994 }
995
937 #ifdef ENABLE_MALICIOUS 996 #ifdef ENABLE_MALICIOUS
938 GNUNET_assert ( (1 >= portion) && 997 GNUNET_assert ( (1 >= portion) &&
939 (0 < portion) ); 998 (0 < portion) );
@@ -956,6 +1015,11 @@ mal_cb (struct RPSPeer *rps_peer)
956static void 1015static void
957single_req_cb (struct RPSPeer *rps_peer) 1016single_req_cb (struct RPSPeer *rps_peer)
958{ 1017{
1018 if (GNUNET_YES == in_shutdown)
1019 {
1020 return;
1021 }
1022
959 schedule_missing_requests (rps_peer); 1023 schedule_missing_requests (rps_peer);
960} 1024}
961 1025
@@ -965,6 +1029,11 @@ single_req_cb (struct RPSPeer *rps_peer)
965static void 1029static void
966delay_req_cb (struct RPSPeer *rps_peer) 1030delay_req_cb (struct RPSPeer *rps_peer)
967{ 1031{
1032 if (GNUNET_YES == in_shutdown)
1033 {
1034 return;
1035 }
1036
968 schedule_missing_requests (rps_peer); 1037 schedule_missing_requests (rps_peer);
969} 1038}
970 1039
@@ -974,6 +1043,11 @@ delay_req_cb (struct RPSPeer *rps_peer)
974static void 1043static void
975seed_cb (struct RPSPeer *rps_peer) 1044seed_cb (struct RPSPeer *rps_peer)
976{ 1045{
1046 if (GNUNET_YES == in_shutdown)
1047 {
1048 return;
1049 }
1050
977 GNUNET_SCHEDULER_add_delayed ( 1051 GNUNET_SCHEDULER_add_delayed (
978 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), 1052 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10),
979 seed_peers, rps_peer); 1053 seed_peers, rps_peer);
@@ -985,6 +1059,11 @@ seed_cb (struct RPSPeer *rps_peer)
985static void 1059static void
986seed_big_cb (struct RPSPeer *rps_peer) 1060seed_big_cb (struct RPSPeer *rps_peer)
987{ 1061{
1062 if (GNUNET_YES == in_shutdown)
1063 {
1064 return;
1065 }
1066
988 // TODO test seeding > GNUNET_MAX_MESSAGE_SIZE peers 1067 // TODO test seeding > GNUNET_MAX_MESSAGE_SIZE peers
989 GNUNET_SCHEDULER_add_delayed ( 1068 GNUNET_SCHEDULER_add_delayed (
990 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), 1069 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
@@ -1006,6 +1085,11 @@ single_peer_seed_cb (struct RPSPeer *rps_peer)
1006static void 1085static void
1007seed_req_cb (struct RPSPeer *rps_peer) 1086seed_req_cb (struct RPSPeer *rps_peer)
1008{ 1087{
1088 if (GNUNET_YES == in_shutdown)
1089 {
1090 return;
1091 }
1092
1009 GNUNET_SCHEDULER_add_delayed ( 1093 GNUNET_SCHEDULER_add_delayed (
1010 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), 1094 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
1011 seed_peers, rps_peer); 1095 seed_peers, rps_peer);
@@ -1020,6 +1104,11 @@ seed_req_cb (struct RPSPeer *rps_peer)
1020static void 1104static void
1021req_cancel_cb (struct RPSPeer *rps_peer) 1105req_cancel_cb (struct RPSPeer *rps_peer)
1022{ 1106{
1107 if (GNUNET_YES == in_shutdown)
1108 {
1109 return;
1110 }
1111
1023 schedule_missing_requests (rps_peer); 1112 schedule_missing_requests (rps_peer);
1024 GNUNET_SCHEDULER_add_delayed ( 1113 GNUNET_SCHEDULER_add_delayed (
1025 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1114 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
@@ -1034,9 +1123,25 @@ req_cancel_cb (struct RPSPeer *rps_peer)
1034static void 1123static void
1035churn (void *cls); 1124churn (void *cls);
1036 1125
1126/**
1127 * @brief Starts churn
1128 *
1129 * Has signature of #MainTest
1130 *
1131 * This is not implemented too nicely as this is called for each peer, but we
1132 * only need to call it once. (Yes we check that we only schedule the task
1133 * once.)
1134 *
1135 * @param rps_peer The peer it's called for
1136 */
1037static void 1137static void
1038churn_test_cb (struct RPSPeer *rps_peer) 1138churn_test_cb (struct RPSPeer *rps_peer)
1039{ 1139{
1140 if (GNUNET_YES == in_shutdown)
1141 {
1142 return;
1143 }
1144
1040 /* Start churn */ 1145 /* Start churn */
1041 if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) 1146 if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task)
1042 { 1147 {
@@ -1073,6 +1178,11 @@ churn_cb (void *cls,
1073 // FIXME 1178 // FIXME
1074 struct OpListEntry *entry = cls; 1179 struct OpListEntry *entry = cls;
1075 1180
1181 if (GNUNET_YES == in_shutdown)
1182 {
1183 return;
1184 }
1185
1076 GNUNET_TESTBED_operation_done (entry->op); 1186 GNUNET_TESTBED_operation_done (entry->op);
1077 if (NULL != emsg) 1187 if (NULL != emsg)
1078 { 1188 {
@@ -1084,7 +1194,7 @@ churn_cb (void *cls,
1084 1194
1085 num_peers_online += entry->delta; 1195 num_peers_online += entry->delta;
1086 1196
1087 if (0 > entry->delta) 1197 if (PEER_GO_OFFLINE == entry->delta)
1088 { /* Peer hopefully just went offline */ 1198 { /* Peer hopefully just went offline */
1089 if (GNUNET_YES != rps_peers[entry->index].online) 1199 if (GNUNET_YES != rps_peers[entry->index].online)
1090 { 1200 {
@@ -1102,7 +1212,7 @@ churn_cb (void *cls,
1102 rps_peers[entry->index].online = GNUNET_NO; 1212 rps_peers[entry->index].online = GNUNET_NO;
1103 } 1213 }
1104 1214
1105 else if (0 < entry->delta) 1215 else if (PEER_GO_ONLINE < entry->delta)
1106 { /* Peer hopefully just went online */ 1216 { /* Peer hopefully just went online */
1107 if (GNUNET_NO != rps_peers[entry->index].online) 1217 if (GNUNET_NO != rps_peers[entry->index].online)
1108 { 1218 {
@@ -1125,20 +1235,44 @@ churn_cb (void *cls,
1125 } 1235 }
1126 rps_peers[entry->index].online = GNUNET_YES; 1236 rps_peers[entry->index].online = GNUNET_YES;
1127 } 1237 }
1238 else
1239 {
1240 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1241 "Invalid value for delta: %i\n", entry->delta);
1242 GNUNET_break (0);
1243 }
1128 1244
1129 GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); 1245 GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
1246 rps_peers[entry->index].entry_op_manage = NULL;
1130 GNUNET_free (entry); 1247 GNUNET_free (entry);
1131 //if (num_peers_in_round[current_round] == peers_running) 1248 //if (num_peers_in_round[current_round] == peers_running)
1132 // run_round (); 1249 // run_round ();
1133} 1250}
1134 1251
1252/**
1253 * @brief Set the rps-service up or down for a specific peer
1254 *
1255 * @param i index of action
1256 * @param j index of peer
1257 * @param delta (#PEER_ONLINE_DELTA) down (-1) or up (1)
1258 * @param prob_go_on_off the probability of the action
1259 */
1135static void 1260static void
1136manage_service_wrapper (unsigned int i, unsigned int j, int delta, 1261manage_service_wrapper (unsigned int i, unsigned int j,
1137 double prob_go_on_off) 1262 enum PEER_ONLINE_DELTA delta,
1263 double prob_go_on_off)
1138{ 1264{
1139 struct OpListEntry *entry; 1265 struct OpListEntry *entry;
1140 uint32_t prob; 1266 uint32_t prob;
1141 1267
1268 GNUNET_assert (GNUNET_YES == rps_peers[j].online);
1269
1270 /* make sure that management operation is not already scheduled */
1271 if (NULL != rps_peers[j].entry_op_manage)
1272 {
1273 return;
1274 }
1275
1142 prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1276 prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1143 UINT32_MAX); 1277 UINT32_MAX);
1144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1146,15 +1280,19 @@ manage_service_wrapper (unsigned int i, unsigned int j, int delta,
1146 i, 1280 i,
1147 j, 1281 j,
1148 GNUNET_i2s (rps_peers[j].peer_id), 1282 GNUNET_i2s (rps_peers[j].peer_id),
1149 (0 > delta) ? "online" : "offline"); 1283 (PEER_GO_ONLINE == delta) ? "online" : "offline");
1150 if (prob < prob_go_on_off * UINT32_MAX) 1284 if (prob < prob_go_on_off * UINT32_MAX)
1151 { 1285 {
1152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1153 "%s goes %s\n", 1287 "%s goes %s\n",
1154 GNUNET_i2s (rps_peers[j].peer_id), 1288 GNUNET_i2s (rps_peers[j].peer_id),
1155 (0 > delta) ? "offline" : "online"); 1289 (PEER_GO_OFFLINE == delta) ? "offline" : "online");
1290
1291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1292 "testbed_peers points to %p, peer 0 to %p\n",
1293 testbed_peers, testbed_peers[0]);
1156 1294
1157 if (0 > delta) 1295 if (PEER_GO_OFFLINE == delta)
1158 cancel_pending_req_rep (&rps_peers[j]); 1296 cancel_pending_req_rep (&rps_peers[j]);
1159 entry = make_oplist_entry (); 1297 entry = make_oplist_entry ();
1160 entry->delta = delta; 1298 entry->delta = delta;
@@ -1164,8 +1302,9 @@ manage_service_wrapper (unsigned int i, unsigned int j, int delta,
1164 "rps", 1302 "rps",
1165 &churn_cb, 1303 &churn_cb,
1166 entry, 1304 entry,
1167 (0 > delta) ? 0 : 1); 1305 (PEER_GO_OFFLINE == delta) ? 0 : 1);
1168 } 1306 }
1307 rps_peers[j].entry_op_manage = entry;
1169} 1308}
1170 1309
1171 1310
@@ -1180,9 +1319,15 @@ churn (void *cls)
1180 double portion_go_online; 1319 double portion_go_online;
1181 double portion_go_offline; 1320 double portion_go_offline;
1182 1321
1322 if (GNUNET_YES == in_shutdown)
1323 {
1324 return;
1325 }
1183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1326 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1184 "Churn function executing\n"); 1327 "Churn function executing\n");
1185 1328
1329 churn_task = NULL; /* Should be invalid by now */
1330
1186 /* Compute the probability for an online peer to go offline 1331 /* Compute the probability for an online peer to go offline
1187 * this round */ 1332 * this round */
1188 portion_online = num_peers_online * 1.0 / num_peers; 1333 portion_online = num_peers_online * 1.0 / num_peers;
@@ -1290,6 +1435,11 @@ profiler_reply_handle (void *cls,
1290static void 1435static void
1291profiler_cb (struct RPSPeer *rps_peer) 1436profiler_cb (struct RPSPeer *rps_peer)
1292{ 1437{
1438 if (GNUNET_YES == in_shutdown)
1439 {
1440 return;
1441 }
1442
1293 /* Start churn */ 1443 /* Start churn */
1294 if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) 1444 if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task)
1295 { 1445 {
@@ -1426,6 +1576,7 @@ run (void *cls,
1426 entry); 1576 entry);
1427 } 1577 }
1428 1578
1579 /* Bring peers up */
1429 num_mal_peers = round (portion * num_peers); 1580 num_mal_peers = round (portion * num_peers);
1430 GNUNET_assert (num_peers == n_peers); 1581 GNUNET_assert (num_peers == n_peers);
1431 for (i = 0; i < n_peers; i++) 1582 for (i = 0; i < n_peers; i++)
@@ -1448,7 +1599,7 @@ run (void *cls,
1448 1599
1449 if (NULL != churn_task) 1600 if (NULL != churn_task)
1450 GNUNET_SCHEDULER_cancel (churn_task); 1601 GNUNET_SCHEDULER_cancel (churn_task);
1451 GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); 1602 shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL);
1452} 1603}
1453 1604
1454 1605
@@ -1609,14 +1760,21 @@ main (int argc, char *argv[])
1609 with the malicious portion */ 1760 with the malicious portion */
1610 1761
1611 ok = 1; 1762 ok = 1;
1612 (void) GNUNET_TESTBED_test_run (cur_test_run.name, 1763 ret_value = GNUNET_TESTBED_test_run (cur_test_run.name,
1613 "test_rps.conf", 1764 "test_rps.conf",
1614 num_peers, 1765 num_peers,
1615 0, NULL, NULL, 1766 0, NULL, NULL,
1616 &run, NULL); 1767 &run, NULL);
1768 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1769 "_test_run returned.\n");
1770 if (GNUNET_OK != ret_value)
1771 {
1772 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1773 "Test did not run successfully!\n");
1774 }
1617 1775
1618 ret_value = cur_test_run.eval_cb(); 1776 ret_value = cur_test_run.eval_cb();
1619 GNUNET_free (rps_peers ); 1777 GNUNET_free (rps_peers);
1620 GNUNET_free (rps_peer_ids); 1778 GNUNET_free (rps_peer_ids);
1621 GNUNET_CONTAINER_multipeermap_destroy (peer_map); 1779 GNUNET_CONTAINER_multipeermap_destroy (peer_map);
1622 return ret_value; 1780 return ret_value;
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index 9586dcf27..219cc6235 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -389,10 +389,11 @@ get_ibf_key (const struct GNUNET_HashCode *src)
389 struct IBF_Key key; 389 struct IBF_Key key;
390 uint16_t salt = 0; 390 uint16_t salt = 0;
391 391
392 GNUNET_CRYPTO_kdf (&key, sizeof (key), 392 GNUNET_assert (GNUNET_OK ==
393 src, sizeof *src, 393 GNUNET_CRYPTO_kdf (&key, sizeof (key),
394 &salt, sizeof (salt), 394 src, sizeof *src,
395 NULL, 0); 395 &salt, sizeof (salt),
396 NULL, 0));
396 return key; 397 return key;
397} 398}
398 399
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c
index 5b2a8ba9b..31e3a3dc2 100644
--- a/src/social/gnunet-service-social.c
+++ b/src/social/gnunet-service-social.c
@@ -503,17 +503,18 @@ cleanup_guest (struct Guest *gst)
503 struct GNUNET_CONTAINER_MultiHashMap * 503 struct GNUNET_CONTAINER_MultiHashMap *
504 plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, 504 plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests,
505 &plc->pub_key_hash); 505 &plc->pub_key_hash);
506 GNUNET_assert (NULL != plc_gst); 506 if (NULL != plc_gst)
507 GNUNET_CONTAINER_multihashmap_remove (plc_gst, &plc->ego_pub_hash, gst);
508
509 if (0 == GNUNET_CONTAINER_multihashmap_size (plc_gst))
510 { 507 {
511 GNUNET_CONTAINER_multihashmap_remove (place_guests, &plc->pub_key_hash, 508 GNUNET_CONTAINER_multihashmap_remove (plc_gst, &plc->ego_pub_hash, gst);
512 plc_gst); 509
513 GNUNET_CONTAINER_multihashmap_destroy (plc_gst); 510 if (0 == GNUNET_CONTAINER_multihashmap_size (plc_gst))
511 {
512 GNUNET_CONTAINER_multihashmap_remove (place_guests, &plc->pub_key_hash,
513 plc_gst);
514 GNUNET_CONTAINER_multihashmap_destroy (plc_gst);
515 }
514 } 516 }
515 GNUNET_CONTAINER_multihashmap_remove (guests, &plc->pub_key_hash, gst); 517 GNUNET_CONTAINER_multihashmap_remove (guests, &plc->pub_key_hash, gst);
516
517 if (NULL != gst->join_req) 518 if (NULL != gst->join_req)
518 GNUNET_free (gst->join_req); 519 GNUNET_free (gst->join_req);
519 if (NULL != gst->relays) 520 if (NULL != gst->relays)
@@ -1391,19 +1392,27 @@ msg_proc_parse (const struct MsgProcRequest *mpreq,
1391 const char **method_prefix, 1392 const char **method_prefix,
1392 struct GNUNET_HashCode *method_hash) 1393 struct GNUNET_HashCode *method_hash)
1393{ 1394{
1394 uint8_t method_size = ntohs (mpreq->header.size) - sizeof (*mpreq); 1395 ssize_t method_size = ntohs (mpreq->header.size) - sizeof (*mpreq);
1395 uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &mpreq[1], 1396 uint16_t offset;
1396 method_size, 1, method_prefix);
1397 1397
1398 if (0 == offset || offset != method_size || *method_prefix == NULL) 1398 if (method_size < 0)
1399 { 1399 {
1400 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1400 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1401 "offset = %u, method_size = %u, method_name = %s\n", 1401 "MsgProcRequest has invalid size\n");
1402 offset, method_size, *method_prefix);
1403 return GNUNET_SYSERR; 1402 return GNUNET_SYSERR;
1404 } 1403 }
1405 1404
1406 GNUNET_CRYPTO_hash (*method_prefix, method_size, method_hash); 1405 offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &mpreq[1],
1406 method_size,
1407 1,
1408 method_prefix);
1409 if (0 == offset || offset != method_size || *method_prefix == NULL)
1410 {
1411 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1412 "MsgProcRequest contains invalid method\n");
1413 return GNUNET_SYSERR;
1414 }
1415 GNUNET_CRYPTO_hash (*method_prefix, (size_t) method_size, method_hash);
1407 *flags = ntohl (mpreq->flags); 1416 *flags = ntohl (mpreq->flags);
1408 return GNUNET_OK; 1417 return GNUNET_OK;
1409} 1418}
@@ -1755,6 +1764,7 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1755 struct GNUNET_CONTAINER_MultiHashMap * 1764 struct GNUNET_CONTAINER_MultiHashMap *
1756 plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, &place_pub_hash); 1765 plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, &place_pub_hash);
1757 struct Guest *gst = NULL; 1766 struct Guest *gst = NULL;
1767 int new_guest;
1758 1768
1759 if (NULL != plc_gst) 1769 if (NULL != plc_gst)
1760 gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash); 1770 gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash);
@@ -1763,9 +1773,12 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1763 "plc_gst = %p, gst = %p\n", 1773 "plc_gst = %p, gst = %p\n",
1764 plc_gst, 1774 plc_gst,
1765 gst); 1775 gst);
1776
1777 new_guest = GNUNET_NO;
1766 if (NULL == gst) 1778 if (NULL == gst)
1767 { 1779 {
1768 gst = GNUNET_new (struct Guest); 1780 gst = GNUNET_new (struct Guest);
1781 new_guest = GNUNET_YES;
1769 } 1782 }
1770 if (NULL == gst->slave) 1783 if (NULL == gst->slave)
1771 { 1784 {
@@ -1841,6 +1854,9 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1841 plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); 1854 plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES);
1842 (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, 1855 (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst,
1843 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1856 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1857 }
1858 if (GNUNET_YES == new_guest)
1859 {
1844 (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, 1860 (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst,
1845 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1861 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1846 (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst, 1862 (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst,
@@ -1862,6 +1878,7 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1862 ret = GNUNET_YES; 1878 ret = GNUNET_YES;
1863 } 1879 }
1864 1880
1881 // TODO: explain why free(gst) not necessary
1865 if (NULL != ret_gst) 1882 if (NULL != ret_gst)
1866 *ret_gst = gst; 1883 *ret_gst = gst;
1867 return ret; 1884 return ret;
@@ -2134,20 +2151,34 @@ handle_client_app_connect (void *cls,
2134{ 2151{
2135 struct Client *c = cls; 2152 struct Client *c = cls;
2136 struct GNUNET_SERVICE_Client *client = c->client; 2153 struct GNUNET_SERVICE_Client *client = c->client;
2137 2154 ssize_t app_id_size = ntohs (creq->header.size) - sizeof (*creq);
2138 uint8_t app_id_size = ntohs (creq->header.size) - sizeof (*creq);
2139 const char *app_id = NULL; 2155 const char *app_id = NULL;
2140 uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &creq[1], 2156 uint16_t offset;
2141 app_id_size, 1, &app_id); 2157
2158 if (app_id_size < 0)
2159 {
2160 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2161 "AppConnectRequest has invalid size\n");
2162 GNUNET_break (0);
2163 GNUNET_SERVICE_client_drop (client);
2164 return;
2165 }
2166
2167 offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &creq[1],
2168 (size_t) app_id_size,
2169 1,
2170 &app_id);
2142 if (0 == offset || offset != app_id_size) 2171 if (0 == offset || offset != app_id_size)
2143 { 2172 {
2173 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2174 "AppConnectRequest contains invalid app ID\n");
2144 GNUNET_break (0); 2175 GNUNET_break (0);
2145 GNUNET_SERVICE_client_drop (client); 2176 GNUNET_SERVICE_client_drop (client);
2146 return; 2177 return;
2147 } 2178 }
2148 2179
2149 struct GNUNET_HashCode app_id_hash; 2180 struct GNUNET_HashCode app_id_hash;
2150 GNUNET_CRYPTO_hash (app_id, app_id_size, &app_id_hash); 2181 GNUNET_CRYPTO_hash (app_id, (size_t) app_id_size, &app_id_hash);
2151 2182
2152 GNUNET_CONTAINER_multihashmap_iterate (egos, ego_entry, client); 2183 GNUNET_CONTAINER_multihashmap_iterate (egos, ego_entry, client);
2153 app_notify_ego_end (client); 2184 app_notify_ego_end (client);
@@ -2172,8 +2203,8 @@ handle_client_app_connect (void *cls,
2172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2173 "%p Application %s connected.\n", app, app_id); 2204 "%p Application %s connected.\n", app, app_id);
2174 2205
2175 c->app_id = GNUNET_malloc (app_id_size); 2206 c->app_id = GNUNET_malloc ((size_t) app_id_size);
2176 GNUNET_memcpy (c->app_id, app_id, app_id_size); 2207 GNUNET_memcpy (c->app_id, app_id, (size_t) app_id_size);
2177 2208
2178 GNUNET_SERVICE_client_continue (client); 2209 GNUNET_SERVICE_client_continue (client);
2179} 2210}
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 8d3e47f94..2bf07bcd7 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -1137,9 +1137,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
1137 * our own receive rate and informs the neighbour about 1137 * our own receive rate and informs the neighbour about
1138 * the new quota. 1138 * the new quota.
1139 * 1139 *
1140 * @param n neighbour entry to change qutoa for 1140 * @param n neighbour entry to change quota for
1141 * @param quota new quota 1141 * @param quota new quota
1142 * @return #GNUNET_YES if @a n is still valid, @GNUNET_NO if 1142 * @return #GNUNET_YES if @a n is still valid, #GNUNET_NO if
1143 * @a n was freed 1143 * @a n was freed
1144 */ 1144 */
1145static int 1145static int
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index c5d6e6d34..8b00543c3 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -3351,9 +3351,10 @@ handle_tcp_data (void *cls,
3351 void *vaddr = NULL; 3351 void *vaddr = NULL;
3352 size_t alen; 3352 size_t alen;
3353 3353
3354 GNUNET_SERVER_client_get_address (client, 3354 GNUNET_assert (GNUNET_OK ==
3355 &vaddr, 3355 GNUNET_SERVER_client_get_address (client,
3356 &alen); 3356 &vaddr,
3357 &alen));
3357 LOG (GNUNET_ERROR_TYPE_ERROR, 3358 LOG (GNUNET_ERROR_TYPE_ERROR,
3358 "Received unexpected %u bytes of type %u from `%s'\n", 3359 "Received unexpected %u bytes of type %u from `%s'\n",
3359 (unsigned int) ntohs (message->size), 3360 (unsigned int) ntohs (message->size),
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c
index be2538c3f..1c55d72b5 100644
--- a/src/util/common_allocation.c
+++ b/src/util/common_allocation.c
@@ -475,8 +475,8 @@ GNUNET_xgrow_ (void **old,
475 */ 475 */
476int 476int
477GNUNET_asprintf (char **buf, 477GNUNET_asprintf (char **buf,
478 const char *format, 478 const char *format,
479 ...) 479 ...)
480{ 480{
481 int ret; 481 int ret;
482 va_list args; 482 va_list args;
@@ -484,6 +484,7 @@ GNUNET_asprintf (char **buf,
484 va_start (args, format); 484 va_start (args, format);
485 ret = VSNPRINTF (NULL, 0, format, args); 485 ret = VSNPRINTF (NULL, 0, format, args);
486 va_end (args); 486 va_end (args);
487 GNUNET_assert (ret >= 0);
487 *buf = GNUNET_malloc (ret + 1); 488 *buf = GNUNET_malloc (ret + 1);
488 va_start (args, format); 489 va_start (args, format);
489 ret = VSPRINTF (*buf, format, args); 490 ret = VSPRINTF (*buf, format, args);
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 7f1d98902..25eeaf80f 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -421,7 +421,6 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg,
421 size_t m_size; 421 size_t m_size;
422 size_t c_size; 422 size_t c_size;
423 423
424
425 /* Pass1 : calculate the buffer size required */ 424 /* Pass1 : calculate the buffer size required */
426 m_size = 0; 425 m_size = 0;
427 for (sec = cfg->sections; NULL != sec; sec = sec->next) 426 for (sec = cfg->sections; NULL != sec; sec = sec->next)
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index 20c7ca7ff..cce9cf82a 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -69,9 +69,9 @@ GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
69 char *np; 69 char *np;
70 70
71 np = GNUNET_STRINGS_data_to_string ((const unsigned char *) block, 71 np = GNUNET_STRINGS_data_to_string ((const unsigned char *) block,
72 sizeof (struct GNUNET_HashCode), 72 sizeof (struct GNUNET_HashCode),
73 (char*) result, 73 (char *) result,
74 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1); 74 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1);
75 GNUNET_assert (NULL != np); 75 GNUNET_assert (NULL != np);
76 *np = '\0'; 76 *np = '\0';
77} 77}
diff --git a/src/util/network.c b/src/util/network.c
index 973878f93..0cb1529a6 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -91,8 +91,8 @@ GNUNET_NETWORK_test_pf (int pf)
91 if (EAFNOSUPPORT == errno) 91 if (EAFNOSUPPORT == errno)
92 return GNUNET_NO; 92 return GNUNET_NO;
93 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 93 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
94 "Failed to create test socket: %s\n", 94 "Failed to create test socket: %s\n",
95 STRERROR (errno)); 95 STRERROR (errno));
96 return GNUNET_SYSERR; 96 return GNUNET_SYSERR;
97 } 97 }
98#if WINDOWS 98#if WINDOWS
@@ -128,21 +128,20 @@ GNUNET_NETWORK_shorten_unixpath (char *unixpath)
128 if (slen < upm) 128 if (slen < upm)
129 return unixpath; /* no shortening required */ 129 return unixpath; /* no shortening required */
130 GNUNET_CRYPTO_hash (unixpath, slen, &sh); 130 GNUNET_CRYPTO_hash (unixpath, slen, &sh);
131 while (16 + 131 while (16 + strlen (unixpath) >= upm)
132 strlen (unixpath) >= upm)
133 { 132 {
134 if (NULL == (end = strrchr (unixpath, '/'))) 133 if (NULL == (end = strrchr (unixpath, '/')))
135 { 134 {
136 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 135 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
137 _("Unable to shorten unix path `%s' while keeping name unique\n"), 136 _("Unable to shorten unix path `%s' while keeping name unique\n"),
138 unixpath); 137 unixpath);
139 GNUNET_free (unixpath); 138 GNUNET_free (unixpath);
140 return NULL; 139 return NULL;
141 } 140 }
142 *end = '\0'; 141 *end = '\0';
143 } 142 }
144 GNUNET_CRYPTO_hash_to_enc (&sh, &ae); 143 GNUNET_CRYPTO_hash_to_enc (&sh, &ae);
145 strncat (unixpath, (char*) ae.encoding, 16); 144 strncat (unixpath, (char *) ae.encoding, 16);
146 return unixpath; 145 return unixpath;
147} 146}
148 147
@@ -239,7 +238,6 @@ GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd,
239 int flags = fcntl (fd->fd, F_GETFL); 238 int flags = fcntl (fd->fd, F_GETFL);
240 239
241 if (flags == -1) 240 if (flags == -1)
242
243 { 241 {
244 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, 242 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
245 "fcntl"); 243 "fcntl");
@@ -311,7 +309,7 @@ socket_set_nosigpipe (const struct GNUNET_NETWORK_Handle *h)
311 309
312 if (0 != 310 if (0 !=
313 setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE, 311 setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE,
314 (const void *) &abs_value, 312 (const void *) &abs_value,
315 sizeof (abs_value))) 313 sizeof (abs_value)))
316 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); 314 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "setsockopt");
317} 315}
@@ -342,8 +340,10 @@ socket_set_nodelay (const struct GNUNET_NETWORK_Handle *h)
342 const char *abs_value = "1"; 340 const char *abs_value = "1";
343 341
344 if (0 != 342 if (0 !=
345 setsockopt (h->fd, IPPROTO_TCP, TCP_NODELAY, 343 setsockopt (h->fd,
346 (const void *) abs_value, 344 IPPROTO_TCP,
345 TCP_NODELAY,
346 (const void *) abs_value,
347 sizeof (abs_value))) 347 sizeof (abs_value)))
348 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, 348 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
349 "setsockopt"); 349 "setsockopt");
@@ -365,7 +365,7 @@ socket_set_nodelay (const struct GNUNET_NETWORK_Handle *h)
365 */ 365 */
366static int 366static int
367initialize_network_handle (struct GNUNET_NETWORK_Handle *h, 367initialize_network_handle (struct GNUNET_NETWORK_Handle *h,
368 int af, 368 int af,
369 int type) 369 int type)
370{ 370{
371 int eno; 371 int eno;
@@ -409,7 +409,7 @@ initialize_network_handle (struct GNUNET_NETWORK_Handle *h,
409#ifdef AF_UNIX 409#ifdef AF_UNIX
410 && (af != AF_UNIX) 410 && (af != AF_UNIX)
411#endif 411#endif
412 ) 412 )
413 socket_set_nodelay (h); 413 socket_set_nodelay (h);
414 return GNUNET_OK; 414 return GNUNET_OK;
415} 415}
@@ -426,7 +426,7 @@ initialize_network_handle (struct GNUNET_NETWORK_Handle *h,
426struct GNUNET_NETWORK_Handle * 426struct GNUNET_NETWORK_Handle *
427GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, 427GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc,
428 struct sockaddr *address, 428 struct sockaddr *address,
429 socklen_t *address_len) 429 socklen_t *address_len)
430{ 430{
431 struct GNUNET_NETWORK_Handle *ret; 431 struct GNUNET_NETWORK_Handle *ret;
432 int eno; 432 int eno;
@@ -443,7 +443,7 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc,
443 443
444 if (0 == gsn) 444 if (0 == gsn)
445 LOG (GNUNET_ERROR_TYPE_DEBUG, 445 LOG (GNUNET_ERROR_TYPE_DEBUG,
446 "Accepting connection on `%s'\n", 446 "Accepting connection on `%s'\n",
447 GNUNET_a2s ((const struct sockaddr *) &name, 447 GNUNET_a2s ((const struct sockaddr *) &name,
448 namelen)); 448 namelen));
449 } 449 }
@@ -491,9 +491,11 @@ GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
491 const int on = 1; 491 const int on = 1;
492 492
493 if (AF_INET6 == desc->af) 493 if (AF_INET6 == desc->af)
494 if (setsockopt (desc->fd, IPPROTO_IPV6, IPV6_V6ONLY, 494 if (setsockopt (desc->fd,
495 (const void *) &on, 495 IPPROTO_IPV6,
496 sizeof (on))) 496 IPV6_V6ONLY,
497 (const void *) &on,
498 sizeof (on)))
497 LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, 499 LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG,
498 "setsockopt"); 500 "setsockopt");
499 } 501 }
@@ -593,8 +595,8 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc)
593 if (0 != unlink (dirname)) 595 if (0 != unlink (dirname))
594 { 596 {
595 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, 597 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING,
596 "unlink", 598 "unlink",
597 dirname); 599 dirname);
598 } 600 }
599 else 601 else
600 { 602 {
@@ -1209,8 +1211,8 @@ GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to,
1209 to->handles_size, 1211 to->handles_size,
1210 from->handles_pos * 2); 1212 from->handles_pos * 2);
1211 GNUNET_memcpy (to->handles, 1213 GNUNET_memcpy (to->handles,
1212 from->handles, 1214 from->handles,
1213 from->handles_pos * sizeof (struct GNUNET_NETWORK_Handle *)); 1215 from->handles_pos * sizeof (struct GNUNET_NETWORK_Handle *));
1214 to->handles_pos = from->handles_pos; 1216 to->handles_pos = from->handles_pos;
1215#endif 1217#endif
1216} 1218}
@@ -1327,9 +1329,9 @@ GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds,
1327 int fd; 1329 int fd;
1328 1330
1329 GNUNET_assert (GNUNET_OK == 1331 GNUNET_assert (GNUNET_OK ==
1330 GNUNET_DISK_internal_file_handle_ (h, 1332 GNUNET_DISK_internal_file_handle_ (h,
1331 &fd, 1333 &fd,
1332 sizeof (int))); 1334 sizeof (int)));
1333 FD_SET (fd, 1335 FD_SET (fd,
1334 &fds->sds); 1336 &fds->sds);
1335 fds->nsds = GNUNET_MAX (fd + 1, 1337 fds->nsds = GNUNET_MAX (fd + 1,
@@ -1707,7 +1709,7 @@ initialize_select_thread ()
1707 */ 1709 */
1708int 1710int
1709GNUNET_NETWORK_test_port_free (int ipproto, 1711GNUNET_NETWORK_test_port_free (int ipproto,
1710 uint16_t port) 1712 uint16_t port)
1711{ 1713{
1712 struct GNUNET_NETWORK_Handle *socket; 1714 struct GNUNET_NETWORK_Handle *socket;
1713 int bind_status; 1715 int bind_status;
@@ -1718,37 +1720,35 @@ GNUNET_NETWORK_test_port_free (int ipproto,
1718 struct addrinfo *ai; 1720 struct addrinfo *ai;
1719 1721
1720 GNUNET_snprintf (open_port_str, 1722 GNUNET_snprintf (open_port_str,
1721 sizeof (open_port_str), 1723 sizeof (open_port_str),
1722 "%u", 1724 "%u",
1723 (unsigned int) port); 1725 (unsigned int) port);
1724 socktype = (IPPROTO_TCP == ipproto) 1726 socktype = (IPPROTO_TCP == ipproto) ? SOCK_STREAM : SOCK_DGRAM;
1725 ? SOCK_STREAM
1726 : SOCK_DGRAM;
1727 ret = NULL; 1727 ret = NULL;
1728 memset (&hint, 0, sizeof (hint)); 1728 memset (&hint, 0, sizeof (hint));
1729 hint.ai_family = AF_UNSPEC; /* IPv4 and IPv6 */ 1729 hint.ai_family = AF_UNSPEC; /* IPv4 and IPv6 */
1730 hint.ai_socktype = socktype; 1730 hint.ai_socktype = socktype;
1731 hint.ai_protocol = ipproto; 1731 hint.ai_protocol = ipproto;
1732 hint.ai_addrlen = 0; 1732 hint.ai_addrlen = 0;
1733 hint.ai_addr = NULL; 1733 hint.ai_addr = NULL;
1734 hint.ai_canonname = NULL; 1734 hint.ai_canonname = NULL;
1735 hint.ai_next = NULL; 1735 hint.ai_next = NULL;
1736 hint.ai_flags = AI_PASSIVE | AI_NUMERICSERV; /* Wild card address */ 1736 hint.ai_flags = AI_PASSIVE | AI_NUMERICSERV; /* Wild card address */
1737 GNUNET_assert (0 == getaddrinfo (NULL, 1737 GNUNET_assert (0 == getaddrinfo (NULL,
1738 open_port_str, 1738 open_port_str,
1739 &hint, 1739 &hint,
1740 &ret)); 1740 &ret));
1741 bind_status = GNUNET_NO; 1741 bind_status = GNUNET_NO;
1742 for (ai = ret; NULL != ai; ai = ai->ai_next) 1742 for (ai = ret; NULL != ai; ai = ai->ai_next)
1743 { 1743 {
1744 socket = GNUNET_NETWORK_socket_create (ai->ai_family, 1744 socket = GNUNET_NETWORK_socket_create (ai->ai_family,
1745 ai->ai_socktype, 1745 ai->ai_socktype,
1746 ai->ai_protocol); 1746 ai->ai_protocol);
1747 if (NULL == socket) 1747 if (NULL == socket)
1748 continue; 1748 continue;
1749 bind_status = GNUNET_NETWORK_socket_bind (socket, 1749 bind_status = GNUNET_NETWORK_socket_bind (socket,
1750 ai->ai_addr, 1750 ai->ai_addr,
1751 ai->ai_addrlen); 1751 ai->ai_addrlen);
1752 GNUNET_NETWORK_socket_close (socket); 1752 GNUNET_NETWORK_socket_close (socket);
1753 if (GNUNET_OK != bind_status) 1753 if (GNUNET_OK != bind_status)
1754 break; 1754 break;
@@ -1808,7 +1808,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1808 (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us)); 1808 (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us));
1809 } 1809 }
1810 return select (nfds, 1810 return select (nfds,
1811 (NULL != rfds) ? &rfds->sds : NULL, 1811 (NULL != rfds) ? &rfds->sds : NULL,
1812 (NULL != wfds) ? &wfds->sds : NULL, 1812 (NULL != wfds) ? &wfds->sds : NULL,
1813 (NULL != efds) ? &efds->sds : NULL, 1813 (NULL != efds) ? &efds->sds : NULL,
1814 (timeout.rel_value_us == 1814 (timeout.rel_value_us ==
@@ -2178,7 +2178,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
2178 { 2178 {
2179 LOG (GNUNET_ERROR_TYPE_DEBUG, 2179 LOG (GNUNET_ERROR_TYPE_DEBUG,
2180 "Adding the socket event to the array as %d\n", 2180 "Adding the socket event to the array as %d\n",
2181 nhandles); 2181 nhandles);
2182 handle_array[nhandles++] = select_finished_event; 2182 handle_array[nhandles++] = select_finished_event;
2183 if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) 2183 if (timeout.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
2184 { 2184 {
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index fecbc0de5..9d37231e7 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -756,8 +756,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t,
756 t->fds = fdi; 756 t->fds = fdi;
757 if (1 == read_nh_len) 757 if (1 == read_nh_len)
758 { 758 {
759 GNUNET_assert (NULL != read_nh);
760 GNUNET_assert (NULL != *read_nh);
759 fdi->fd = *read_nh; 761 fdi->fd = *read_nh;
760 GNUNET_assert (NULL != fdi->fd);
761 fdi->et = GNUNET_SCHEDULER_ET_IN; 762 fdi->et = GNUNET_SCHEDULER_ET_IN;
762 fdi->sock = GNUNET_NETWORK_get_fd (*read_nh); 763 fdi->sock = GNUNET_NETWORK_get_fd (*read_nh);
763 t->read_fd = fdi->sock; 764 t->read_fd = fdi->sock;
@@ -765,8 +766,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t,
765 } 766 }
766 else if (1 == write_nh_len) 767 else if (1 == write_nh_len)
767 { 768 {
769 GNUNET_assert (NULL != write_nh);
770 GNUNET_assert (NULL != *write_nh);
768 fdi->fd = *write_nh; 771 fdi->fd = *write_nh;
769 GNUNET_assert (NULL != fdi->fd);
770 fdi->et = GNUNET_SCHEDULER_ET_OUT; 772 fdi->et = GNUNET_SCHEDULER_ET_OUT;
771 fdi->sock = GNUNET_NETWORK_get_fd (*write_nh); 773 fdi->sock = GNUNET_NETWORK_get_fd (*write_nh);
772 t->read_fd = -1; 774 t->read_fd = -1;
@@ -774,8 +776,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t,
774 } 776 }
775 else if (1 == read_fh_len) 777 else if (1 == read_fh_len)
776 { 778 {
779 GNUNET_assert (NULL != read_fh);
780 GNUNET_assert (NULL != *read_fh);
777 fdi->fh = *read_fh; 781 fdi->fh = *read_fh;
778 GNUNET_assert (NULL != fdi->fh);
779 fdi->et = GNUNET_SCHEDULER_ET_IN; 782 fdi->et = GNUNET_SCHEDULER_ET_IN;
780 fdi->sock = (*read_fh)->fd; // FIXME: does not work under WIN32 783 fdi->sock = (*read_fh)->fd; // FIXME: does not work under WIN32
781 t->read_fd = fdi->sock; 784 t->read_fd = fdi->sock;
@@ -783,8 +786,9 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t,
783 } 786 }
784 else 787 else
785 { 788 {
789 GNUNET_assert (NULL != write_fh);
790 GNUNET_assert (NULL != *write_fh);
786 fdi->fh = *write_fh; 791 fdi->fh = *write_fh;
787 GNUNET_assert (NULL != fdi->fh);
788 fdi->et = GNUNET_SCHEDULER_ET_OUT; 792 fdi->et = GNUNET_SCHEDULER_ET_OUT;
789 fdi->sock = (*write_fh)->fd; // FIXME: does not work under WIN32 793 fdi->sock = (*write_fh)->fd; // FIXME: does not work under WIN32
790 t->read_fd = -1; 794 t->read_fd = -1;
@@ -1750,8 +1754,11 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio,
1750 const struct GNUNET_DISK_FileHandle **write_fhandles; 1754 const struct GNUNET_DISK_FileHandle **write_fhandles;
1751 unsigned int read_nhandles_len, write_nhandles_len, 1755 unsigned int read_nhandles_len, write_nhandles_len,
1752 read_fhandles_len, write_fhandles_len; 1756 read_fhandles_len, write_fhandles_len;
1757 int no_fdsets = (NULL == rs) && (NULL == ws);
1758 int no_socket_descriptors =
1759 ((NULL != rs) && (0 == rs->nsds)) && ((NULL != ws) && (0 == ws->nsds));
1753 1760
1754 if (((NULL == rs) && (NULL == ws)) || ((0 == rs->nsds) && (0 == ws->nsds))) 1761 if (no_fdsets || no_socket_descriptors)
1755 return GNUNET_SCHEDULER_add_delayed_with_priority (delay, 1762 return GNUNET_SCHEDULER_add_delayed_with_priority (delay,
1756 prio, 1763 prio,
1757 task, 1764 task,