diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-16 15:21:20 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-16 15:21:20 +0000 |
commit | 03b104dab570998b1f791994a8134d35b4b4dc0a (patch) | |
tree | 98851c89adfbdeef8e0f1a3eff3d1854160ebd48 | |
parent | 7f8e018e0b12b0ecc1a6021020af9e5f84846b02 (diff) | |
download | gnunet-03b104dab570998b1f791994a8134d35b4b4dc0a.tar.gz gnunet-03b104dab570998b1f791994a8134d35b4b4dc0a.zip |
Testing changes required to work with new core api. Revert GNUNET_CORE_iterate_peers call to work properly.
-rw-r--r-- | src/core/Makefile.am | 3 | ||||
-rw-r--r-- | src/core/core_api.c | 6 | ||||
-rw-r--r-- | src/core/core_api_iterate_peers.c | 169 | ||||
-rw-r--r-- | src/core/gnunet-service-core.c | 46 | ||||
-rw-r--r-- | src/dht/gnunet-dht-driver.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_core_service.h | 4 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 4 | ||||
-rw-r--r-- | src/testing/test_testing_data_remote.conf | 8 | ||||
-rw-r--r-- | src/testing/test_testing_data_topology_scale_free.conf | 2 | ||||
-rw-r--r-- | src/testing/test_testing_topology.c | 99 | ||||
-rw-r--r-- | src/testing/testing.c | 4 | ||||
-rw-r--r-- | src/testing/testing_group.c | 9 | ||||
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 4 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp.c | 7 | ||||
-rw-r--r-- | src/util/scheduler.c | 2 |
15 files changed, 333 insertions, 36 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 94db94959..0b8a34ff9 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am | |||
@@ -14,7 +14,8 @@ lib_LTLIBRARIES = \ | |||
14 | libgnunetcore.la | 14 | libgnunetcore.la |
15 | 15 | ||
16 | libgnunetcore_la_SOURCES = \ | 16 | libgnunetcore_la_SOURCES = \ |
17 | core_api.c core.h | 17 | core_api.c core.h \ |
18 | core_api_iterate_peers.c | ||
18 | libgnunetcore_la_LIBADD = \ | 19 | libgnunetcore_la_LIBADD = \ |
19 | $(top_builddir)/src/util/libgnunetutil.la \ | 20 | $(top_builddir)/src/util/libgnunetutil.la \ |
20 | $(GN_LIBINTL) $(XLIB) | 21 | $(GN_LIBINTL) $(XLIB) |
diff --git a/src/core/core_api.c b/src/core/core_api.c index ffffbea92..0fdcacb7a 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -1432,6 +1432,9 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, | |||
1432 | if (NULL == pr) | 1432 | if (NULL == pr) |
1433 | { | 1433 | { |
1434 | /* attempt to send to peer that is not connected */ | 1434 | /* attempt to send to peer that is not connected */ |
1435 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | ||
1436 | "Attempting to send to peer `%s' from peer `%s', but not connected!\n", | ||
1437 | GNUNET_i2s(target), GNUNET_h2s(&handle->me.hashPubKey)); | ||
1435 | GNUNET_break (0); | 1438 | GNUNET_break (0); |
1436 | return NULL; | 1439 | return NULL; |
1437 | } | 1440 | } |
@@ -1839,6 +1842,7 @@ GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequest | |||
1839 | } | 1842 | } |
1840 | 1843 | ||
1841 | 1844 | ||
1845 | #if NEW | ||
1842 | /* ********************* GNUNET_CORE_iterate_peers *********************** */ | 1846 | /* ********************* GNUNET_CORE_iterate_peers *********************** */ |
1843 | 1847 | ||
1844 | /** | 1848 | /** |
@@ -1903,6 +1907,6 @@ GNUNET_CORE_iterate_peers (struct GNUNET_CORE_Handle *h, | |||
1903 | &ic); | 1907 | &ic); |
1904 | return GNUNET_OK; | 1908 | return GNUNET_OK; |
1905 | } | 1909 | } |
1906 | 1910 | #endif | |
1907 | 1911 | ||
1908 | /* end of core_api.c */ | 1912 | /* end of core_api.c */ |
diff --git a/src/core/core_api_iterate_peers.c b/src/core/core_api_iterate_peers.c new file mode 100644 index 000000000..657768363 --- /dev/null +++ b/src/core/core_api_iterate_peers.c | |||
@@ -0,0 +1,169 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009, 2010 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file core/core_api_iterate_peers.c | ||
23 | * @brief implementation of the peer_iterate function | ||
24 | * @author Christian Grothoff | ||
25 | * @author Nathan Evans | ||
26 | */ | ||
27 | #include "platform.h" | ||
28 | #include "gnunet_core_service.h" | ||
29 | #include "core.h" | ||
30 | |||
31 | |||
32 | struct GNUNET_CORE_RequestContext | ||
33 | { | ||
34 | |||
35 | /** | ||
36 | * Our connection to the service. | ||
37 | */ | ||
38 | struct GNUNET_CLIENT_Connection *client; | ||
39 | |||
40 | /** | ||
41 | * Handle for transmitting a request. | ||
42 | */ | ||
43 | struct GNUNET_CLIENT_TransmitHandle *th; | ||
44 | |||
45 | /** | ||
46 | * Function called with the peer. | ||
47 | */ | ||
48 | GNUNET_CORE_ConnectEventHandler peer_cb; | ||
49 | |||
50 | /** | ||
51 | * Closure for peer_cb. | ||
52 | */ | ||
53 | void *cb_cls; | ||
54 | |||
55 | }; | ||
56 | |||
57 | |||
58 | /** | ||
59 | * Receive reply from core service with information about a peer. | ||
60 | * | ||
61 | * @param cls our 'struct GNUNET_CORE_RequestContext *' | ||
62 | * @param msg NULL on error or last entry | ||
63 | */ | ||
64 | static void | ||
65 | receive_info (void *cls, | ||
66 | const struct GNUNET_MessageHeader *msg) | ||
67 | { | ||
68 | struct GNUNET_CORE_RequestContext *request_context = cls; | ||
69 | const struct ConnectNotifyMessage *connect_message; | ||
70 | |||
71 | |||
72 | /* Handle last message or error case, disconnect and clean up */ | ||
73 | if ( (msg == NULL) || | ||
74 | ((ntohs (msg->type) == GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT) && | ||
75 | (ntohs (msg->size) == sizeof (struct GNUNET_MessageHeader))) ) | ||
76 | { | ||
77 | if (request_context->peer_cb != NULL) | ||
78 | request_context->peer_cb (request_context->cb_cls, | ||
79 | NULL, NULL); | ||
80 | GNUNET_CLIENT_disconnect (request_context->client, GNUNET_NO); | ||
81 | GNUNET_free (request_context); | ||
82 | return; | ||
83 | } | ||
84 | |||
85 | /* Handle incorrect message type or size, disconnect and clean up */ | ||
86 | if ( (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT) || | ||
87 | (ntohs (msg->size) != sizeof (struct ConnectNotifyMessage)) ) | ||
88 | { | ||
89 | GNUNET_break (0); | ||
90 | if (request_context->peer_cb != NULL) | ||
91 | request_context->peer_cb (request_context->cb_cls, | ||
92 | NULL, NULL); | ||
93 | GNUNET_CLIENT_disconnect (request_context->client, GNUNET_NO); | ||
94 | GNUNET_free (request_context); | ||
95 | return; | ||
96 | } | ||
97 | |||
98 | /* Normal case */ | ||
99 | connect_message = (const struct ConnectNotifyMessage *) msg; | ||
100 | if (request_context->peer_cb != NULL) | ||
101 | request_context->peer_cb (request_context->cb_cls, | ||
102 | &connect_message->peer, | ||
103 | NULL); | ||
104 | |||
105 | GNUNET_CLIENT_receive(request_context->client, &receive_info, request_context, GNUNET_TIME_relative_get_forever()); | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | * Function called to notify a client about the socket | ||
110 | * begin ready to queue more data. "buf" will be | ||
111 | * NULL and "size" zero if the socket was closed for | ||
112 | * writing in the meantime. | ||
113 | * | ||
114 | * @param cls closure | ||
115 | * @param size number of bytes available in buf | ||
116 | * @param buf where the callee should write the message | ||
117 | * @return number of bytes written to buf | ||
118 | */ | ||
119 | static size_t | ||
120 | transmit_request(void *cls, | ||
121 | size_t size, void *buf) | ||
122 | { | ||
123 | struct GNUNET_MessageHeader *msg; | ||
124 | if ((size < sizeof(struct GNUNET_MessageHeader)) || (buf == NULL)) | ||
125 | return 0; | ||
126 | |||
127 | msg = (struct GNUNET_MessageHeader *)buf; | ||
128 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); | ||
129 | msg->type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS); | ||
130 | return sizeof(struct GNUNET_MessageHeader); | ||
131 | } | ||
132 | |||
133 | /** | ||
134 | * Obtain statistics and/or change preferences for the given peer. | ||
135 | * | ||
136 | * @param sched scheduler to use | ||
137 | * @param cfg configuration to use | ||
138 | * @param peer_cb function to call with the peer information | ||
139 | * @param cb_cls closure for peer_cb | ||
140 | * @return GNUNET_OK if iterating, GNUNET_SYSERR on error | ||
141 | */ | ||
142 | int | ||
143 | GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
144 | GNUNET_CORE_ConnectEventHandler peer_cb, | ||
145 | void *cb_cls) | ||
146 | { | ||
147 | struct GNUNET_CORE_RequestContext *request_context; | ||
148 | struct GNUNET_CLIENT_Connection *client; | ||
149 | |||
150 | client = GNUNET_CLIENT_connect ("core", cfg); | ||
151 | if (client == NULL) | ||
152 | return GNUNET_SYSERR; | ||
153 | request_context = GNUNET_malloc (sizeof (struct GNUNET_CORE_RequestContext)); | ||
154 | request_context->client = client; | ||
155 | request_context->peer_cb = peer_cb; | ||
156 | request_context->cb_cls = cb_cls; | ||
157 | |||
158 | request_context->th = GNUNET_CLIENT_notify_transmit_ready(client, | ||
159 | sizeof(struct GNUNET_MessageHeader), | ||
160 | GNUNET_TIME_relative_get_forever(), | ||
161 | GNUNET_YES, | ||
162 | &transmit_request, | ||
163 | NULL); | ||
164 | |||
165 | GNUNET_CLIENT_receive(client, &receive_info, request_context, GNUNET_TIME_relative_get_forever()); | ||
166 | return GNUNET_OK; | ||
167 | } | ||
168 | |||
169 | /* end of core_api_iterate_peers.c */ | ||
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 29f084d04..bfb17b6c8 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -1307,6 +1307,49 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
1307 | 1307 | ||
1308 | 1308 | ||
1309 | /** | 1309 | /** |
1310 | * Handle CORE_ITERATE_PEERS request. | ||
1311 | */ | ||
1312 | static void | ||
1313 | handle_client_iterate_peers (void *cls, | ||
1314 | struct GNUNET_SERVER_Client *client, | ||
1315 | const struct GNUNET_MessageHeader *message) | ||
1316 | |||
1317 | { | ||
1318 | struct Neighbour *n; | ||
1319 | struct ConnectNotifyMessage cnm; | ||
1320 | struct GNUNET_MessageHeader done_msg; | ||
1321 | struct GNUNET_SERVER_TransmitContext *tc; | ||
1322 | |||
1323 | /* notify new client about existing neighbours */ | ||
1324 | cnm.header.size = htons (sizeof (struct ConnectNotifyMessage)); | ||
1325 | cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT); | ||
1326 | done_msg.size = htons (sizeof (struct GNUNET_MessageHeader)); | ||
1327 | done_msg.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT); | ||
1328 | tc = GNUNET_SERVER_transmit_context_create (client); | ||
1329 | n = neighbours; | ||
1330 | cnm.ats_count = htonl (0); | ||
1331 | cnm.ats.type = htonl (0); | ||
1332 | cnm.ats.value = htonl (0); | ||
1333 | while (n != NULL) | ||
1334 | { | ||
1335 | if (n->status == PEER_STATE_KEY_CONFIRMED) | ||
1336 | { | ||
1337 | #if DEBUG_CORE_CLIENT | ||
1338 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1339 | "Sending `%s' message to client.\n", "NOTIFY_CONNECT"); | ||
1340 | #endif | ||
1341 | cnm.peer = n->peer; | ||
1342 | GNUNET_SERVER_transmit_context_append_message (tc, &cnm.header); | ||
1343 | } | ||
1344 | n = n->next; | ||
1345 | } | ||
1346 | GNUNET_SERVER_transmit_context_append_message (tc, &done_msg); | ||
1347 | GNUNET_SERVER_transmit_context_run (tc, | ||
1348 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
1349 | } | ||
1350 | |||
1351 | |||
1352 | /** | ||
1310 | * Handle REQUEST_INFO request. | 1353 | * Handle REQUEST_INFO request. |
1311 | */ | 1354 | */ |
1312 | static void | 1355 | static void |
@@ -4191,6 +4234,9 @@ run (void *cls, | |||
4191 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 4234 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
4192 | {&handle_client_init, NULL, | 4235 | {&handle_client_init, NULL, |
4193 | GNUNET_MESSAGE_TYPE_CORE_INIT, 0}, | 4236 | GNUNET_MESSAGE_TYPE_CORE_INIT, 0}, |
4237 | {&handle_client_iterate_peers, NULL, | ||
4238 | GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS, | ||
4239 | sizeof (struct GNUNET_MessageHeader)}, | ||
4194 | {&handle_client_request_info, NULL, | 4240 | {&handle_client_request_info, NULL, |
4195 | GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO, | 4241 | GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO, |
4196 | sizeof (struct RequestInfoMessage)}, | 4242 | sizeof (struct RequestInfoMessage)}, |
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index 8f1081a7a..c6666b23d 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c | |||
@@ -2758,7 +2758,7 @@ run (void *cls, | |||
2758 | buf = &data[count + 1]; | 2758 | buf = &data[count + 1]; |
2759 | } | 2759 | } |
2760 | } | 2760 | } |
2761 | 2761 | GNUNET_free(data); | |
2762 | if (GNUNET_OK != | 2762 | if (GNUNET_OK != |
2763 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "malicious_getters", | 2763 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "malicious_getters", |
2764 | &malicious_getters)) | 2764 | &malicious_getters)) |
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index abfcd1d3b..8c57b23b7 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h | |||
@@ -357,13 +357,13 @@ GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequest | |||
357 | /** | 357 | /** |
358 | * Iterate over all connected peers. | 358 | * Iterate over all connected peers. |
359 | * | 359 | * |
360 | * @param h core handle | 360 | * @param cfg configuration handle |
361 | * @param peer_cb function to call with the peer information | 361 | * @param peer_cb function to call with the peer information |
362 | * @param cb_cls closure for peer_cb | 362 | * @param cb_cls closure for peer_cb |
363 | * @return GNUNET_OK on success, GNUNET_SYSERR on errors | 363 | * @return GNUNET_OK on success, GNUNET_SYSERR on errors |
364 | */ | 364 | */ |
365 | int | 365 | int |
366 | GNUNET_CORE_iterate_peers (struct GNUNET_CORE_Handle *h, | 366 | GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, |
367 | GNUNET_CORE_ConnectEventHandler peer_cb, | 367 | GNUNET_CORE_ConnectEventHandler peer_cb, |
368 | void *cb_cls); | 368 | void *cb_cls); |
369 | 369 | ||
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 4d9fec4ca..e9eee668a 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -377,6 +377,10 @@ extern "C" | |||
377 | */ | 377 | */ |
378 | #define GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONNECT 77 | 378 | #define GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONNECT 77 |
379 | 379 | ||
380 | /** | ||
381 | * Request for peer iteration from CORE service. | ||
382 | */ | ||
383 | #define GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS 78 | ||
380 | 384 | ||
381 | /** | 385 | /** |
382 | * Session key exchange between peers. | 386 | * Session key exchange between peers. |
diff --git a/src/testing/test_testing_data_remote.conf b/src/testing/test_testing_data_remote.conf index 3c28c5ece..df036c49e 100644 --- a/src/testing/test_testing_data_remote.conf +++ b/src/testing/test_testing_data_remote.conf | |||
@@ -1,6 +1,6 @@ | |||
1 | PATHS] | 1 | [PATHS] |
2 | SERVICEHOME = /tmp/test-gnunet-testing/ | 2 | SERVICEHOME = /tmp/test-gnunet-testing/ |
3 | DEFAULTCONFIG = test_testing_data.conf | 3 | DEFAULTCONFIG = test_testing_data_remote.conf |
4 | 4 | ||
5 | [resolver] | 5 | [resolver] |
6 | PORT = 2564 | 6 | PORT = 2564 |
@@ -16,6 +16,7 @@ PORT = 2566 | |||
16 | DEFAULTSERVICES = | 16 | DEFAULTSERVICES = |
17 | 17 | ||
18 | [statistics] | 18 | [statistics] |
19 | AUTOSTART = NO | ||
19 | PORT = 2567 | 20 | PORT = 2567 |
20 | 21 | ||
21 | [transport-tcp] | 22 | [transport-tcp] |
@@ -29,8 +30,9 @@ PORT = 2570 | |||
29 | 30 | ||
30 | [testing] | 31 | [testing] |
31 | CONTROL_HOST = 131.159.20.42 | 32 | CONTROL_HOST = 131.159.20.42 |
32 | HOSTS = 127.0.0.1 | 33 | HOSTFILE = remote_hosts.txt |
33 | WEAKRANDOM = YES | 34 | WEAKRANDOM = YES |
35 | NUM_PEERS = 2 | ||
34 | 36 | ||
35 | [dht] | 37 | [dht] |
36 | AUTOSTART = NO | 38 | AUTOSTART = NO |
diff --git a/src/testing/test_testing_data_topology_scale_free.conf b/src/testing/test_testing_data_topology_scale_free.conf index abf86e3d9..1a104b88b 100644 --- a/src/testing/test_testing_data_topology_scale_free.conf +++ b/src/testing/test_testing_data_topology_scale_free.conf | |||
@@ -40,7 +40,7 @@ PORT = 2570 | |||
40 | #DEBUG = YES | 40 | #DEBUG = YES |
41 | 41 | ||
42 | [testing] | 42 | [testing] |
43 | NUM_PEERS = 500 | 43 | NUM_PEERS = 50 |
44 | WEAKRANDOM = YES | 44 | WEAKRANDOM = YES |
45 | TOPOLOGY = SCALE_FREE | 45 | TOPOLOGY = SCALE_FREE |
46 | F2F = YES | 46 | F2F = YES |
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index 36ccad6c9..f9d5fb9af 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c | |||
@@ -142,6 +142,12 @@ struct TestMessageContext | |||
142 | /* Identifier for this message, so we don't disconnect other peers! */ | 142 | /* Identifier for this message, so we don't disconnect other peers! */ |
143 | uint32_t uid; | 143 | uint32_t uid; |
144 | 144 | ||
145 | /* Has peer1 been notified already of a connection to peer2? */ | ||
146 | int peer1notified; | ||
147 | |||
148 | /* Has the core of peer2 been connected already? */ | ||
149 | int peer2connected; | ||
150 | |||
145 | /* Task for disconnecting cores, allow task to be cancelled on shutdown */ | 151 | /* Task for disconnecting cores, allow task to be cancelled on shutdown */ |
146 | GNUNET_SCHEDULER_TaskIdentifier disconnect_task; | 152 | GNUNET_SCHEDULER_TaskIdentifier disconnect_task; |
147 | 153 | ||
@@ -364,6 +370,7 @@ process_mtype (void *cls, | |||
364 | #endif | 370 | #endif |
365 | 371 | ||
366 | total_messages_received++; | 372 | total_messages_received++; |
373 | |||
367 | #if VERBOSE > 1 | 374 | #if VERBOSE > 1 |
368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
369 | "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), | 376 | "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), |
@@ -491,33 +498,89 @@ init_notify_peer2 (void *cls, | |||
491 | { | 498 | { |
492 | struct TestMessageContext *pos = cls; | 499 | struct TestMessageContext *pos = cls; |
493 | 500 | ||
501 | total_server_connections++; | ||
502 | |||
503 | pos->peer2connected = GNUNET_YES; | ||
504 | if (pos->peer1notified == GNUNET_YES) /* Peer 1 has been notified of connection to peer 2 */ | ||
505 | { | ||
494 | #if VERBOSE > 1 | 506 | #if VERBOSE > 1 |
495 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
496 | "Core connection to `%4s' established, scheduling message send\n", | 508 | "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", |
497 | GNUNET_i2s (my_identity)); | 509 | GNUNET_i2s (my_identity), GNUNET_h2s(&pos->peer1->id.hashPubKey)); |
498 | #endif | 510 | #endif |
499 | total_server_connections++; | 511 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, |
512 | 0, | ||
513 | TIMEOUT, | ||
514 | &pos->peer2->id, | ||
515 | sizeof (struct | ||
516 | GNUNET_TestMessage), | ||
517 | &transmit_ready, pos)) | ||
518 | { | ||
519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
520 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | ||
521 | GNUNET_i2s (&pos->peer2->id)); | ||
522 | transmit_ready_failed++; | ||
523 | } | ||
524 | else | ||
525 | { | ||
526 | transmit_ready_scheduled++; | ||
527 | } | ||
528 | } | ||
529 | } | ||
530 | |||
531 | /** | ||
532 | * Method called whenever a given peer connects. | ||
533 | * | ||
534 | * @param cls closure | ||
535 | * @param peer peer identity this notification is about | ||
536 | * @param atsi performance data for the connection | ||
537 | */ | ||
538 | static void connect_notify_peers (void *cls, | ||
539 | const struct | ||
540 | GNUNET_PeerIdentity *peer, | ||
541 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | ||
542 | { | ||
543 | struct TestMessageContext *pos = cls; | ||
500 | 544 | ||
501 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, | 545 | if (0 == memcmp(peer, &pos->peer2->id, sizeof(struct GNUNET_PeerIdentity))) |
502 | 0, | ||
503 | TIMEOUT, | ||
504 | &pos->peer2->id, | ||
505 | sizeof (struct | ||
506 | GNUNET_TestMessage), | ||
507 | &transmit_ready, pos)) | ||
508 | { | 546 | { |
547 | pos->peer1notified = GNUNET_YES; | ||
548 | #if VERBOSE > 1 | ||
509 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
510 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | 550 | "Peer `%s' notified of connection to peer `%s'\n", |
511 | GNUNET_i2s (&pos->peer2->id)); | 551 | GNUNET_i2s (&pos->peer1->id), GNUNET_h2s(&peer->hashPubKey)); |
512 | transmit_ready_failed++; | 552 | #endif |
513 | } | 553 | } |
514 | else | 554 | else |
555 | return; | ||
556 | |||
557 | if (pos->peer2connected == GNUNET_YES) /* Already connected and notified of connection, send message! */ | ||
515 | { | 558 | { |
516 | transmit_ready_scheduled++; | 559 | #if VERBOSE > 1 |
560 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
561 | "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", | ||
562 | GNUNET_i2s (&pos->peer2->id), GNUNET_h2s(&pos->peer1->id.hashPubKey)); | ||
563 | #endif | ||
564 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, | ||
565 | 0, | ||
566 | TIMEOUT, | ||
567 | &pos->peer2->id, | ||
568 | sizeof (struct | ||
569 | GNUNET_TestMessage), | ||
570 | &transmit_ready, pos)) | ||
571 | { | ||
572 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
573 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | ||
574 | GNUNET_i2s (&pos->peer2->id)); | ||
575 | transmit_ready_failed++; | ||
576 | } | ||
577 | else | ||
578 | { | ||
579 | transmit_ready_scheduled++; | ||
580 | } | ||
517 | } | 581 | } |
518 | } | 582 | } |
519 | 583 | ||
520 | |||
521 | static void | 584 | static void |
522 | init_notify_peer1 (void *cls, | 585 | init_notify_peer1 (void *cls, |
523 | struct GNUNET_CORE_Handle *server, | 586 | struct GNUNET_CORE_Handle *server, |
@@ -585,7 +648,7 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
585 | 1, | 648 | 1, |
586 | pos, | 649 | pos, |
587 | &init_notify_peer1, | 650 | &init_notify_peer1, |
588 | NULL, NULL, | 651 | &connect_notify_peers, NULL, |
589 | NULL, | 652 | NULL, |
590 | NULL, | 653 | NULL, |
591 | GNUNET_NO, NULL, GNUNET_NO, | 654 | GNUNET_NO, NULL, GNUNET_NO, |
@@ -639,7 +702,7 @@ topology_callback (void *cls, | |||
639 | #endif | 702 | #endif |
640 | total_connections++; | 703 | total_connections++; |
641 | #if VERBOSE > 1 | 704 | #if VERBOSE > 1 |
642 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s\n", | 705 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "connected peer %s to peer %s\n", |
643 | first_daemon->shortname, second_daemon->shortname); | 706 | first_daemon->shortname, second_daemon->shortname); |
644 | #endif | 707 | #endif |
645 | temp_context = GNUNET_malloc (sizeof (struct TestMessageContext)); | 708 | temp_context = GNUNET_malloc (sizeof (struct TestMessageContext)); |
diff --git a/src/testing/testing.c b/src/testing/testing.c index 84493410a..3d1a74e0e 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -1533,10 +1533,12 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1533 | ctx->max_connect_attempts + 1), | 1533 | ctx->max_connect_attempts + 1), |
1534 | &ctx->d2->id, | 1534 | &ctx->d2->id, |
1535 | &core_connect_request_cont, ctx); | 1535 | &core_connect_request_cont, ctx); |
1536 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1536 | #if DEBUG_TESTING |
1537 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1537 | "Sending connect request to CORE of %s for peer %s\n", | 1538 | "Sending connect request to CORE of %s for peer %s\n", |
1538 | GNUNET_i2s (&ctx->d1->id), | 1539 | GNUNET_i2s (&ctx->d1->id), |
1539 | GNUNET_h2s (&ctx->d2->id.hashPubKey)); | 1540 | GNUNET_h2s (&ctx->d2->id.hashPubKey)); |
1541 | #endif | ||
1540 | ctx->timeout_hello = | 1542 | ctx->timeout_hello = |
1541 | GNUNET_TIME_relative_add (ctx->timeout_hello, | 1543 | GNUNET_TIME_relative_add (ctx->timeout_hello, |
1542 | GNUNET_TIME_relative_multiply | 1544 | GNUNET_TIME_relative_multiply |
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 9c0dbd8fa..e74d5b9ef 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -3421,12 +3421,15 @@ schedule_get_topology (void *cls, | |||
3421 | outstanding_connects); | 3421 | outstanding_connects); |
3422 | #endif | 3422 | #endif |
3423 | topology_context->connected++; | 3423 | topology_context->connected++; |
3424 | |||
3424 | if (GNUNET_OK != | 3425 | if (GNUNET_OK != |
3425 | GNUNET_CORE_iterate_peers (core_context->daemon->server, | 3426 | GNUNET_CORE_iterate_peers (core_context->daemon->cfg, |
3426 | &internal_topology_callback, | 3427 | &internal_topology_callback, |
3427 | core_context)) | 3428 | core_context)) |
3428 | internal_topology_callback (core_context, NULL, NULL); | 3429 | { |
3429 | 3430 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Topology iteration failed.\n"); | |
3431 | internal_topology_callback (core_context, NULL, NULL); | ||
3432 | } | ||
3430 | } | 3433 | } |
3431 | } | 3434 | } |
3432 | 3435 | ||
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index ba07fcb48..9ef606f68 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -2528,7 +2528,9 @@ libgnunet_plugin_transport_tcp_init (void *cls) | |||
2528 | GNUNET_SERVER_disconnect_notify (plugin->server, | 2528 | GNUNET_SERVER_disconnect_notify (plugin->server, |
2529 | &disconnect_notify, | 2529 | &disconnect_notify, |
2530 | plugin); | 2530 | plugin); |
2531 | GNUNET_CONFIGURATION_get_value_string(env->cfg, "transport-tcp", "BINDTO", &plugin->bind_address); | 2531 | |
2532 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-tcp", "BINDTO", &plugin->bind_address)) | ||
2533 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Binding tcp plugin to specific address: `%s'\n", plugin->bind_address); | ||
2532 | 2534 | ||
2533 | if (plugin->behind_nat == GNUNET_NO) | 2535 | if (plugin->behind_nat == GNUNET_NO) |
2534 | { | 2536 | { |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index d95147a1a..94447bdbc 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -2293,9 +2293,10 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2293 | 2293 | ||
2294 | plugin->service = service; | 2294 | plugin->service = service; |
2295 | 2295 | ||
2296 | GNUNET_CONFIGURATION_get_value_string(env->cfg, "transport-udp", "BINDTO", &plugin->bind_address); | 2296 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string(env->cfg, "transport-udp", "BINDTO", &plugin->bind_address)) |
2297 | 2297 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Binding udp plugin to specific address: `%s'\n", plugin->bind_address); | |
2298 | GNUNET_CONFIGURATION_get_value_string(env->cfg, "transport-udp", "BINDTO6", &plugin->bind6_address); | 2298 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string(env->cfg, "transport-udp", "BINDTO6", &plugin->bind6_address)) |
2299 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Binding udp plugin to specific address: `%s'\n", plugin->bind6_address); | ||
2299 | 2300 | ||
2300 | if (plugin->behind_nat == GNUNET_NO) | 2301 | if (plugin->behind_nat == GNUNET_NO) |
2301 | { | 2302 | { |
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index f1cfd2c36..49d491bd7 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -770,7 +770,7 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) | |||
770 | snprintf (lsof, sizeof (lsof), "lsof -p %d", getpid()); | 770 | snprintf (lsof, sizeof (lsof), "lsof -p %d", getpid()); |
771 | close (1); | 771 | close (1); |
772 | dup2 (2, 1); | 772 | dup2 (2, 1); |
773 | system (lsof); | 773 | ret = system (lsof); |
774 | #endif | 774 | #endif |
775 | #endif | 775 | #endif |
776 | abort (); | 776 | abort (); |