diff options
author | Phil <phil.buschmann@tum.de> | 2018-01-22 14:56:59 +0100 |
---|---|---|
committer | Phil <phil.buschmann@tum.de> | 2018-01-22 14:56:59 +0100 |
commit | a67bd3630046d3a52195a13cbd4b4631c283d68d (patch) | |
tree | b8936d63f6c511248870d25646657634925c76f7 /src | |
parent | 5cc1e5ae920bac7f22d8a684bbea210d60788d48 (diff) | |
parent | e22c9d7e579210f39008923937e15b45fb226319 (diff) | |
download | gnunet-a67bd3630046d3a52195a13cbd4b4631c283d68d.tar.gz gnunet-a67bd3630046d3a52195a13cbd4b4631c283d68d.zip |
-merge branch 'master' into identity_oidc
Diffstat (limited to 'src')
34 files changed, 1777 insertions, 337 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index 6b07ab7b7..3c142a95c 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c | |||
@@ -1276,15 +1276,15 @@ GNUNET_CADET_close_port (struct GNUNET_CADET_Port *p) | |||
1276 | struct GNUNET_CADET_PortMessage *msg; | 1276 | struct GNUNET_CADET_PortMessage *msg; |
1277 | struct GNUNET_MQ_Envelope *env; | 1277 | struct GNUNET_MQ_Envelope *env; |
1278 | 1278 | ||
1279 | GNUNET_assert (GNUNET_YES == | ||
1280 | GNUNET_CONTAINER_multihashmap_remove (p->cadet->ports, | ||
1281 | &p->id, | ||
1282 | p)); | ||
1279 | env = GNUNET_MQ_msg (msg, | 1283 | env = GNUNET_MQ_msg (msg, |
1280 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE); | 1284 | GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE); |
1281 | msg->port = p->id; | 1285 | msg->port = p->id; |
1282 | GNUNET_MQ_send (p->cadet->mq, | 1286 | GNUNET_MQ_send (p->cadet->mq, |
1283 | env); | 1287 | env); |
1284 | GNUNET_assert (GNUNET_YES == | ||
1285 | GNUNET_CONTAINER_multihashmap_remove (p->cadet->ports, | ||
1286 | &p->id, | ||
1287 | p)); | ||
1288 | GNUNET_free_non_null (p->handlers); | 1288 | GNUNET_free_non_null (p->handlers); |
1289 | GNUNET_free (p); | 1289 | GNUNET_free (p); |
1290 | } | 1290 | } |
@@ -1673,7 +1673,7 @@ GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h, | |||
1673 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1673 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1674 | "Listening to CADET port %s\n", | 1674 | "Listening to CADET port %s\n", |
1675 | GNUNET_h2s (port)); | 1675 | GNUNET_h2s (port)); |
1676 | 1676 | ||
1677 | p = GNUNET_new (struct GNUNET_CADET_Port); | 1677 | p = GNUNET_new (struct GNUNET_CADET_Port); |
1678 | p->cadet = h; | 1678 | p->cadet = h; |
1679 | p->id = *port; | 1679 | p->id = *port; |
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c index c3e99e0eb..20e4c363e 100644 --- a/src/cadet/gnunet-service-cadet.c +++ b/src/cadet/gnunet-service-cadet.c | |||
@@ -75,7 +75,7 @@ struct CadetClient | |||
75 | * Handle to communicate with the client | 75 | * Handle to communicate with the client |
76 | */ | 76 | */ |
77 | struct GNUNET_MQ_Handle *mq; | 77 | struct GNUNET_MQ_Handle *mq; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Client handle. | 80 | * Client handle. |
81 | */ | 81 | */ |
@@ -536,6 +536,13 @@ handle_port_close (void *cls, | |||
536 | "Closing port %s as requested by %s\n", | 536 | "Closing port %s as requested by %s\n", |
537 | GNUNET_h2s (&pmsg->port), | 537 | GNUNET_h2s (&pmsg->port), |
538 | GSC_2s (c)); | 538 | GSC_2s (c)); |
539 | if (NULL == c->ports) | ||
540 | { | ||
541 | /* Client closed a port despite _never_ having opened one? */ | ||
542 | GNUNET_break (0); | ||
543 | GNUNET_SERVICE_client_drop (c->client); | ||
544 | return; | ||
545 | } | ||
539 | op = GNUNET_CONTAINER_multihashmap_get (c->ports, | 546 | op = GNUNET_CONTAINER_multihashmap_get (c->ports, |
540 | &pmsg->port); | 547 | &pmsg->port); |
541 | if (NULL == op) | 548 | if (NULL == op) |
diff --git a/src/cadet/gnunet-service-cadet_paths.c b/src/cadet/gnunet-service-cadet_paths.c index 9dd6f1ddd..b443cf9e8 100644 --- a/src/cadet/gnunet-service-cadet_paths.c +++ b/src/cadet/gnunet-service-cadet_paths.c | |||
@@ -429,7 +429,17 @@ extend_path (struct CadetPeerPath *path, | |||
429 | path->hn); | 429 | path->hn); |
430 | path->hn = NULL; | 430 | path->hn = NULL; |
431 | path->entries_length = old_len + num_peers; | 431 | path->entries_length = old_len + num_peers; |
432 | attach_path (path, old_len); | 432 | if (GNUNET_YES == force) |
433 | { | ||
434 | int end = path->entries_length - 1; | ||
435 | |||
436 | path->hn = GCP_attach_path (path->entries[end]->peer, | ||
437 | path, | ||
438 | end, | ||
439 | GNUNET_YES); | ||
440 | } else { | ||
441 | attach_path (path, old_len); | ||
442 | } | ||
433 | if (NULL == path->hn) | 443 | if (NULL == path->hn) |
434 | { | 444 | { |
435 | /* none of the peers is interested in this path; | 445 | /* none of the peers is interested in this path; |
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index cc56f5959..d51fd3e01 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c | |||
@@ -135,7 +135,7 @@ struct Plugin | |||
135 | /** | 135 | /** |
136 | * Precompiled SQL for selection | 136 | * Precompiled SQL for selection |
137 | */ | 137 | */ |
138 | sqlite3_stmt *get; | 138 | sqlite3_stmt *get[8]; |
139 | 139 | ||
140 | /** | 140 | /** |
141 | * Should the database be dropped on shutdown? | 141 | * Should the database be dropped on shutdown? |
@@ -386,12 +386,63 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
386 | (SQLITE_OK != | 386 | (SQLITE_OK != |
387 | sq_prepare (plugin->dbh, | 387 | sq_prepare (plugin->dbh, |
388 | "SELECT " RESULT_COLUMNS " FROM gn091 " | 388 | "SELECT " RESULT_COLUMNS " FROM gn091 " |
389 | "WHERE _ROWID_ >= ? AND " | 389 | "WHERE _ROWID_ >= ?1 " |
390 | "(rvalue >= ? OR 0 = ?) AND " | 390 | "ORDER BY _ROWID_ ASC LIMIT 1", |
391 | "(hash = ? OR 0 = ?) AND " | 391 | &plugin->get[0])) || |
392 | "(type = ? OR 0 = ?) " | 392 | (SQLITE_OK != |
393 | sq_prepare (plugin->dbh, | ||
394 | "SELECT " RESULT_COLUMNS " FROM gn091 " | ||
395 | "WHERE _ROWID_ >= ?1 AND " | ||
396 | "type = ?4 " | ||
397 | "ORDER BY _ROWID_ ASC LIMIT 1", | ||
398 | &plugin->get[1])) || | ||
399 | (SQLITE_OK != | ||
400 | sq_prepare (plugin->dbh, | ||
401 | "SELECT " RESULT_COLUMNS " FROM gn091 " | ||
402 | "WHERE _ROWID_ >= ?1 AND " | ||
403 | "hash = ?3 " | ||
404 | "ORDER BY _ROWID_ ASC LIMIT 1", | ||
405 | &plugin->get[2])) || | ||
406 | (SQLITE_OK != | ||
407 | sq_prepare (plugin->dbh, | ||
408 | "SELECT " RESULT_COLUMNS " FROM gn091 " | ||
409 | "WHERE _ROWID_ >= ?1 AND " | ||
410 | "hash = ?3 AND " | ||
411 | "type = ?4 " | ||
412 | "ORDER BY _ROWID_ ASC LIMIT 1", | ||
413 | &plugin->get[3])) || | ||
414 | (SQLITE_OK != | ||
415 | sq_prepare (plugin->dbh, | ||
416 | "SELECT " RESULT_COLUMNS " FROM gn091 " | ||
417 | "WHERE _ROWID_ >= ?1 AND " | ||
418 | "rvalue >= ?2 " | ||
419 | "ORDER BY _ROWID_ ASC LIMIT 1", | ||
420 | &plugin->get[4])) || | ||
421 | (SQLITE_OK != | ||
422 | sq_prepare (plugin->dbh, | ||
423 | "SELECT " RESULT_COLUMNS " FROM gn091 " | ||
424 | "WHERE _ROWID_ >= ?1 AND " | ||
425 | "rvalue >= ?2 AND " | ||
426 | "type = ?4 " | ||
393 | "ORDER BY _ROWID_ ASC LIMIT 1", | 427 | "ORDER BY _ROWID_ ASC LIMIT 1", |
394 | &plugin->get)) || | 428 | &plugin->get[5])) || |
429 | (SQLITE_OK != | ||
430 | sq_prepare (plugin->dbh, | ||
431 | "SELECT " RESULT_COLUMNS " FROM gn091 " | ||
432 | "WHERE _ROWID_ >= ?1 AND " | ||
433 | "rvalue >= ?2 AND " | ||
434 | "hash = ?3 " | ||
435 | "ORDER BY _ROWID_ ASC LIMIT 1", | ||
436 | &plugin->get[6])) || | ||
437 | (SQLITE_OK != | ||
438 | sq_prepare (plugin->dbh, | ||
439 | "SELECT " RESULT_COLUMNS " FROM gn091 " | ||
440 | "WHERE _ROWID_ >= ?1 AND " | ||
441 | "rvalue >= ?2 AND " | ||
442 | "hash = ?3 AND " | ||
443 | "type = ?4 " | ||
444 | "ORDER BY _ROWID_ ASC LIMIT 1", | ||
445 | &plugin->get[7])) || | ||
395 | (SQLITE_OK != | 446 | (SQLITE_OK != |
396 | sq_prepare (plugin->dbh, | 447 | sq_prepare (plugin->dbh, |
397 | "DELETE FROM gn091 WHERE _ROWID_ = ?", | 448 | "DELETE FROM gn091 WHERE _ROWID_ = ?", |
@@ -445,8 +496,9 @@ database_shutdown (struct Plugin *plugin) | |||
445 | sqlite3_finalize (plugin->selZeroAnon); | 496 | sqlite3_finalize (plugin->selZeroAnon); |
446 | if (NULL != plugin->insertContent) | 497 | if (NULL != plugin->insertContent) |
447 | sqlite3_finalize (plugin->insertContent); | 498 | sqlite3_finalize (plugin->insertContent); |
448 | if (NULL != plugin->get) | 499 | for (int i = 0; i < 8; ++i) |
449 | sqlite3_finalize (plugin->get); | 500 | if (NULL != plugin->get[i]) |
501 | sqlite3_finalize (plugin->get[i]); | ||
450 | result = sqlite3_close (plugin->dbh); | 502 | result = sqlite3_close (plugin->dbh); |
451 | #if SQLITE_VERSION_NUMBER >= 3007000 | 503 | #if SQLITE_VERSION_NUMBER >= 3007000 |
452 | if (result == SQLITE_BUSY) | 504 | if (result == SQLITE_BUSY) |
@@ -843,18 +895,16 @@ sqlite_plugin_get_key (void *cls, | |||
843 | { | 895 | { |
844 | struct Plugin *plugin = cls; | 896 | struct Plugin *plugin = cls; |
845 | uint64_t rvalue; | 897 | uint64_t rvalue; |
846 | uint16_t use_rvalue = random; | 898 | int use_rvalue = random; |
847 | uint32_t type32 = (uint32_t) type; | 899 | uint32_t type32 = (uint32_t) type; |
848 | uint16_t use_type = GNUNET_BLOCK_TYPE_ANY != type; | 900 | int use_type = GNUNET_BLOCK_TYPE_ANY != type; |
849 | uint16_t use_key = NULL != key; | 901 | int use_key = NULL != key; |
902 | sqlite3_stmt *stmt = plugin->get[use_rvalue * 4 + use_key * 2 + use_type]; | ||
850 | struct GNUNET_SQ_QueryParam params[] = { | 903 | struct GNUNET_SQ_QueryParam params[] = { |
851 | GNUNET_SQ_query_param_uint64 (&next_uid), | 904 | GNUNET_SQ_query_param_uint64 (&next_uid), |
852 | GNUNET_SQ_query_param_uint64 (&rvalue), | 905 | GNUNET_SQ_query_param_uint64 (&rvalue), |
853 | GNUNET_SQ_query_param_uint16 (&use_rvalue), | ||
854 | GNUNET_SQ_query_param_auto_from_type (key), | 906 | GNUNET_SQ_query_param_auto_from_type (key), |
855 | GNUNET_SQ_query_param_uint16 (&use_key), | ||
856 | GNUNET_SQ_query_param_uint32 (&type32), | 907 | GNUNET_SQ_query_param_uint32 (&type32), |
857 | GNUNET_SQ_query_param_uint16 (&use_type), | ||
858 | GNUNET_SQ_query_param_end | 908 | GNUNET_SQ_query_param_end |
859 | }; | 909 | }; |
860 | 910 | ||
@@ -868,14 +918,14 @@ sqlite_plugin_get_key (void *cls, | |||
868 | rvalue = 0; | 918 | rvalue = 0; |
869 | 919 | ||
870 | if (GNUNET_OK != | 920 | if (GNUNET_OK != |
871 | GNUNET_SQ_bind (plugin->get, | 921 | GNUNET_SQ_bind (stmt, |
872 | params)) | 922 | params)) |
873 | { | 923 | { |
874 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); | 924 | proc (proc_cls, NULL, 0, NULL, 0, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); |
875 | return; | 925 | return; |
876 | } | 926 | } |
877 | execute_get (plugin, | 927 | execute_get (plugin, |
878 | plugin->get, | 928 | stmt, |
879 | proc, | 929 | proc, |
880 | proc_cls); | 930 | proc_cls); |
881 | } | 931 | } |
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am index d60ff62d6..c52ac93c7 100644 --- a/src/dht/Makefile.am +++ b/src/dht/Makefile.am | |||
@@ -204,6 +204,7 @@ EXTRA_DIST = \ | |||
204 | test_dht_multipeer.conf \ | 204 | test_dht_multipeer.conf \ |
205 | test_dht_2dtorus.conf \ | 205 | test_dht_2dtorus.conf \ |
206 | test_dht_line.conf \ | 206 | test_dht_line.conf \ |
207 | test_dht_tools.conf \ | ||
207 | test_dht_tools.py.in \ | 208 | test_dht_tools.py.in \ |
208 | test_dht_multipeer_topology.dat | 209 | test_dht_multipeer_topology.dat |
209 | 210 | ||
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c index e361df336..842ec6270 100644 --- a/src/dht/gnunet-dht-get.c +++ b/src/dht/gnunet-dht-get.c | |||
@@ -238,37 +238,32 @@ main (int argc, char *const *argv) | |||
238 | { | 238 | { |
239 | 239 | ||
240 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 240 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
241 | 241 | ||
242 | GNUNET_GETOPT_option_string ('k', | 242 | GNUNET_GETOPT_option_string ('k', |
243 | "key", | 243 | "key", |
244 | "KEY", | 244 | "KEY", |
245 | gettext_noop ("the query key"), | 245 | gettext_noop ("the query key"), |
246 | &query_key), | 246 | &query_key), |
247 | 247 | ||
248 | GNUNET_GETOPT_option_uint ('r', | 248 | GNUNET_GETOPT_option_uint ('r', |
249 | "replication", | 249 | "replication", |
250 | "LEVEL", | 250 | "LEVEL", |
251 | gettext_noop ("how many parallel requests (replicas) to create"), | 251 | gettext_noop ("how many parallel requests (replicas) to create"), |
252 | &replication), | 252 | &replication), |
253 | |||
254 | |||
255 | GNUNET_GETOPT_option_uint ('t', | 253 | GNUNET_GETOPT_option_uint ('t', |
256 | "type", | 254 | "type", |
257 | "TYPE", | 255 | "TYPE", |
258 | gettext_noop ("the type of data to look for"), | 256 | gettext_noop ("the type of data to look for"), |
259 | &query_type), | 257 | &query_type), |
260 | |||
261 | GNUNET_GETOPT_option_relative_time ('T', | 258 | GNUNET_GETOPT_option_relative_time ('T', |
262 | "timeout", | 259 | "timeout", |
263 | "TIMEOUT", | 260 | "TIMEOUT", |
264 | gettext_noop ("how long to execute this query before giving up?"), | 261 | gettext_noop ("how long to execute this query before giving up?"), |
265 | &timeout_request), | 262 | &timeout_request), |
266 | |||
267 | GNUNET_GETOPT_option_flag ('x', | 263 | GNUNET_GETOPT_option_flag ('x', |
268 | "demultiplex", | 264 | "demultiplex", |
269 | gettext_noop ("use DHT's demultiplex everywhere option"), | 265 | gettext_noop ("use DHT's demultiplex everywhere option"), |
270 | &demultixplex_everywhere), | 266 | &demultixplex_everywhere), |
271 | |||
272 | GNUNET_GETOPT_option_verbose (&verbose), | 267 | GNUNET_GETOPT_option_verbose (&verbose), |
273 | GNUNET_GETOPT_OPTION_END | 268 | GNUNET_GETOPT_OPTION_END |
274 | }; | 269 | }; |
diff --git a/src/dht/test_dht_tools.conf b/src/dht/test_dht_tools.conf new file mode 100644 index 000000000..9306c5dc9 --- /dev/null +++ b/src/dht/test_dht_tools.conf | |||
@@ -0,0 +1,157 @@ | |||
1 | [dhtcache] | ||
2 | QUOTA = 1 MB | ||
3 | DATABASE = heap | ||
4 | |||
5 | [transport] | ||
6 | PLUGINS = tcp | ||
7 | ACCEPT_FROM6 = ::1; | ||
8 | ACCEPT_FROM = 127.0.0.1; | ||
9 | NEIGHBOUR_LIMIT = 50 | ||
10 | PORT = 12365 | ||
11 | |||
12 | [ats] | ||
13 | WAN_QUOTA_IN = 1 GB | ||
14 | WAN_QUOTA_OUT = 1 GB | ||
15 | |||
16 | [transport-tcp] | ||
17 | TIMEOUT = 300 s | ||
18 | BINDTO = 127.0.0.1 | ||
19 | |||
20 | [PATHS] | ||
21 | GNUNET_TEST_HOME = /tmp/test-gnunet-dht-peer-1/ | ||
22 | |||
23 | [nat] | ||
24 | DISABLEV6 = YES | ||
25 | ENABLE_UPNP = NO | ||
26 | BEHIND_NAT = NO | ||
27 | ALLOW_NAT = NO | ||
28 | INTERNAL_ADDRESS = 127.0.0.1 | ||
29 | EXTERNAL_ADDRESS = 127.0.0.1 | ||
30 | USE_LOCALADDR = NO | ||
31 | |||
32 | [dht] | ||
33 | AUTOSTART = YES | ||
34 | FORCESTART = YES | ||
35 | |||
36 | [nse] | ||
37 | AUTOSTART = YES | ||
38 | WORKBITS = 1 | ||
39 | # Configuration to disable autostarting of | ||
40 | # all services above the 'core' level. | ||
41 | # (including resolver) | ||
42 | |||
43 | [dns] | ||
44 | AUTOSTART = NO | ||
45 | |||
46 | [cadet] | ||
47 | AUTOSTART = NO | ||
48 | |||
49 | [datastore] | ||
50 | AUTOSTART = NO | ||
51 | |||
52 | [fs] | ||
53 | AUTOSTART = NO | ||
54 | |||
55 | [dv] | ||
56 | AUTOSTART = NO | ||
57 | |||
58 | [vpn] | ||
59 | AUTOSTART = NO | ||
60 | |||
61 | [consensus] | ||
62 | AUTOSTART = NO | ||
63 | |||
64 | [resolver] | ||
65 | AUTOSTART = NO | ||
66 | |||
67 | [namestore] | ||
68 | AUTOSTART = NO | ||
69 | |||
70 | [namecache] | ||
71 | AUTOSTART = NO | ||
72 | |||
73 | [identity] | ||
74 | AUTOSTART = NO | ||
75 | |||
76 | [revocation] | ||
77 | AUTOSTART = NO | ||
78 | |||
79 | [conversation] | ||
80 | AUTOSTART = NO | ||
81 | |||
82 | [peerstore] | ||
83 | AUTOSTART = NO | ||
84 | |||
85 | [psycstore] | ||
86 | AUTOSTART = NO | ||
87 | |||
88 | [gns] | ||
89 | AUTOSTART = NO | ||
90 | |||
91 | [regex] | ||
92 | AUTOSTART = NO | ||
93 | |||
94 | [set] | ||
95 | AUTOSTART = NO | ||
96 | |||
97 | [scalarproduct-bob] | ||
98 | AUTOSTART = NO | ||
99 | |||
100 | [scalarproduct-alice] | ||
101 | AUTOSTART = NO | ||
102 | |||
103 | [social] | ||
104 | AUTOSTART = NO | ||
105 | |||
106 | [psyc] | ||
107 | AUTOSTART = NO | ||
108 | |||
109 | [rps] | ||
110 | AUTOSTART = NO | ||
111 | |||
112 | [multicast] | ||
113 | AUTOSTART = NO | ||
114 | |||
115 | [sensordashboard] | ||
116 | AUTOSTART = NO | ||
117 | |||
118 | [sensor] | ||
119 | AUTOSTART = NO | ||
120 | # Configuration file that can be included to prevent ANY of the usual | ||
121 | # FORCESTART = YES to be set. Also disables NSE POW calculation. | ||
122 | # | ||
123 | # This configuration is included from various configuration test files. | ||
124 | # Whenever a new service is added that has FORCESTART = YES for | ||
125 | # production should be disabled for (most) test suites, the option should | ||
126 | # be added here instead of all over the place ;-). | ||
127 | |||
128 | [core] | ||
129 | FORCESTART = NO | ||
130 | |||
131 | [fs] | ||
132 | FORCESTART = NO | ||
133 | |||
134 | [dht] | ||
135 | FORCESTART = NO | ||
136 | |||
137 | [cadet] | ||
138 | FORCESTART = NO | ||
139 | |||
140 | [nse] | ||
141 | FORCESTART = NO | ||
142 | WORKBITS = 0 | ||
143 | |||
144 | [revocation] | ||
145 | FORCESTART = NO | ||
146 | |||
147 | [topology] | ||
148 | FORCESTART = NO | ||
149 | |||
150 | [hostlist] | ||
151 | FORCESTART = NO | ||
152 | |||
153 | [gns] | ||
154 | FORCESTART = NO | ||
155 | |||
156 | [zonemaster] | ||
157 | FORCESTART = NO \ No newline at end of file | ||
diff --git a/src/dht/test_dht_tools.sh b/src/dht/test_dht_tools.sh index f83c26a1a..56cc99e15 100755 --- a/src/dht/test_dht_tools.sh +++ b/src/dht/test_dht_tools.sh | |||
@@ -1,7 +1,8 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # This file is in the public domain. | ||
2 | 3 | ||
3 | out=`mktemp /tmp/test-gnunet-dht-logXXXXXXXX` | 4 | out=`mktemp /tmp/test-gnunet-dht-logXXXXXXXX` |
4 | tempcfg=`mktemp /tmp/test_dht_api_peer1.XXXXXXXX` | 5 | tempcfg=`mktemp /tmp/test-dht-tools.XXXXXXXX` |
5 | checkout="check.out" | 6 | checkout="check.out" |
6 | armexe="gnunet-arm -c $tempcfg " | 7 | armexe="gnunet-arm -c $tempcfg " |
7 | putexe="gnunet-dht-put -c $tempcfg " | 8 | putexe="gnunet-dht-put -c $tempcfg " |
@@ -19,16 +20,7 @@ stop_arm() | |||
19 | rm -f $out $tempcfg | 20 | rm -f $out $tempcfg |
20 | } | 21 | } |
21 | 22 | ||
22 | cp test_dht_api_peer1.conf $tempcfg | 23 | cp test_dht_tools.conf $tempcfg |
23 | |||
24 | echo -n "TEST: Generating hostkey..." | ||
25 | if ! $peerinfo > $out ; then | ||
26 | echo "FAIL: error running $peerinfo" | ||
27 | echo "Command output was:" | ||
28 | cat $out | ||
29 | exit 1 | ||
30 | fi | ||
31 | echo "PASS" | ||
32 | 24 | ||
33 | echo -n "TEST: Starting ARM..." | 25 | echo -n "TEST: Starting ARM..." |
34 | if ! $armexe $DEBUG -s > $out ; then | 26 | if ! $armexe $DEBUG -s > $out ; then |
@@ -39,7 +31,6 @@ if ! $armexe $DEBUG -s > $out ; then | |||
39 | exit 1 | 31 | exit 1 |
40 | fi | 32 | fi |
41 | echo "PASS" | 33 | echo "PASS" |
42 | sleep 1 | ||
43 | 34 | ||
44 | echo -n "TEST: Testing put..." | 35 | echo -n "TEST: Testing put..." |
45 | if ! $putexe -k testkey -d testdata -t 8 > $out ; then | 36 | if ! $putexe -k testkey -d testdata -t 8 > $out ; then |
@@ -50,13 +41,12 @@ if ! $putexe -k testkey -d testdata -t 8 > $out ; then | |||
50 | exit 1 | 41 | exit 1 |
51 | fi | 42 | fi |
52 | echo "PASS" | 43 | echo "PASS" |
53 | sleep 1 | ||
54 | 44 | ||
55 | echo -n "TEST: Testing get..." | 45 | echo -n "TEST: Testing get..." |
56 | echo "Result 0, type 8:" > $checkout | 46 | echo "Result 0, type 8:" > $checkout |
57 | echo "testdata" >> $checkout | 47 | echo "testdata" >> $checkout |
58 | 48 | ||
59 | if ! $getexe -k testkey -T 5 -t 8 > $out ; then | 49 | if ! $getexe -k testkey -T 100ms -t 8 > $out ; then |
60 | echo "FAIL: error running $putexe" | 50 | echo "FAIL: error running $putexe" |
61 | echo "Command output was:" | 51 | echo "Command output was:" |
62 | cat $out | 52 | cat $out |
@@ -65,7 +55,8 @@ if ! $getexe -k testkey -T 5 -t 8 > $out ; then | |||
65 | fi | 55 | fi |
66 | 56 | ||
67 | if ! diff --strip-trailing-cr -q $out $checkout ; then | 57 | if ! diff --strip-trailing-cr -q $out $checkout ; then |
68 | echo "FAIL: $out and $checkout differ" | 58 | echo "FAIL: $out and $checkout differ:" |
59 | diff --strip-trailing-cr $out $checkout | ||
69 | stop_arm | 60 | stop_arm |
70 | exit 1 | 61 | exit 1 |
71 | fi | 62 | fi |
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 395aad7db..c75469a24 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c | |||
@@ -895,35 +895,30 @@ main (int argc, char *const *argv) | |||
895 | { | 895 | { |
896 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 896 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
897 | GNUNET_GETOPT_option_uint ('a', | 897 | GNUNET_GETOPT_option_uint ('a', |
898 | "anonymity", | 898 | "anonymity", |
899 | "LEVEL", | 899 | "LEVEL", |
900 | gettext_noop ("set the desired LEVEL of sender-anonymity"), | 900 | gettext_noop ("set the desired LEVEL of sender-anonymity"), |
901 | &bo.anonymity_level), | 901 | &bo.anonymity_level), |
902 | |||
903 | GNUNET_GETOPT_option_flag ('d', | 902 | GNUNET_GETOPT_option_flag ('d', |
904 | "disable-creation-time", | 903 | "disable-creation-time", |
905 | gettext_noop ("disable adding the creation time to the " | 904 | gettext_noop ("disable adding the creation time to the " |
906 | "metadata of the uploaded file"), | 905 | "metadata of the uploaded file"), |
907 | &do_disable_creation_time), | 906 | &do_disable_creation_time), |
908 | |||
909 | GNUNET_GETOPT_option_flag ('D', | 907 | GNUNET_GETOPT_option_flag ('D', |
910 | "disable-extractor", | 908 | "disable-extractor", |
911 | gettext_noop ("do not use libextractor to add keywords or metadata"), | 909 | gettext_noop ("do not use libextractor to add keywords or metadata"), |
912 | &disable_extractor), | 910 | &disable_extractor), |
913 | |||
914 | GNUNET_GETOPT_option_flag ('e', | 911 | GNUNET_GETOPT_option_flag ('e', |
915 | "extract", | 912 | "extract", |
916 | gettext_noop ("print list of extracted keywords that would " | 913 | gettext_noop ("print list of extracted keywords that would " |
917 | "be used, but do not perform upload"), | 914 | "be used, but do not perform upload"), |
918 | &extract_only), | 915 | &extract_only), |
919 | |||
920 | GNUNET_FS_GETOPT_KEYWORDS ('k', | 916 | GNUNET_FS_GETOPT_KEYWORDS ('k', |
921 | "key", | 917 | "key", |
922 | "KEYWORD", | 918 | "KEYWORD", |
923 | gettext_noop ("add an additional keyword for the top-level " | 919 | gettext_noop ("add an additional keyword for the top-level " |
924 | "file or directory (this option can be specified multiple times)"), | 920 | "file or directory (this option can be specified multiple times)"), |
925 | &topKeywords), | 921 | &topKeywords), |
926 | |||
927 | GNUNET_FS_GETOPT_METADATA ('m', | 922 | GNUNET_FS_GETOPT_METADATA ('m', |
928 | "meta", | 923 | "meta", |
929 | "TYPE:VALUE", | 924 | "TYPE:VALUE", |
@@ -955,20 +950,16 @@ main (int argc, char *const *argv) | |||
955 | gettext_noop ("publish the files under the pseudonym " | 950 | gettext_noop ("publish the files under the pseudonym " |
956 | "NAME (place file into namespace)"), | 951 | "NAME (place file into namespace)"), |
957 | &pseudonym), | 952 | &pseudonym), |
958 | |||
959 | GNUNET_GETOPT_option_uint ('r', | 953 | GNUNET_GETOPT_option_uint ('r', |
960 | "replication", | 954 | "replication", |
961 | "LEVEL", | 955 | "LEVEL", |
962 | gettext_noop ("set the desired replication LEVEL"), | 956 | gettext_noop ("set the desired replication LEVEL"), |
963 | &bo.replication_level), | 957 | &bo.replication_level), |
964 | |||
965 | |||
966 | GNUNET_GETOPT_option_flag ('s', | 958 | GNUNET_GETOPT_option_flag ('s', |
967 | "simulate-only", | 959 | "simulate-only", |
968 | gettext_noop ("only simulate the process but do not do " | 960 | gettext_noop ("only simulate the process but do not do " |
969 | "any actual publishing (useful to compute URIs)"), | 961 | "any actual publishing (useful to compute URIs)"), |
970 | &do_simulate), | 962 | &do_simulate), |
971 | |||
972 | GNUNET_GETOPT_option_string ('t', | 963 | GNUNET_GETOPT_option_string ('t', |
973 | "this", | 964 | "this", |
974 | "ID", | 965 | "ID", |
@@ -981,7 +972,7 @@ main (int argc, char *const *argv) | |||
981 | "URI", | 972 | "URI", |
982 | gettext_noop ("URI to be published (can be used instead of passing a " | 973 | gettext_noop ("URI to be published (can be used instead of passing a " |
983 | "file to add keywords to the file with the respective URI)"), | 974 | "file to add keywords to the file with the respective URI)"), |
984 | &uri_string), | 975 | &uri_string), |
985 | 976 | ||
986 | GNUNET_GETOPT_option_verbose (&verbose), | 977 | GNUNET_GETOPT_option_verbose (&verbose), |
987 | 978 | ||
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 25092dcf0..591dff04f 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -1150,8 +1150,8 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls) | |||
1150 | hdr_type, | 1150 | hdr_type, |
1151 | hdr_val); | 1151 | hdr_val); |
1152 | header = GNUNET_new (struct HttpResponseHeader); | 1152 | header = GNUNET_new (struct HttpResponseHeader); |
1153 | header->type = GNUNET_strndup (hdr_type, strlen (hdr_type)); | 1153 | header->type = GNUNET_strdup (hdr_type); |
1154 | header->value = GNUNET_strndup (hdr_val, strlen (hdr_val)); | 1154 | header->value = GNUNET_strdup (hdr_val); |
1155 | GNUNET_CONTAINER_DLL_insert (s5r->header_head, | 1155 | GNUNET_CONTAINER_DLL_insert (s5r->header_head, |
1156 | s5r->header_tail, | 1156 | s5r->header_tail, |
1157 | header); | 1157 | header); |
diff --git a/src/identity-provider/identity_provider_api.c b/src/identity-provider/identity_provider_api.c index 38c11841c..e993a1ac7 100644 --- a/src/identity-provider/identity_provider_api.c +++ b/src/identity-provider/identity_provider_api.c | |||
@@ -376,6 +376,15 @@ free_it (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it) | |||
376 | GNUNET_free (it); | 376 | GNUNET_free (it); |
377 | } | 377 | } |
378 | 378 | ||
379 | static void | ||
380 | free_op (struct GNUNET_IDENTITY_PROVIDER_Operation* op) | ||
381 | { | ||
382 | if (NULL == op) | ||
383 | return; | ||
384 | if (NULL != op->env) | ||
385 | GNUNET_MQ_discard (op->env); | ||
386 | GNUNET_free(op); | ||
387 | } | ||
379 | 388 | ||
380 | 389 | ||
381 | /** | 390 | /** |
@@ -434,7 +443,7 @@ handle_attribute_store_response (void *cls, | |||
434 | GNUNET_CONTAINER_DLL_remove (h->op_head, | 443 | GNUNET_CONTAINER_DLL_remove (h->op_head, |
435 | h->op_tail, | 444 | h->op_tail, |
436 | op); | 445 | op); |
437 | GNUNET_free (op); | 446 | free_op (op); |
438 | 447 | ||
439 | } | 448 | } |
440 | 449 | ||
@@ -522,7 +531,7 @@ handle_consume_ticket_result (void *cls, | |||
522 | GNUNET_CONTAINER_DLL_remove (h->op_head, | 531 | GNUNET_CONTAINER_DLL_remove (h->op_head, |
523 | h->op_tail, | 532 | h->op_tail, |
524 | op); | 533 | op); |
525 | GNUNET_free (op); | 534 | free_op (op); |
526 | } | 535 | } |
527 | return; | 536 | return; |
528 | } | 537 | } |
@@ -613,7 +622,7 @@ handle_attribute_result (void *cls, | |||
613 | GNUNET_CONTAINER_DLL_remove (h->op_head, | 622 | GNUNET_CONTAINER_DLL_remove (h->op_head, |
614 | h->op_tail, | 623 | h->op_tail, |
615 | op); | 624 | op); |
616 | GNUNET_free (op); | 625 | free_op (op); |
617 | 626 | ||
618 | } | 627 | } |
619 | return; | 628 | return; |
@@ -709,7 +718,7 @@ handle_ticket_result (void *cls, | |||
709 | if (NULL != op->tr_cb) | 718 | if (NULL != op->tr_cb) |
710 | op->tr_cb (op->cls, ticket); | 719 | op->tr_cb (op->cls, ticket); |
711 | } | 720 | } |
712 | GNUNET_free (op); | 721 | free_op (op); |
713 | return; | 722 | return; |
714 | } else if (NULL != it) { | 723 | } else if (NULL != it) { |
715 | if (msg_len == sizeof (struct TicketResultMessage)) | 724 | if (msg_len == sizeof (struct TicketResultMessage)) |
@@ -730,6 +739,7 @@ handle_ticket_result (void *cls, | |||
730 | GNUNET_break (0); | 739 | GNUNET_break (0); |
731 | } | 740 | } |
732 | 741 | ||
742 | |||
733 | /** | 743 | /** |
734 | * Handle an incoming message of type | 744 | * Handle an incoming message of type |
735 | * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET_RESULT | 745 | * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET_RESULT |
@@ -766,7 +776,7 @@ handle_revoke_ticket_result (void *cls, | |||
766 | GNUNET_CONTAINER_DLL_remove (h->op_head, | 776 | GNUNET_CONTAINER_DLL_remove (h->op_head, |
767 | h->op_tail, | 777 | h->op_tail, |
768 | op); | 778 | op); |
769 | GNUNET_free (op); | 779 | free_op (op); |
770 | return; | 780 | return; |
771 | } | 781 | } |
772 | GNUNET_assert (0); | 782 | GNUNET_assert (0); |
@@ -864,7 +874,7 @@ GNUNET_IDENTITY_PROVIDER_cancel (struct GNUNET_IDENTITY_PROVIDER_Operation *op) | |||
864 | h->op_tail, | 874 | h->op_tail, |
865 | op); | 875 | op); |
866 | GNUNET_MQ_discard (op->env); | 876 | GNUNET_MQ_discard (op->env); |
867 | GNUNET_free (op); | 877 | free_op (op); |
868 | } | 878 | } |
869 | 879 | ||
870 | 880 | ||
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h index 0add8852a..6d3c07f1d 100644 --- a/src/include/gnunet_namestore_service.h +++ b/src/include/gnunet_namestore_service.h | |||
@@ -193,7 +193,7 @@ GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, | |||
193 | * Returns at most one result to the processor. | 193 | * Returns at most one result to the processor. |
194 | * | 194 | * |
195 | * @param h handle to the namestore | 195 | * @param h handle to the namestore |
196 | * @param zone public key of the zone to look up in, never NULL | 196 | * @param zone private key of the zone to look up in, never NULL |
197 | * @param value_zone public key of the target zone (value), never NULL | 197 | * @param value_zone public key of the target zone (value), never NULL |
198 | * @param error_cb function to call on error (i.e. disconnect) | 198 | * @param error_cb function to call on error (i.e. disconnect) |
199 | * the handle is afterwards invalid | 199 | * the handle is afterwards invalid |
diff --git a/src/multicast/Makefile.am b/src/multicast/Makefile.am index 48185e1a4..61a9f8bf6 100644 --- a/src/multicast/Makefile.am +++ b/src/multicast/Makefile.am | |||
@@ -53,7 +53,6 @@ check_PROGRAMS = \ | |||
53 | test_multicast \ | 53 | test_multicast \ |
54 | test_multicast_multipeer_star \ | 54 | test_multicast_multipeer_star \ |
55 | test_multicast_multipeer_line | 55 | test_multicast_multipeer_line |
56 | # test_multicast_2peers | ||
57 | 56 | ||
58 | if ENABLE_TEST_RUN | 57 | if ENABLE_TEST_RUN |
59 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@}; export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH; unset XDG_DATA_HOME; unset XDG_CONFIG_HOME; | 58 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@}; export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH; unset XDG_DATA_HOME; unset XDG_CONFIG_HOME; |
@@ -78,10 +77,3 @@ test_multicast_multipeer_line_LDADD = \ | |||
78 | libgnunetmulticast.la \ | 77 | libgnunetmulticast.la \ |
79 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 78 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
80 | $(top_builddir)/src/util/libgnunetutil.la | 79 | $(top_builddir)/src/util/libgnunetutil.la |
81 | |||
82 | test_multicast_2peers_SOURCES = \ | ||
83 | test_multicast_2peers.c | ||
84 | test_multicast_2peers_LDADD = \ | ||
85 | libgnunetmulticast.la \ | ||
86 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
87 | $(top_builddir)/src/util/libgnunetutil.la | ||
diff --git a/src/multicast/test_multicast_multipeer.c b/src/multicast/test_multicast_multipeer.c index 7df1a8213..d1ed1cb39 100644 --- a/src/multicast/test_multicast_multipeer.c +++ b/src/multicast/test_multicast_multipeer.c | |||
@@ -65,7 +65,6 @@ static void service_connect (void *cls, | |||
65 | static struct MulticastPeerContext **multicast_peers; | 65 | static struct MulticastPeerContext **multicast_peers; |
66 | static struct GNUNET_TESTBED_Peer **peers; | 66 | static struct GNUNET_TESTBED_Peer **peers; |
67 | 67 | ||
68 | // FIXME: refactor | ||
69 | static struct GNUNET_TESTBED_Operation *op[PEERS_REQUESTED]; | 68 | static struct GNUNET_TESTBED_Operation *op[PEERS_REQUESTED]; |
70 | static struct GNUNET_TESTBED_Operation *pi_op[PEERS_REQUESTED]; | 69 | static struct GNUNET_TESTBED_Operation *pi_op[PEERS_REQUESTED]; |
71 | 70 | ||
@@ -74,7 +73,7 @@ static struct GNUNET_MULTICAST_Member *members[PEERS_REQUESTED]; /* first elemen | |||
74 | 73 | ||
75 | static struct GNUNET_SCHEDULER_Task *timeout_tid; | 74 | static struct GNUNET_SCHEDULER_Task *timeout_tid; |
76 | 75 | ||
77 | //static struct GNUNET_CRYPTO_EddsaPrivateKey *group_key; | 76 | static struct GNUNET_CRYPTO_EddsaPrivateKey *group_key; |
78 | static struct GNUNET_CRYPTO_EddsaPublicKey group_pub_key; | 77 | static struct GNUNET_CRYPTO_EddsaPublicKey group_pub_key; |
79 | static struct GNUNET_HashCode group_pub_key_hash; | 78 | static struct GNUNET_HashCode group_pub_key_hash; |
80 | 79 | ||
@@ -110,7 +109,7 @@ shutdown_task (void *cls) | |||
110 | { | 109 | { |
111 | for (int i=0; i < PEERS_REQUESTED; i++) | 110 | for (int i=0; i < PEERS_REQUESTED; i++) |
112 | { | 111 | { |
113 | GNUNET_free (multicast_peers[i]->key); | 112 | GNUNET_free_non_null (multicast_peers[i]->key); |
114 | GNUNET_free (multicast_peers[i]); | 113 | GNUNET_free (multicast_peers[i]); |
115 | multicast_peers[i] = NULL; | 114 | multicast_peers[i] = NULL; |
116 | } | 115 | } |
@@ -180,7 +179,6 @@ member_join_decision (void *cls, | |||
180 | const struct GNUNET_MessageHeader *join_msg) | 179 | const struct GNUNET_MessageHeader *join_msg) |
181 | { | 180 | { |
182 | struct MulticastPeerContext *mc_peer = (struct MulticastPeerContext*)cls; | 181 | struct MulticastPeerContext *mc_peer = (struct MulticastPeerContext*)cls; |
183 | struct GNUNET_MULTICAST_MemberTransmitHandle *req; | ||
184 | 182 | ||
185 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 183 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
186 | "Peer #%u (%s) received a decision from origin: %s\n", | 184 | "Peer #%u (%s) received a decision from origin: %s\n", |
@@ -190,10 +188,10 @@ member_join_decision (void *cls, | |||
190 | 188 | ||
191 | if (GNUNET_YES == is_admitted) | 189 | if (GNUNET_YES == is_admitted) |
192 | { | 190 | { |
193 | req = GNUNET_MULTICAST_member_to_origin (members[mc_peer->peer], | 191 | GNUNET_MULTICAST_member_to_origin (members[mc_peer->peer], |
194 | 0, | 192 | 0, |
195 | notify, | 193 | notify, |
196 | cls); | 194 | cls); |
197 | 195 | ||
198 | } | 196 | } |
199 | } | 197 | } |
@@ -384,13 +382,14 @@ multicast_connect (void *cls, | |||
384 | struct GNUNET_MessageHeader *join_msg; | 382 | struct GNUNET_MessageHeader *join_msg; |
385 | char data[64]; | 383 | char data[64]; |
386 | 384 | ||
387 | multicast_peer->key = GNUNET_CRYPTO_ecdsa_key_create (); | ||
388 | if (0 == multicast_peer->peer) | 385 | if (0 == multicast_peer->peer) |
389 | { | 386 | { |
390 | GNUNET_CRYPTO_eddsa_key_get_public (multicast_peer->key, &group_pub_key); | 387 | group_key = GNUNET_CRYPTO_eddsa_key_create (); |
388 | GNUNET_CRYPTO_eddsa_key_get_public (group_key, &group_pub_key); | ||
389 | |||
391 | GNUNET_CRYPTO_hash (&group_pub_key, sizeof (group_pub_key), &group_pub_key_hash); | 390 | GNUNET_CRYPTO_hash (&group_pub_key, sizeof (group_pub_key), &group_pub_key_hash); |
392 | origin = GNUNET_MULTICAST_origin_start (cfg, | 391 | origin = GNUNET_MULTICAST_origin_start (cfg, |
393 | multicast_peer->key, | 392 | group_key, |
394 | 0, | 393 | 0, |
395 | origin_join_request, | 394 | origin_join_request, |
396 | origin_replay_frag, | 395 | origin_replay_frag, |
@@ -413,6 +412,8 @@ multicast_connect (void *cls, | |||
413 | } | 412 | } |
414 | else | 413 | else |
415 | { | 414 | { |
415 | multicast_peer->key = GNUNET_CRYPTO_ecdsa_key_create (); | ||
416 | |||
416 | sprintf(data, "Hi, I am peer #%u (%s). Can I enter?", | 417 | sprintf(data, "Hi, I am peer #%u (%s). Can I enter?", |
417 | multicast_peer->peer, | 418 | multicast_peer->peer, |
418 | GNUNET_i2s (multicast_peers[multicast_peer->peer]->id)); | 419 | GNUNET_i2s (multicast_peers[multicast_peer->peer]->id)); |
@@ -546,7 +547,8 @@ service_connect (void *cls, | |||
546 | * @param PEERS_REQUESTED size of the 'peers' array | 547 | * @param PEERS_REQUESTED size of the 'peers' array |
547 | * @param links_succeeded number of links between peers that were created | 548 | * @param links_succeeded number of links between peers that were created |
548 | * @param links_failed number of links testbed was unable to establish | 549 | * @param links_failed number of links testbed was unable to establish |
549 | */ static void | 550 | */ |
551 | static void | ||
550 | testbed_master (void *cls, | 552 | testbed_master (void *cls, |
551 | struct GNUNET_TESTBED_RunHandle *h, | 553 | struct GNUNET_TESTBED_RunHandle *h, |
552 | unsigned int num_peers, | 554 | unsigned int num_peers, |
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 4f710e116..a848d4b72 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am | |||
@@ -59,8 +59,8 @@ TESTING_TESTS = \ | |||
59 | test_namestore_api_zone_iteration_specific_zone.nc \ | 59 | test_namestore_api_zone_iteration_specific_zone.nc \ |
60 | test_namestore_api_zone_iteration_stop.nc \ | 60 | test_namestore_api_zone_iteration_stop.nc \ |
61 | test_namestore_api_monitoring.nc \ | 61 | test_namestore_api_monitoring.nc \ |
62 | test_namestore_api_monitoring_existing.nc | 62 | test_namestore_api_monitoring_existing.nc \ |
63 | # test_namestore_api_zone_to_name | 63 | test_namestore_api_zone_to_name |
64 | endif | 64 | endif |
65 | 65 | ||
66 | # Declare .nc (NO-CONCURRENCY) as a test extension so that we can impart | 66 | # Declare .nc (NO-CONCURRENCY) as a test extension so that we can impart |
@@ -298,12 +298,12 @@ test_namestore_api_remove_not_existing_record_nc_LDADD = \ | |||
298 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 298 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
299 | libgnunetnamestore.la | 299 | libgnunetnamestore.la |
300 | 300 | ||
301 | #test_namestore_api_zone_to_name_SOURCES = \ | 301 | test_namestore_api_zone_to_name_SOURCES = \ |
302 | # test_namestore_api_zone_to_name.c | 302 | test_namestore_api_zone_to_name.c |
303 | #test_namestore_api_zone_to_name_LDADD = \ | 303 | test_namestore_api_zone_to_name_LDADD = \ |
304 | # $(top_builddir)/src/testing/libgnunettesting.la \ | 304 | $(top_builddir)/src/testing/libgnunettesting.la \ |
305 | # $(top_builddir)/src/util/libgnunetutil.la \ | 305 | $(top_builddir)/src/util/libgnunetutil.la \ |
306 | # libgnunetnamestore.la | 306 | libgnunetnamestore.la |
307 | 307 | ||
308 | test_namestore_api_monitoring_nc_SOURCES = \ | 308 | test_namestore_api_monitoring_nc_SOURCES = \ |
309 | test_namestore_api_monitoring.c | 309 | test_namestore_api_monitoring.c |
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index 92068cc01..a187bd250 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c | |||
@@ -405,6 +405,7 @@ check_lookup_result (void *cls, | |||
405 | size_t name_len; | 405 | size_t name_len; |
406 | size_t rd_len; | 406 | size_t rd_len; |
407 | 407 | ||
408 | (void) cls; | ||
408 | rd_len = ntohs (msg->rd_len); | 409 | rd_len = ntohs (msg->rd_len); |
409 | msg_len = ntohs (msg->gns_header.header.size); | 410 | msg_len = ntohs (msg->gns_header.header.size); |
410 | name_len = ntohs (msg->name_len); | 411 | name_len = ntohs (msg->name_len); |
@@ -517,6 +518,7 @@ check_record_result (void *cls, | |||
517 | size_t name_len; | 518 | size_t name_len; |
518 | size_t rd_len; | 519 | size_t rd_len; |
519 | 520 | ||
521 | (void) cls; | ||
520 | rd_len = ntohs (msg->rd_len); | 522 | rd_len = ntohs (msg->rd_len); |
521 | msg_len = ntohs (msg->gns_header.header.size); | 523 | msg_len = ntohs (msg->gns_header.header.size); |
522 | name_len = ntohs (msg->name_len); | 524 | name_len = ntohs (msg->name_len); |
@@ -656,6 +658,7 @@ check_zone_to_name_response (void *cls, | |||
656 | size_t rd_ser_len; | 658 | size_t rd_ser_len; |
657 | const char *name_tmp; | 659 | const char *name_tmp; |
658 | 660 | ||
661 | (void) cls; | ||
659 | if (GNUNET_OK != ntohs (msg->res)) | 662 | if (GNUNET_OK != ntohs (msg->res)) |
660 | return GNUNET_OK; | 663 | return GNUNET_OK; |
661 | name_len = ntohs (msg->name_len); | 664 | name_len = ntohs (msg->name_len); |
@@ -771,6 +774,7 @@ mq_error_handler (void *cls, | |||
771 | { | 774 | { |
772 | struct GNUNET_NAMESTORE_Handle *h = cls; | 775 | struct GNUNET_NAMESTORE_Handle *h = cls; |
773 | 776 | ||
777 | (void) error; | ||
774 | force_reconnect (h); | 778 | force_reconnect (h); |
775 | } | 779 | } |
776 | 780 | ||
@@ -994,6 +998,7 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, | |||
994 | size_t name_len; | 998 | size_t name_len; |
995 | uint32_t rid; | 999 | uint32_t rid; |
996 | struct RecordStoreMessage *msg; | 1000 | struct RecordStoreMessage *msg; |
1001 | ssize_t sret; | ||
997 | 1002 | ||
998 | name_len = strlen (label) + 1; | 1003 | name_len = strlen (label) + 1; |
999 | if (name_len > MAX_NAME_LEN) | 1004 | if (name_len > MAX_NAME_LEN) |
@@ -1029,11 +1034,16 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, | |||
1029 | label, | 1034 | label, |
1030 | name_len); | 1035 | name_len); |
1031 | rd_ser = &name_tmp[name_len]; | 1036 | rd_ser = &name_tmp[name_len]; |
1032 | GNUNET_assert (rd_ser_len == | 1037 | sret = GNUNET_GNSRECORD_records_serialize (rd_count, |
1033 | GNUNET_GNSRECORD_records_serialize (rd_count, | 1038 | rd, |
1034 | rd, | 1039 | rd_ser_len, |
1035 | rd_ser_len, | 1040 | rd_ser); |
1036 | rd_ser)); | 1041 | if (0 > sret) |
1042 | { | ||
1043 | GNUNET_free (env); | ||
1044 | return NULL; | ||
1045 | } | ||
1046 | GNUNET_assert (rd_ser_len == (size_t) sret); | ||
1037 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1047 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1038 | "Sending NAMESTORE_RECORD_STORE message for name `%s' with %u records\n", | 1048 | "Sending NAMESTORE_RECORD_STORE message for name `%s' with %u records\n", |
1039 | label, | 1049 | label, |
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c index 5c3533506..eb2378ed4 100644 --- a/src/namestore/plugin_namestore_sqlite.c +++ b/src/namestore/plugin_namestore_sqlite.c | |||
@@ -466,7 +466,7 @@ namestore_sqlite_store_records (void *cls, | |||
466 | uint32_t rd_count32 = (uint32_t) rd_count; | 466 | uint32_t rd_count32 = (uint32_t) rd_count; |
467 | struct GNUNET_SQ_QueryParam sparams[] = { | 467 | struct GNUNET_SQ_QueryParam sparams[] = { |
468 | GNUNET_SQ_query_param_auto_from_type (zone_key), | 468 | GNUNET_SQ_query_param_auto_from_type (zone_key), |
469 | GNUNET_SQ_query_param_auto_from_type (&rvalue), | 469 | GNUNET_SQ_query_param_auto_from_type (&pkey), |
470 | GNUNET_SQ_query_param_uint64 (&rvalue), | 470 | GNUNET_SQ_query_param_uint64 (&rvalue), |
471 | GNUNET_SQ_query_param_uint32 (&rd_count32), | 471 | GNUNET_SQ_query_param_uint32 (&rd_count32), |
472 | GNUNET_SQ_query_param_fixed_size (data, data_size), | 472 | GNUNET_SQ_query_param_fixed_size (data, data_size), |
diff --git a/src/namestore/test_namestore_api_zone_to_name.c b/src/namestore/test_namestore_api_zone_to_name.c index ca33ee280..2bc7d34a3 100644 --- a/src/namestore/test_namestore_api_zone_to_name.c +++ b/src/namestore/test_namestore_api_zone_to_name.c | |||
@@ -37,28 +37,25 @@ | |||
37 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100) | 37 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100) |
38 | 38 | ||
39 | 39 | ||
40 | static struct GNUNET_NAMESTORE_Handle * nsh; | 40 | static struct GNUNET_NAMESTORE_Handle *nsh; |
41 | 41 | ||
42 | static struct GNUNET_SCHEDULER_Task * endbadly_task; | 42 | static struct GNUNET_SCHEDULER_Task *endbadly_task; |
43 | 43 | ||
44 | static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey; | 44 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; |
45 | 45 | ||
46 | static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; | 46 | static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; |
47 | 47 | ||
48 | static struct GNUNET_TIME_Absolute expire; | 48 | static struct GNUNET_CRYPTO_EcdsaPublicKey s_zone_value; |
49 | |||
50 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; | ||
51 | |||
52 | static struct GNUNET_CRYPTO_ShortHashCode s_zone_value; | ||
53 | 49 | ||
54 | static char * s_name; | 50 | static char * s_name; |
55 | 51 | ||
56 | static struct GNUNET_CRYPTO_EcdsaSignature *s_signature; | ||
57 | |||
58 | static int res; | 52 | static int res; |
59 | 53 | ||
60 | static char *directory; | 54 | static char *directory; |
61 | 55 | ||
56 | static struct GNUNET_NAMESTORE_QueueEntry *qe; | ||
57 | |||
58 | |||
62 | /** | 59 | /** |
63 | * Re-establish the connection to the service. | 60 | * Re-establish the connection to the service. |
64 | * | 61 | * |
@@ -67,12 +64,8 @@ static char *directory; | |||
67 | static void | 64 | static void |
68 | endbadly (void *cls) | 65 | endbadly (void *cls) |
69 | { | 66 | { |
70 | if (nsh != NULL) | 67 | (void) cls; |
71 | GNUNET_NAMESTORE_disconnect (nsh); | 68 | GNUNET_SCHEDULER_shutdown (); |
72 | nsh = NULL; | ||
73 | if (privkey != NULL) | ||
74 | GNUNET_free (privkey); | ||
75 | privkey = NULL; | ||
76 | res = 1; | 69 | res = 1; |
77 | } | 70 | } |
78 | 71 | ||
@@ -80,50 +73,69 @@ endbadly (void *cls) | |||
80 | static void | 73 | static void |
81 | end (void *cls) | 74 | end (void *cls) |
82 | { | 75 | { |
83 | if (endbadly_task != NULL) | 76 | if (NULL != qe) |
77 | { | ||
78 | GNUNET_NAMESTORE_cancel (qe); | ||
79 | qe = NULL; | ||
80 | } | ||
81 | if (NULL != endbadly_task) | ||
84 | { | 82 | { |
85 | GNUNET_SCHEDULER_cancel (endbadly_task); | 83 | GNUNET_SCHEDULER_cancel (endbadly_task); |
86 | endbadly_task = NULL; | 84 | endbadly_task = NULL; |
87 | } | 85 | } |
88 | if (privkey != NULL) | 86 | if (NULL != privkey) |
87 | { | ||
89 | GNUNET_free (privkey); | 88 | GNUNET_free (privkey); |
90 | privkey = NULL; | 89 | privkey = NULL; |
91 | if (nsh != NULL) | 90 | } |
91 | if (NULL != nsh) | ||
92 | { | ||
92 | GNUNET_NAMESTORE_disconnect (nsh); | 93 | GNUNET_NAMESTORE_disconnect (nsh); |
93 | nsh = NULL; | 94 | nsh = NULL; |
95 | } | ||
94 | } | 96 | } |
95 | 97 | ||
96 | 98 | ||
97 | static void | 99 | static void |
98 | zone_to_name_proc (void *cls, | 100 | zone_to_name_proc (void *cls, |
99 | const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, | 101 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
100 | struct GNUNET_TIME_Absolute expire, | ||
101 | const char *n, | 102 | const char *n, |
102 | unsigned int rd_count, | 103 | unsigned int rd_count, |
103 | const struct GNUNET_GNSRECORD_Data *rd, | 104 | const struct GNUNET_GNSRECORD_Data *rd) |
104 | const struct GNUNET_CRYPTO_EcdsaSignature *signature) | ||
105 | { | 105 | { |
106 | int fail = GNUNET_NO; | 106 | int fail = GNUNET_NO; |
107 | 107 | ||
108 | if ((zone_key == NULL) && (n == NULL) && (rd_count == 0) && (rd == NULL) && (signature == NULL)) | 108 | qe = NULL; |
109 | if ( (NULL == zone_key) && | ||
110 | (NULL == n) && | ||
111 | (0 == rd_count) && | ||
112 | (NULL == rd) ) | ||
109 | { | 113 | { |
110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No result found\n"); | 114 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
115 | "No result found\n"); | ||
111 | res = 1; | 116 | res = 1; |
112 | } | 117 | } |
113 | else | 118 | else |
114 | { | 119 | { |
115 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result found: `%s'\n", n); | 120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
116 | if ((n == NULL) || (0 != strcmp(n, s_name))) | 121 | "Result found: `%s'\n", |
122 | n); | ||
123 | if ( (NULL == n) || | ||
124 | (0 != strcmp (n, | ||
125 | s_name))) | ||
117 | { | 126 | { |
118 | fail = GNUNET_YES; | 127 | fail = GNUNET_YES; |
119 | GNUNET_break (0); | 128 | GNUNET_break (0); |
120 | } | 129 | } |
121 | if (rd_count != 1) | 130 | if (1 != rd_count) |
122 | { | 131 | { |
123 | fail = GNUNET_YES; | 132 | fail = GNUNET_YES; |
124 | GNUNET_break (0); | 133 | GNUNET_break (0); |
125 | } | 134 | } |
126 | if ((zone_key == NULL) || (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))) | 135 | if ( (NULL == zone_key) || |
136 | (0 != memcmp (zone_key, | ||
137 | privkey, | ||
138 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))) | ||
127 | { | 139 | { |
128 | fail = GNUNET_YES; | 140 | fail = GNUNET_YES; |
129 | GNUNET_break (0); | 141 | GNUNET_break (0); |
@@ -133,29 +145,54 @@ zone_to_name_proc (void *cls, | |||
133 | else | 145 | else |
134 | res = 1; | 146 | res = 1; |
135 | } | 147 | } |
136 | GNUNET_SCHEDULER_add_now(&end, NULL); | 148 | GNUNET_SCHEDULER_add_now (&end, |
149 | NULL); | ||
137 | } | 150 | } |
138 | 151 | ||
139 | 152 | ||
140 | static void | 153 | static void |
141 | put_cont (void *cls, int32_t success, const char *emsg) | 154 | error_cb (void *cls) |
155 | { | ||
156 | (void) cls; | ||
157 | qe = NULL; | ||
158 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
159 | "Not found!\n"); | ||
160 | GNUNET_SCHEDULER_shutdown (); | ||
161 | res = 2; | ||
162 | } | ||
163 | |||
164 | |||
165 | static void | ||
166 | put_cont (void *cls, | ||
167 | int32_t success, | ||
168 | const char *emsg) | ||
142 | { | 169 | { |
143 | char *name = cls; | 170 | char *name = cls; |
144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name store added record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | 171 | |
172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
173 | "Name store added record for `%s': %s\n", | ||
174 | name, | ||
175 | (success == GNUNET_OK) ? "SUCCESS" : emsg); | ||
145 | if (success == GNUNET_OK) | 176 | if (success == GNUNET_OK) |
146 | { | 177 | { |
147 | res = 0; | 178 | res = 0; |
148 | 179 | ||
149 | /* create initial record */ | 180 | qe = GNUNET_NAMESTORE_zone_to_name (nsh, |
150 | GNUNET_NAMESTORE_zone_to_name (nsh, &s_zone, &s_zone_value, zone_to_name_proc, NULL); | 181 | privkey, |
151 | 182 | &s_zone_value, | |
183 | &error_cb, | ||
184 | NULL, | ||
185 | &zone_to_name_proc, | ||
186 | NULL); | ||
152 | } | 187 | } |
153 | else | 188 | else |
154 | { | 189 | { |
155 | res = 1; | 190 | res = 1; |
156 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 191 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
157 | "Failed to put records for name `%s'\n", name); | 192 | "Failed to put records for name `%s'\n", |
158 | GNUNET_SCHEDULER_add_now(&end, NULL); | 193 | name); |
194 | GNUNET_SCHEDULER_add_now (&end, | ||
195 | NULL); | ||
159 | } | 196 | } |
160 | } | 197 | } |
161 | 198 | ||
@@ -165,57 +202,72 @@ run (void *cls, | |||
165 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 202 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
166 | struct GNUNET_TESTING_Peer *peer) | 203 | struct GNUNET_TESTING_Peer *peer) |
167 | { | 204 | { |
168 | struct GNUNET_TIME_Absolute et; | 205 | (void) cls; |
169 | 206 | (void) peer; | |
170 | directory = NULL; | 207 | directory = NULL; |
171 | GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "GNUNET_TEST_HOME", &directory); | 208 | GNUNET_assert (GNUNET_OK == |
209 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
210 | "PATHS", | ||
211 | "GNUNET_TEST_HOME", | ||
212 | &directory)); | ||
172 | GNUNET_DISK_directory_remove (directory); | 213 | GNUNET_DISK_directory_remove (directory); |
173 | 214 | ||
174 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | 215 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
216 | &endbadly, | ||
217 | NULL); | ||
218 | GNUNET_SCHEDULER_add_shutdown (&end, | ||
219 | NULL); | ||
175 | GNUNET_asprintf (&s_name, "dummy"); | 220 | GNUNET_asprintf (&s_name, "dummy"); |
176 | /* load privat key */ | 221 | /* load privat key */ |
177 | char *hostkey_file; | 222 | { |
178 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 223 | char *zonekey_file; |
179 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 224 | |
180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 225 | GNUNET_asprintf (&zonekey_file, |
181 | "Using zonekey file `%s'\n", | 226 | "zonefiles%s%s", |
182 | hostkey_file); | 227 | DIR_SEPARATOR_STR, |
183 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); | 228 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
184 | GNUNET_free (hostkey_file); | 229 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
185 | GNUNET_assert (privkey != NULL); | 230 | "Using zonekey file `%s'\n", |
231 | zonekey_file); | ||
232 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (zonekey_file); | ||
233 | GNUNET_free (zonekey_file); | ||
234 | } | ||
235 | GNUNET_assert (NULL != privkey); | ||
186 | /* get public key */ | 236 | /* get public key */ |
187 | GNUNET_CRYPTO_ecdsa_key_get_public(privkey, &pubkey); | 237 | GNUNET_CRYPTO_ecdsa_key_get_public (privkey, |
238 | &pubkey); | ||
188 | 239 | ||
189 | /* zone hash */ | 240 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, |
190 | GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), &s_zone); | 241 | &s_zone_value, |
191 | GNUNET_CRYPTO_short_hash (s_name, strlen (s_name) + 1, &s_zone_value); | 242 | sizeof (s_zone_value)); |
192 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 243 | { |
193 | "Using PKEY `%s' \n", | 244 | struct GNUNET_GNSRECORD_Data rd; |
194 | GNUNET_NAMESTORE_short_h2s (&s_zone_value)); | 245 | |
195 | 246 | rd.expiration_time = GNUNET_TIME_absolute_get().abs_value_us; | |
196 | struct GNUNET_GNSRECORD_Data rd; | 247 | rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; |
197 | rd.expiration_time = GNUNET_TIME_absolute_get().abs_value_us; | 248 | rd.data_size = sizeof (s_zone_value); |
198 | rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY; | 249 | rd.data = &s_zone_value; |
199 | rd.data_size = sizeof (struct GNUNET_CRYPTO_ShortHashCode); | 250 | rd.flags = 0; |
200 | rd.data = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_ShortHashCode)); | 251 | |
201 | rd.flags = 0; | 252 | nsh = GNUNET_NAMESTORE_connect (cfg); |
202 | GNUNET_memcpy ((char *) rd.data, &s_zone_value, sizeof (struct GNUNET_CRYPTO_ShortHashCode)); | 253 | GNUNET_break (NULL != nsh); |
203 | nsh = GNUNET_NAMESTORE_connect (cfg); | 254 | GNUNET_NAMESTORE_records_store (nsh, |
204 | GNUNET_break (NULL != nsh); | 255 | privkey, |
205 | 256 | s_name, | |
206 | expire = GNUNET_TIME_absolute_get (); | 257 | 1, |
207 | et.abs_value_us = rd.expiration_time; | 258 | &rd, |
208 | s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, &rd, 1); | 259 | &put_cont, |
209 | GNUNET_NAMESTORE_record_put(nsh, &pubkey, s_name, expire, 1, &rd, s_signature, put_cont, NULL); | 260 | NULL); |
210 | 261 | } | |
211 | GNUNET_free ((void *) rd.data); | ||
212 | } | 262 | } |
213 | 263 | ||
214 | 264 | ||
215 | |||
216 | int | 265 | int |
217 | main (int argc, char *argv[]) | 266 | main (int argc, |
267 | char *argv[]) | ||
218 | { | 268 | { |
269 | (void) argc; | ||
270 | (void) argv; | ||
219 | res = 1; | 271 | res = 1; |
220 | if (0 != | 272 | if (0 != |
221 | GNUNET_TESTING_peer_run ("test-namestore-api-zone-to-name", | 273 | GNUNET_TESTING_peer_run ("test-namestore-api-zone-to-name", |
@@ -227,8 +279,8 @@ main (int argc, char *argv[]) | |||
227 | } | 279 | } |
228 | if (NULL != directory) | 280 | if (NULL != directory) |
229 | { | 281 | { |
230 | GNUNET_DISK_directory_remove (directory); | 282 | GNUNET_DISK_directory_remove (directory); |
231 | GNUNET_free (directory); | 283 | GNUNET_free (directory); |
232 | } | 284 | } |
233 | return res; | 285 | return res; |
234 | } | 286 | } |
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index 045fe74b1..d9fed26a6 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c | |||
@@ -100,8 +100,8 @@ extract_varsize_blob (void *cls, | |||
100 | idst = GNUNET_malloc (len); | 100 | idst = GNUNET_malloc (len); |
101 | *((void **) dst) = idst; | 101 | *((void **) dst) = idst; |
102 | GNUNET_memcpy (idst, | 102 | GNUNET_memcpy (idst, |
103 | res, | 103 | res, |
104 | len); | 104 | len); |
105 | return GNUNET_OK; | 105 | return GNUNET_OK; |
106 | } | 106 | } |
107 | 107 | ||
@@ -165,7 +165,7 @@ extract_fixed_blob (void *cls, | |||
165 | { | 165 | { |
166 | GNUNET_break (0); | 166 | GNUNET_break (0); |
167 | return GNUNET_SYSERR; | 167 | return GNUNET_SYSERR; |
168 | } | 168 | } |
169 | 169 | ||
170 | /* if a field is null, continue but | 170 | /* if a field is null, continue but |
171 | * remember that we now return a different result */ | 171 | * remember that we now return a different result */ |
@@ -182,8 +182,8 @@ extract_fixed_blob (void *cls, | |||
182 | fnum); | 182 | fnum); |
183 | GNUNET_assert (NULL != res); | 183 | GNUNET_assert (NULL != res); |
184 | GNUNET_memcpy (dst, | 184 | GNUNET_memcpy (dst, |
185 | res, | 185 | res, |
186 | len); | 186 | len); |
187 | return GNUNET_OK; | 187 | return GNUNET_OK; |
188 | } | 188 | } |
189 | 189 | ||
@@ -580,7 +580,7 @@ extract_uint16 (void *cls, | |||
580 | if (PQgetisnull (result, | 580 | if (PQgetisnull (result, |
581 | row, | 581 | row, |
582 | fnum)) | 582 | fnum)) |
583 | { | 583 | { |
584 | GNUNET_break (0); | 584 | GNUNET_break (0); |
585 | return GNUNET_SYSERR; | 585 | return GNUNET_SYSERR; |
586 | } | 586 | } |
@@ -590,6 +590,14 @@ extract_uint16 (void *cls, | |||
590 | GNUNET_break (0); | 590 | GNUNET_break (0); |
591 | return GNUNET_SYSERR; | 591 | return GNUNET_SYSERR; |
592 | } | 592 | } |
593 | if (sizeof (uint16_t) != | ||
594 | PQgetlength (result, | ||
595 | row, | ||
596 | fnum)) | ||
597 | { | ||
598 | GNUNET_break (0); | ||
599 | return GNUNET_SYSERR; | ||
600 | } | ||
593 | res = (uint16_t *) PQgetvalue (result, | 601 | res = (uint16_t *) PQgetvalue (result, |
594 | row, | 602 | row, |
595 | fnum); | 603 | fnum); |
@@ -663,6 +671,14 @@ extract_uint32 (void *cls, | |||
663 | GNUNET_break (0); | 671 | GNUNET_break (0); |
664 | return GNUNET_SYSERR; | 672 | return GNUNET_SYSERR; |
665 | } | 673 | } |
674 | if (sizeof (uint32_t) != | ||
675 | PQgetlength (result, | ||
676 | row, | ||
677 | fnum)) | ||
678 | { | ||
679 | GNUNET_break (0); | ||
680 | return GNUNET_SYSERR; | ||
681 | } | ||
666 | res = (uint32_t *) PQgetvalue (result, | 682 | res = (uint32_t *) PQgetvalue (result, |
667 | row, | 683 | row, |
668 | fnum); | 684 | fnum); |
@@ -736,6 +752,14 @@ extract_uint64 (void *cls, | |||
736 | GNUNET_break (0); | 752 | GNUNET_break (0); |
737 | return GNUNET_SYSERR; | 753 | return GNUNET_SYSERR; |
738 | } | 754 | } |
755 | if (sizeof (uint64_t) != | ||
756 | PQgetlength (result, | ||
757 | row, | ||
758 | fnum)) | ||
759 | { | ||
760 | GNUNET_break (0); | ||
761 | return GNUNET_SYSERR; | ||
762 | } | ||
739 | res = (uint64_t *) PQgetvalue (result, | 763 | res = (uint64_t *) PQgetvalue (result, |
740 | row, | 764 | row, |
741 | fnum); | 765 | fnum); |
diff --git a/src/psyc/Makefile.am b/src/psyc/Makefile.am index a16128624..61618d176 100644 --- a/src/psyc/Makefile.am +++ b/src/psyc/Makefile.am | |||
@@ -33,7 +33,7 @@ libgnunetpsyc_la_LDFLAGS = \ | |||
33 | bin_PROGRAMS = | 33 | bin_PROGRAMS = |
34 | 34 | ||
35 | libexec_PROGRAMS = \ | 35 | libexec_PROGRAMS = \ |
36 | gnunet-service-psyc | 36 | gnunet-service-psyc |
37 | 37 | ||
38 | gnunet_service_psyc_SOURCES = \ | 38 | gnunet_service_psyc_SOURCES = \ |
39 | gnunet-service-psyc.c | 39 | gnunet-service-psyc.c |
@@ -49,7 +49,8 @@ gnunet_service_psyc_CFLAGS = $(AM_CFLAGS) | |||
49 | 49 | ||
50 | if HAVE_TESTING | 50 | if HAVE_TESTING |
51 | check_PROGRAMS = \ | 51 | check_PROGRAMS = \ |
52 | test_psyc | 52 | test_psyc2 |
53 | # test_psyc | ||
53 | endif | 54 | endif |
54 | 55 | ||
55 | if ENABLE_TEST_RUN | 56 | if ENABLE_TEST_RUN |
@@ -64,6 +65,13 @@ test_psyc_LDADD = \ | |||
64 | $(top_builddir)/src/psycutil/libgnunetpsycutil.la \ | 65 | $(top_builddir)/src/psycutil/libgnunetpsycutil.la \ |
65 | $(top_builddir)/src/testing/libgnunettesting.la \ | 66 | $(top_builddir)/src/testing/libgnunettesting.la \ |
66 | $(top_builddir)/src/util/libgnunetutil.la | 67 | $(top_builddir)/src/util/libgnunetutil.la |
68 | test_psyc2_SOURCES = \ | ||
69 | test_psyc2.c | ||
70 | test_psyc2_LDADD = \ | ||
71 | libgnunetpsyc.la \ | ||
72 | $(top_builddir)/src/psycutil/libgnunetpsycutil.la \ | ||
73 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
74 | $(top_builddir)/src/util/libgnunetutil.la | ||
67 | 75 | ||
68 | EXTRA_DIST = \ | 76 | EXTRA_DIST = \ |
69 | test_psyc.conf | 77 | test_psyc.conf |
diff --git a/src/psyc/psyc_test_lib.h b/src/psyc/psyc_test_lib.h new file mode 100644 index 000000000..10e3c46fe --- /dev/null +++ b/src/psyc/psyc_test_lib.h | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * This file is part of GNUnet | ||
3 | * Copyright (C) 2013 GNUnet e.V. | ||
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., 51 Franklin Street, Fifth Floor, | ||
18 | * Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file psyc/test_psyc_api_join.c | ||
23 | * @brief library for writing psyc tests | ||
24 | * @author xrs | ||
25 | */ | ||
26 | |||
27 | #define MAX_TESTBED_OPS 32 | ||
28 | |||
29 | struct pctx | ||
30 | { | ||
31 | int idx; | ||
32 | |||
33 | struct GNUNET_TESTBED_Peer *testbed_peer; | ||
34 | |||
35 | const struct GNUNET_PeerIdentity *peer_id; | ||
36 | |||
37 | const struct GNUNET_PeerIdentity *peer_id_master; | ||
38 | |||
39 | /** | ||
40 | * Used to simulate egos (not peerid) | ||
41 | */ | ||
42 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *id_key; | ||
43 | |||
44 | const struct GNUNET_CRYPTO_EcdsaPublicKey *id_pub_key; | ||
45 | |||
46 | /** | ||
47 | * Used to store either GNUNET_PSYC_Master or GNUNET_PSYC_Slave handle | ||
48 | */ | ||
49 | void *psyc; | ||
50 | |||
51 | struct GNUNET_PSYC_Channel *channel; | ||
52 | |||
53 | const struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; | ||
54 | |||
55 | struct GNUNET_CRYPTO_EddsaPublicKey *channel_pub_key; | ||
56 | |||
57 | int test_ok; | ||
58 | }; | ||
59 | |||
60 | static struct GNUNET_SCHEDULER_Task *timeout_task_id; | ||
61 | |||
62 | static int result = GNUNET_SYSERR; | ||
63 | |||
64 | static struct GNUNET_TESTBED_Operation *op[MAX_TESTBED_OPS]; | ||
65 | |||
66 | static int op_cnt = 0; | ||
67 | |||
diff --git a/src/psyc/test_psyc.conf b/src/psyc/test_psyc.conf index e00a614d2..836255163 100644 --- a/src/psyc/test_psyc.conf +++ b/src/psyc/test_psyc.conf | |||
@@ -1,16 +1,28 @@ | |||
1 | @INLINE@ ../../contrib/no_forcestart.conf | 1 | @INLINE@ ../../contrib/no_forcestart.conf |
2 | 2 | ||
3 | [PATHS] | 3 | [testbed] |
4 | GNUNET_TEST_HOME = /tmp/gnunet-test-psyc/ | 4 | HOSTNAME = localhost |
5 | OVERLAY_TOPOLOGY = STAR | ||
5 | 6 | ||
6 | [transport] | 7 | [peerinfo] |
7 | PLUGINS = tcp | 8 | # Option to disable all disk IO; only useful for testbed runs |
9 | # (large-scale experiments); disables persistence of HELLOs! | ||
10 | NO_IO = YES | ||
11 | |||
12 | [cadet] | ||
13 | ID_ANNOUNCE_TIME = 5 s | ||
8 | 14 | ||
9 | [nat] | 15 | [nat] |
10 | DISABLEV6 = YES | ||
11 | ENABLE_UPNP = NO | 16 | ENABLE_UPNP = NO |
12 | BEHIND_NAT = NO | ||
13 | ALLOW_NAT = NO | ||
14 | INTERNAL_ADDRESS = 127.0.0.1 | ||
15 | EXTERNAL_ADDRESS = 127.0.0.1 | ||
16 | 17 | ||
18 | [psyc] | ||
19 | FORCESTART = YES | ||
20 | AUTOSTART = YES | ||
21 | |||
22 | [multicast] | ||
23 | FORCESTART = YES | ||
24 | AUTOSTART = YES | ||
25 | |||
26 | [psycstore] | ||
27 | FORCESTART = YES | ||
28 | AUTOSTART = YES | ||
diff --git a/src/psyc/test_psyc2.c b/src/psyc/test_psyc2.c new file mode 100644 index 000000000..bbf3eed9d --- /dev/null +++ b/src/psyc/test_psyc2.c | |||
@@ -0,0 +1,284 @@ | |||
1 | /* | ||
2 | * This file is part of GNUnet | ||
3 | * Copyright (C) 2013 GNUnet e.V. | ||
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., 51 Franklin Street, Fifth Floor, | ||
18 | * Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file psyc/test_psyc2.c | ||
23 | * @brief Testbed test for the PSYC API. | ||
24 | * @author xrs | ||
25 | */ | ||
26 | |||
27 | #include "platform.h" | ||
28 | #include "gnunet_crypto_lib.h" | ||
29 | #include "gnunet_common.h" | ||
30 | #include "gnunet_util_lib.h" | ||
31 | #include "gnunet_testbed_service.h" | ||
32 | #include "gnunet_psyc_util_lib.h" | ||
33 | #include "gnunet_psyc_service.h" | ||
34 | |||
35 | #define PEERS_REQUESTED 2 | ||
36 | |||
37 | static int result; | ||
38 | |||
39 | static struct GNUNET_SCHEDULER_Task *timeout_tid; | ||
40 | static struct pctx **pctx; | ||
41 | |||
42 | static struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; | ||
43 | static struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key; | ||
44 | |||
45 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; | ||
46 | static struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key; | ||
47 | |||
48 | /** | ||
49 | * Task To perform tests | ||
50 | */ | ||
51 | static struct GNUNET_SCHEDULER_Task *test_task; | ||
52 | |||
53 | /** | ||
54 | * Peer id couter | ||
55 | */ | ||
56 | static unsigned int pids; | ||
57 | |||
58 | struct pctx | ||
59 | { | ||
60 | int idx; | ||
61 | struct GNUNET_TESTBED_Peer *peer; | ||
62 | const struct GNUNET_PeerIdentity *id; | ||
63 | |||
64 | struct GNUNET_TESTBED_Operation *op; | ||
65 | |||
66 | /** | ||
67 | * psyc service handle | ||
68 | */ | ||
69 | void *psyc; | ||
70 | struct GNUNET_PSYC_Master *mst; | ||
71 | struct GNUNET_PSYC_Slave *slv; | ||
72 | |||
73 | /** | ||
74 | * result for test on peer | ||
75 | */ | ||
76 | int test_ok; | ||
77 | }; | ||
78 | |||
79 | static void | ||
80 | shutdown_task (void *cls) | ||
81 | { | ||
82 | if (NULL != pctx) | ||
83 | { | ||
84 | if (NULL != pctx[0]->mst) | ||
85 | GNUNET_PSYC_master_stop (pctx[0]->mst, GNUNET_NO, NULL, NULL); | ||
86 | |||
87 | for (int i=0; i < PEERS_REQUESTED; i++) | ||
88 | { | ||
89 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Operation done.\n"); | ||
90 | GNUNET_TESTBED_operation_done (pctx[i]->op); | ||
91 | GNUNET_free_non_null (pctx[i]); | ||
92 | } | ||
93 | GNUNET_free (pctx); | ||
94 | } | ||
95 | |||
96 | if (NULL != timeout_tid) | ||
97 | GNUNET_SCHEDULER_cancel (timeout_tid); | ||
98 | } | ||
99 | |||
100 | static void | ||
101 | timeout_task (void *cls) | ||
102 | { | ||
103 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout!\n"); | ||
104 | result = GNUNET_SYSERR; | ||
105 | GNUNET_SCHEDULER_shutdown (); | ||
106 | } | ||
107 | |||
108 | static void | ||
109 | start_test (void *cls) | ||
110 | { | ||
111 | } | ||
112 | |||
113 | static void | ||
114 | pinfo_cb (void *cls, | ||
115 | struct GNUNET_TESTBED_Operation *operation, | ||
116 | const struct GNUNET_TESTBED_PeerInformation *pinfo, | ||
117 | const char *emsg) | ||
118 | { | ||
119 | struct pctx *pc = (struct pctx*) cls; | ||
120 | |||
121 | pc->id = pinfo->result.id; | ||
122 | |||
123 | pids++; | ||
124 | if (pids < (PEERS_REQUESTED - 1)) | ||
125 | return; | ||
126 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all IDs, starting test\n"); | ||
127 | test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL); | ||
128 | } | ||
129 | |||
130 | static void | ||
131 | mst_start_cb () | ||
132 | { | ||
133 | } | ||
134 | |||
135 | static void | ||
136 | join_request_cb () | ||
137 | { | ||
138 | } | ||
139 | |||
140 | static void | ||
141 | mst_message_cb () | ||
142 | { | ||
143 | } | ||
144 | |||
145 | static void | ||
146 | mst_message_part_cb () | ||
147 | { | ||
148 | } | ||
149 | |||
150 | static void | ||
151 | slv_message_cb () | ||
152 | { | ||
153 | } | ||
154 | |||
155 | static void | ||
156 | slv_message_part_cb () | ||
157 | { | ||
158 | } | ||
159 | |||
160 | static void | ||
161 | slv_connect_cb () | ||
162 | { | ||
163 | } | ||
164 | |||
165 | static void | ||
166 | join_decision_cb () | ||
167 | { | ||
168 | } | ||
169 | |||
170 | static void * | ||
171 | psyc_ca (void *cls, | ||
172 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
173 | { | ||
174 | struct GNUNET_PSYC_Message *join_msg = NULL; | ||
175 | struct pctx *pc = (struct pctx *) cls; | ||
176 | |||
177 | if (0 == pc->idx) | ||
178 | { | ||
179 | pc->mst = GNUNET_PSYC_master_start (cfg, channel_key, | ||
180 | GNUNET_PSYC_CHANNEL_PRIVATE, | ||
181 | &mst_start_cb, &join_request_cb, | ||
182 | &mst_message_cb, &mst_message_part_cb, | ||
183 | NULL); | ||
184 | return pc->mst; | ||
185 | } | ||
186 | |||
187 | pc->slv = GNUNET_PSYC_slave_join (cfg, &channel_pub_key, slave_key, | ||
188 | GNUNET_PSYC_SLAVE_JOIN_NONE, | ||
189 | &pid, 0, NULL, &slv_message_cb, | ||
190 | &slv_message_part_cb, | ||
191 | &slv_connect_cb, &join_decision_cb, | ||
192 | NULL, join_msg); | ||
193 | return pc->slv; | ||
194 | } | ||
195 | |||
196 | static void | ||
197 | psyc_da (void *cls, | ||
198 | void *op_result) | ||
199 | { | ||
200 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Disconnected from service.\n"); | ||
201 | } | ||
202 | |||
203 | static void | ||
204 | service_connect (void *cls, | ||
205 | struct GNUNET_TESTBED_Operation *op, | ||
206 | void *ca_result, | ||
207 | const char *emsg) | ||
208 | { | ||
209 | struct pctx *pc = (struct pctx *) cls; | ||
210 | |||
211 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
212 | "Connected to service\n"); | ||
213 | |||
214 | GNUNET_assert (NULL != ca_result); | ||
215 | |||
216 | // FIXME: we need a simple service handle to connect to the service, then | ||
217 | // get peer information and AFTER that make PSYC ops. Compare to CADET. | ||
218 | pc->psyc = ca_result; | ||
219 | |||
220 | GNUNET_TESTBED_peer_get_information (pc->peer, | ||
221 | GNUNET_TESTBED_PIT_IDENTITY, | ||
222 | pinfo_cb, pc); | ||
223 | } | ||
224 | |||
225 | static void | ||
226 | testbed_master (void *cls, | ||
227 | struct GNUNET_TESTBED_RunHandle *h, | ||
228 | unsigned int num_peers, | ||
229 | struct GNUNET_TESTBED_Peer **p, | ||
230 | unsigned int links_succeeded, | ||
231 | unsigned int links_failed) | ||
232 | { | ||
233 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connected to testbed_master()\n"); | ||
234 | |||
235 | // Create ctx for peers | ||
236 | pctx = GNUNET_new_array (PEERS_REQUESTED, struct pctx*); | ||
237 | for (int i = 0; i<PEERS_REQUESTED; i++) | ||
238 | { | ||
239 | pctx[i] = GNUNET_new (struct pctx); | ||
240 | pctx[i]->idx = i; | ||
241 | pctx[i]->peer = p[i]; | ||
242 | pctx[i]->id = NULL; | ||
243 | pctx[i]->mst = NULL; | ||
244 | pctx[i]->op = NULL; | ||
245 | pctx[i]->test_ok = GNUNET_NO; | ||
246 | } | ||
247 | |||
248 | channel_key = GNUNET_CRYPTO_eddsa_key_create (); | ||
249 | slave_key = GNUNET_CRYPTO_ecdsa_key_create (); | ||
250 | |||
251 | GNUNET_CRYPTO_eddsa_key_get_public (channel_key, &channel_pub_key); | ||
252 | GNUNET_CRYPTO_ecdsa_key_get_public (slave_key, &slave_pub_key); | ||
253 | |||
254 | pctx[0]->op = | ||
255 | GNUNET_TESTBED_service_connect (NULL, p[0], "psyc", service_connect, | ||
256 | pctx[0], psyc_ca, psyc_da, pctx[0]); | ||
257 | |||
258 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | ||
259 | |||
260 | timeout_tid = | ||
261 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | ||
262 | &timeout_task, NULL); | ||
263 | } | ||
264 | |||
265 | int | ||
266 | main (int argc, char *argv[]) | ||
267 | { | ||
268 | int ret; | ||
269 | |||
270 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test\n"); | ||
271 | |||
272 | result = GNUNET_SYSERR; | ||
273 | |||
274 | ret = GNUNET_TESTBED_test_run ("test-psyc2", "test_psyc.conf", | ||
275 | PEERS_REQUESTED, 0LL, NULL, NULL, | ||
276 | testbed_master, NULL); | ||
277 | |||
278 | if ((GNUNET_OK != ret) || (GNUNET_OK != result)) | ||
279 | return 1; | ||
280 | |||
281 | return 0; | ||
282 | } | ||
283 | |||
284 | /* end of test-psyc2.c */ | ||
diff --git a/src/psyc/test_psyc_api_join.c b/src/psyc/test_psyc_api_join.c new file mode 100644 index 000000000..ae019d42e --- /dev/null +++ b/src/psyc/test_psyc_api_join.c | |||
@@ -0,0 +1,282 @@ | |||
1 | /* | ||
2 | * This file is part of GNUnet | ||
3 | * Copyright (C) 2013 GNUnet e.V. | ||
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., 51 Franklin Street, Fifth Floor, | ||
18 | * Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file psyc/test_psyc_api_join.c | ||
23 | * @brief Testbed test for the PSYC API. | ||
24 | * @author xrs | ||
25 | */ | ||
26 | |||
27 | /** | ||
28 | * Lessons Learned: | ||
29 | * - define topology in config | ||
30 | * - psyc slave join needs part to end (same with master) | ||
31 | * - GNUNET_SCHEDULER_add_delayed return value will outdate at call time | ||
32 | * - main can not contain GNUNET_log() | ||
33 | */ | ||
34 | |||
35 | #include "platform.h" | ||
36 | #include "gnunet_crypto_lib.h" | ||
37 | #include "gnunet_common.h" | ||
38 | #include "gnunet_util_lib.h" | ||
39 | #include "gnunet_testbed_service.h" | ||
40 | #include "gnunet_psyc_util_lib.h" | ||
41 | #include "gnunet_psyc_service.h" | ||
42 | #include "psyc_test_lib.h" | ||
43 | |||
44 | static struct pctx PEERS[2]; | ||
45 | |||
46 | static int pids; | ||
47 | |||
48 | |||
49 | static void | ||
50 | shutdown_task (void *cls) | ||
51 | { | ||
52 | if (NULL != timeout_task_id) { | ||
53 | GNUNET_SCHEDULER_cancel (timeout_task_id); | ||
54 | timeout_task_id = NULL; | ||
55 | } | ||
56 | |||
57 | for (int i=0;i<2;i++) { | ||
58 | GNUNET_free (PEERS[i].channel_pub_key); | ||
59 | |||
60 | if (NULL != PEERS[i].psyc) | ||
61 | { | ||
62 | if (0 == i) | ||
63 | GNUNET_PSYC_master_stop (PEERS[i].psyc, GNUNET_NO, NULL, NULL); | ||
64 | else | ||
65 | GNUNET_PSYC_slave_part (PEERS[i].psyc, GNUNET_NO, NULL, NULL); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | for (int i=0;i<MAX_TESTBED_OPS;i++) | ||
70 | if (NULL != op[i]) | ||
71 | GNUNET_TESTBED_operation_done (op[i]); | ||
72 | |||
73 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shut down!\n"); | ||
74 | } | ||
75 | |||
76 | static void | ||
77 | timeout_task (void *cls) | ||
78 | { | ||
79 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Timeout!\n"); | ||
80 | |||
81 | timeout_task_id = NULL; | ||
82 | |||
83 | result = GNUNET_SYSERR; | ||
84 | GNUNET_SCHEDULER_shutdown (); | ||
85 | } | ||
86 | |||
87 | static void | ||
88 | join_decision_cb (void *cls, | ||
89 | const struct GNUNET_PSYC_JoinDecisionMessage *dcsn, | ||
90 | int is_admitted, | ||
91 | const struct GNUNET_PSYC_Message *join_msg) | ||
92 | { | ||
93 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
94 | "slave: got join decision: %s\n", | ||
95 | (GNUNET_YES == is_admitted) ? "admitted":"rejected"); | ||
96 | |||
97 | result = (GNUNET_YES == is_admitted) ? GNUNET_OK : GNUNET_SYSERR; | ||
98 | |||
99 | GNUNET_SCHEDULER_shutdown (); | ||
100 | } | ||
101 | |||
102 | static void | ||
103 | join_request_cb (void *cls, | ||
104 | const struct GNUNET_PSYC_JoinRequestMessage *req, | ||
105 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | ||
106 | const struct GNUNET_PSYC_Message *join_msg, | ||
107 | struct GNUNET_PSYC_JoinHandle *jh) | ||
108 | { | ||
109 | struct GNUNET_HashCode slave_key_hash; | ||
110 | |||
111 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "master: got join request.\n"); | ||
112 | |||
113 | GNUNET_CRYPTO_hash (slave_key, sizeof (*slave_key), &slave_key_hash); | ||
114 | |||
115 | GNUNET_PSYC_join_decision (jh, GNUNET_YES, 0, NULL, NULL); | ||
116 | } | ||
117 | |||
118 | static void | ||
119 | psyc_da () | ||
120 | { | ||
121 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "disconnect form PSYC service\n"); | ||
122 | } | ||
123 | |||
124 | static void * | ||
125 | psyc_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
126 | { | ||
127 | struct pctx *peer = (struct pctx*) cls; | ||
128 | |||
129 | // Case: master role | ||
130 | if (0 == peer->idx) { | ||
131 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connecting to PSYC as master ...\n"); | ||
132 | |||
133 | peer->psyc = (struct GNUNET_PSYC_Master *) | ||
134 | GNUNET_PSYC_master_start (cfg, | ||
135 | peer->channel_key, | ||
136 | GNUNET_PSYC_CHANNEL_PRIVATE, | ||
137 | NULL, | ||
138 | join_request_cb, | ||
139 | NULL, | ||
140 | NULL, | ||
141 | cls); | ||
142 | return peer->psyc; | ||
143 | } | ||
144 | |||
145 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connecting to PSYC as slave ...\n"); | ||
146 | |||
147 | struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create (); | ||
148 | GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_ASSIGN, "_foo", "bar baz", 7); | ||
149 | GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_ASSIGN, "_foo_bar", "foo bar baz", 11); | ||
150 | |||
151 | struct GNUNET_PSYC_Message * | ||
152 | join_msg = GNUNET_PSYC_message_create ("_request_join", env, "some data", 40); | ||
153 | |||
154 | peer->psyc = (struct GNUNET_PSYC_Slave *) | ||
155 | GNUNET_PSYC_slave_join (cfg, | ||
156 | peer->channel_pub_key, | ||
157 | peer->id_key, | ||
158 | GNUNET_PSYC_SLAVE_JOIN_NONE, | ||
159 | peer->peer_id_master, | ||
160 | 0, | ||
161 | NULL, | ||
162 | NULL, | ||
163 | NULL, | ||
164 | NULL, | ||
165 | join_decision_cb, | ||
166 | cls, | ||
167 | join_msg); | ||
168 | |||
169 | GNUNET_free (join_msg); | ||
170 | peer->channel = GNUNET_PSYC_slave_get_channel (peer->psyc); | ||
171 | GNUNET_PSYC_env_destroy (env); | ||
172 | |||
173 | return peer->psyc; | ||
174 | } | ||
175 | |||
176 | static void | ||
177 | service_connect (void *cls, | ||
178 | struct GNUNET_TESTBED_Operation *op, | ||
179 | void *ca_result, | ||
180 | const char *emsg) | ||
181 | { | ||
182 | GNUNET_assert (NULL != ca_result); | ||
183 | |||
184 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connected to the service\n"); | ||
185 | } | ||
186 | |||
187 | static void | ||
188 | connect_to_services (void *cls) | ||
189 | { | ||
190 | for (int i = 0; i < 2; i++) | ||
191 | { | ||
192 | PEERS[i].peer_id_master = PEERS[0].peer_id; | ||
193 | |||
194 | op[op_cnt++] = | ||
195 | GNUNET_TESTBED_service_connect (NULL, PEERS[i].testbed_peer, "psyc", | ||
196 | &service_connect, &PEERS[i], &psyc_ca, | ||
197 | &psyc_da, &PEERS[i]); | ||
198 | } | ||
199 | } | ||
200 | |||
201 | static void | ||
202 | pinfo_cb (void *cls, | ||
203 | struct GNUNET_TESTBED_Operation *operation, | ||
204 | const struct GNUNET_TESTBED_PeerInformation *pinfo, | ||
205 | const char *emsg) | ||
206 | { | ||
207 | struct pctx *peer = (struct pctx*) cls; | ||
208 | |||
209 | peer->peer_id = pinfo->result.id; | ||
210 | |||
211 | pids++; | ||
212 | if (pids < 2) | ||
213 | return; | ||
214 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got all IDs, starting test\n"); | ||
215 | |||
216 | GNUNET_SCHEDULER_add_now (&connect_to_services, NULL); | ||
217 | } | ||
218 | |||
219 | static void | ||
220 | testbed_master (void *cls, | ||
221 | struct GNUNET_TESTBED_RunHandle *h, | ||
222 | unsigned int num_peers, | ||
223 | struct GNUNET_TESTBED_Peer **p, | ||
224 | unsigned int links_succeeded, | ||
225 | unsigned int links_failed) | ||
226 | { | ||
227 | struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key = NULL; | ||
228 | |||
229 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connected to testbed_master\n"); | ||
230 | |||
231 | // Set up shutdown logic | ||
232 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | ||
233 | timeout_task_id = | ||
234 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 15), | ||
235 | &timeout_task, NULL); | ||
236 | GNUNET_assert (NULL != timeout_task_id); | ||
237 | |||
238 | // Set up channel key | ||
239 | channel_key = GNUNET_CRYPTO_eddsa_key_create (); | ||
240 | GNUNET_assert (NULL != channel_key); | ||
241 | |||
242 | // Set up information contexts for peers | ||
243 | for (int i=0 ; i < 2 ; i++) | ||
244 | { | ||
245 | PEERS[i].idx = i; | ||
246 | PEERS[i].testbed_peer = p[i]; | ||
247 | |||
248 | // Create "egos" | ||
249 | PEERS[i].id_key = GNUNET_CRYPTO_ecdsa_key_create (); | ||
250 | |||
251 | // Set up channel keys shared by master and slave | ||
252 | PEERS[i].channel_key = channel_key; | ||
253 | |||
254 | PEERS[i].channel_pub_key = | ||
255 | GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); | ||
256 | // Get public key | ||
257 | GNUNET_CRYPTO_eddsa_key_get_public (PEERS[i].channel_key, | ||
258 | PEERS[i].channel_pub_key); | ||
259 | // Get peerinfo | ||
260 | op[op_cnt++] = | ||
261 | GNUNET_TESTBED_peer_get_information (p[i], | ||
262 | GNUNET_TESTBED_PIT_IDENTITY, | ||
263 | pinfo_cb, &PEERS[i]); | ||
264 | } | ||
265 | } | ||
266 | |||
267 | int | ||
268 | main (int argc, char *argv[]) | ||
269 | { | ||
270 | int ret; | ||
271 | |||
272 | ret = GNUNET_TESTBED_test_run ("test_psyc_api_join", "test_psyc.conf", | ||
273 | 2, 0LL, NULL, NULL, | ||
274 | &testbed_master, NULL); | ||
275 | |||
276 | if ( (GNUNET_OK != ret) || (GNUNET_OK != result) ) | ||
277 | return 1; | ||
278 | |||
279 | return 0; | ||
280 | } | ||
281 | |||
282 | /* end of test_psyc_api_join.c */ | ||
diff --git a/src/psycutil/psyc_message.c b/src/psycutil/psyc_message.c index 3421fd0ba..3bd99425e 100644 --- a/src/psycutil/psyc_message.c +++ b/src/psycutil/psyc_message.c | |||
@@ -818,7 +818,6 @@ GNUNET_PSYC_transmit_cancel (struct GNUNET_PSYC_TransmitHandle *tmit) | |||
818 | 818 | ||
819 | /* FIXME */ | 819 | /* FIXME */ |
820 | struct GNUNET_MessageHeader msg; | 820 | struct GNUNET_MessageHeader msg; |
821 | msg.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA); | ||
822 | msg.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL); | 821 | msg.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL); |
823 | msg.size = htons (sizeof (msg)); | 822 | msg.size = htons (sizeof (msg)); |
824 | transmit_queue_insert (tmit, &msg, GNUNET_YES); | 823 | transmit_queue_insert (tmit, &msg, GNUNET_YES); |
diff --git a/src/rps/Makefile.am b/src/rps/Makefile.am index de3469254..b5f712268 100644 --- a/src/rps/Makefile.am +++ b/src/rps/Makefile.am | |||
@@ -141,7 +141,9 @@ test_rps_churn_SOURCES = $(rps_test_src) | |||
141 | test_rps_churn_LDADD = $(ld_rps_test_lib) | 141 | test_rps_churn_LDADD = $(ld_rps_test_lib) |
142 | 142 | ||
143 | gnunet_rps_profiler_SOURCES = $(rps_test_src) | 143 | gnunet_rps_profiler_SOURCES = $(rps_test_src) |
144 | gnunet_rps_profiler_LDADD = $(ld_rps_test_lib) | 144 | gnunet_rps_profiler_LDADD = \ |
145 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
146 | $(ld_rps_test_lib) | ||
145 | 147 | ||
146 | EXTRA_DIST = \ | 148 | EXTRA_DIST = \ |
147 | test_rps.conf | 149 | test_rps.conf |
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index ec70075cf..aeb0eabc2 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_cadet_service.h" | 29 | #include "gnunet_cadet_service.h" |
30 | #include "gnunet_peerinfo_service.h" | 30 | #include "gnunet_peerinfo_service.h" |
31 | #include "gnunet_nse_service.h" | 31 | #include "gnunet_nse_service.h" |
32 | #include "gnunet_statistics_service.h" | ||
32 | #include "rps.h" | 33 | #include "rps.h" |
33 | #include "rps-test_util.h" | 34 | #include "rps-test_util.h" |
34 | #include "gnunet-service-rps_sampler.h" | 35 | #include "gnunet-service-rps_sampler.h" |
@@ -60,6 +61,11 @@ | |||
60 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 61 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
61 | 62 | ||
62 | /** | 63 | /** |
64 | * Handle to the statistics service. | ||
65 | */ | ||
66 | static struct GNUNET_STATISTICS_Handle *stats; | ||
67 | |||
68 | /** | ||
63 | * Our own identity. | 69 | * Our own identity. |
64 | */ | 70 | */ |
65 | static struct GNUNET_PeerIdentity own_identity; | 71 | static struct GNUNET_PeerIdentity own_identity; |
@@ -810,6 +816,12 @@ mq_notify_sent_cb (void *cls) | |||
810 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 816 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
811 | "%s was sent.\n", | 817 | "%s was sent.\n", |
812 | pending_msg->type); | 818 | pending_msg->type); |
819 | if (0 == strncmp ("PULL REPLY", pending_msg->type, 10)) | ||
820 | GNUNET_STATISTICS_update(stats, "# pull replys sent", 1, GNUNET_NO); | ||
821 | if (0 == strncmp ("PULL REQUEST", pending_msg->type, 12)) | ||
822 | GNUNET_STATISTICS_update(stats, "# pull requests sent", 1, GNUNET_NO); | ||
823 | if (0 == strncmp ("PUSH", pending_msg->type, 4)) | ||
824 | GNUNET_STATISTICS_update(stats, "# pushes sent", 1, GNUNET_NO); | ||
813 | /* Do not cancle message */ | 825 | /* Do not cancle message */ |
814 | remove_pending_message (pending_msg, GNUNET_NO); | 826 | remove_pending_message (pending_msg, GNUNET_NO); |
815 | } | 827 | } |
@@ -1515,7 +1527,9 @@ Peers_handle_inbound_channel (void *cls, | |||
1515 | { | 1527 | { |
1516 | set_channel_flag (peer_ctx->recv_channel_flags, | 1528 | set_channel_flag (peer_ctx->recv_channel_flags, |
1517 | Peers_CHANNEL_ESTABLISHED_TWICE); | 1529 | Peers_CHANNEL_ESTABLISHED_TWICE); |
1518 | GNUNET_CADET_channel_destroy (channel); | 1530 | //GNUNET_CADET_channel_destroy (channel); |
1531 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); | ||
1532 | peer_ctx->recv_channel = channel; | ||
1519 | /* return the channel context */ | 1533 | /* return the channel context */ |
1520 | return &peer_ctx->peer_id; | 1534 | return &peer_ctx->peer_id; |
1521 | } | 1535 | } |
@@ -1626,7 +1640,6 @@ Peers_destroy_sending_channel (const struct GNUNET_PeerIdentity *peer) | |||
1626 | * | 1640 | * |
1627 | * @param cls The closure | 1641 | * @param cls The closure |
1628 | * @param channel The channel being closed | 1642 | * @param channel The channel being closed |
1629 | * @param channel_ctx The context associated with this channel | ||
1630 | */ | 1643 | */ |
1631 | void | 1644 | void |
1632 | Peers_cleanup_destroyed_channel (void *cls, | 1645 | Peers_cleanup_destroyed_channel (void *cls, |
@@ -2390,6 +2403,7 @@ send_pull_reply (const struct GNUNET_PeerIdentity *peer_id, | |||
2390 | send_size * sizeof (struct GNUNET_PeerIdentity)); | 2403 | send_size * sizeof (struct GNUNET_PeerIdentity)); |
2391 | 2404 | ||
2392 | Peers_send_message (peer_id, ev, "PULL REPLY"); | 2405 | Peers_send_message (peer_id, ev, "PULL REPLY"); |
2406 | GNUNET_STATISTICS_update(stats, "# pull reply send issued", 1, GNUNET_NO); | ||
2393 | } | 2407 | } |
2394 | 2408 | ||
2395 | 2409 | ||
@@ -2570,6 +2584,8 @@ cleanup_destroyed_channel (void *cls, | |||
2570 | uint32_t *channel_flag; | 2584 | uint32_t *channel_flag; |
2571 | struct PeerContext *peer_ctx; | 2585 | struct PeerContext *peer_ctx; |
2572 | 2586 | ||
2587 | GNUNET_assert (NULL != peer); | ||
2588 | |||
2573 | if (GNUNET_NO == Peers_check_peer_known (peer)) | 2589 | if (GNUNET_NO == Peers_check_peer_known (peer)) |
2574 | { /* We don't know a context to that peer */ | 2590 | { /* We don't know a context to that peer */ |
2575 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2591 | LOG (GNUNET_ERROR_TYPE_WARNING, |
@@ -2961,6 +2977,7 @@ handle_peer_push (void *cls, | |||
2961 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2977 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2962 | "Received PUSH (%s)\n", | 2978 | "Received PUSH (%s)\n", |
2963 | GNUNET_i2s (peer)); | 2979 | GNUNET_i2s (peer)); |
2980 | GNUNET_STATISTICS_update(stats, "# push message received", 1, GNUNET_NO); | ||
2964 | 2981 | ||
2965 | #ifdef ENABLE_MALICIOUS | 2982 | #ifdef ENABLE_MALICIOUS |
2966 | struct AttackedPeer *tmp_att_peer; | 2983 | struct AttackedPeer *tmp_att_peer; |
@@ -3013,6 +3030,7 @@ handle_peer_pull_request (void *cls, | |||
3013 | const struct GNUNET_PeerIdentity *view_array; | 3030 | const struct GNUNET_PeerIdentity *view_array; |
3014 | 3031 | ||
3015 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REQUEST (%s)\n", GNUNET_i2s (peer)); | 3032 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REQUEST (%s)\n", GNUNET_i2s (peer)); |
3033 | GNUNET_STATISTICS_update(stats, "# pull request message received", 1, GNUNET_NO); | ||
3016 | 3034 | ||
3017 | #ifdef ENABLE_MALICIOUS | 3035 | #ifdef ENABLE_MALICIOUS |
3018 | if (1 == mal_type | 3036 | if (1 == mal_type |
@@ -3096,6 +3114,7 @@ handle_peer_pull_reply (void *cls, | |||
3096 | #endif /* ENABLE_MALICIOUS */ | 3114 | #endif /* ENABLE_MALICIOUS */ |
3097 | 3115 | ||
3098 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REPLY (%s)\n", GNUNET_i2s (sender)); | 3116 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REPLY (%s)\n", GNUNET_i2s (sender)); |
3117 | GNUNET_STATISTICS_update(stats, "# pull reply messages received", 1, GNUNET_NO); | ||
3099 | 3118 | ||
3100 | #ifdef ENABLE_MALICIOUS | 3119 | #ifdef ENABLE_MALICIOUS |
3101 | // We shouldn't even receive pull replies as we're not sending | 3120 | // We shouldn't even receive pull replies as we're not sending |
@@ -3234,6 +3253,7 @@ send_pull_request (const struct GNUNET_PeerIdentity *peer) | |||
3234 | 3253 | ||
3235 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST); | 3254 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST); |
3236 | Peers_send_message (peer, ev, "PULL REQUEST"); | 3255 | Peers_send_message (peer, ev, "PULL REQUEST"); |
3256 | GNUNET_STATISTICS_update(stats, "# pull request send issued", 1, GNUNET_NO); | ||
3237 | } | 3257 | } |
3238 | 3258 | ||
3239 | 3259 | ||
@@ -3253,6 +3273,7 @@ send_push (const struct GNUNET_PeerIdentity *peer_id) | |||
3253 | 3273 | ||
3254 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PUSH); | 3274 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PUSH); |
3255 | Peers_send_message (peer_id, ev, "PUSH"); | 3275 | Peers_send_message (peer_id, ev, "PUSH"); |
3276 | GNUNET_STATISTICS_update(stats, "# push send issued", 1, GNUNET_NO); | ||
3256 | } | 3277 | } |
3257 | 3278 | ||
3258 | 3279 | ||
@@ -3554,6 +3575,7 @@ do_round (void *cls) | |||
3554 | 3575 | ||
3555 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 3576 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3556 | "Going to execute next round.\n"); | 3577 | "Going to execute next round.\n"); |
3578 | GNUNET_STATISTICS_update(stats, "# rounds", 1, GNUNET_NO); | ||
3557 | do_round_task = NULL; | 3579 | do_round_task = NULL; |
3558 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 3580 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3559 | "Printing view:\n"); | 3581 | "Printing view:\n"); |
@@ -3702,10 +3724,15 @@ do_round (void *cls) | |||
3702 | } | 3724 | } |
3703 | 3725 | ||
3704 | GNUNET_array_grow (peers_to_clean, peers_to_clean_size, 0); | 3726 | GNUNET_array_grow (peers_to_clean, peers_to_clean_size, 0); |
3705 | } | 3727 | } else { |
3706 | else | ||
3707 | { | ||
3708 | LOG (GNUNET_ERROR_TYPE_DEBUG, "No update of the view.\n"); | 3728 | LOG (GNUNET_ERROR_TYPE_DEBUG, "No update of the view.\n"); |
3729 | GNUNET_STATISTICS_update(stats, "# rounds blocked", 1, GNUNET_NO); | ||
3730 | if (CustomPeerMap_size (push_map) > alpha * View_size ()) | ||
3731 | GNUNET_STATISTICS_update(stats, "# rounds blocked - too many pushes", 1, GNUNET_NO); | ||
3732 | if (0 >= CustomPeerMap_size (push_map)) | ||
3733 | GNUNET_STATISTICS_update(stats, "# rounds blocked - no pushes", 1, GNUNET_NO); | ||
3734 | if (0 >= CustomPeerMap_size (pull_map)) | ||
3735 | GNUNET_STATISTICS_update(stats, "# rounds blocked - no pull replies", 1, GNUNET_NO); | ||
3709 | } | 3736 | } |
3710 | // TODO independent of that also get some peers from CADET_get_peers()? | 3737 | // TODO independent of that also get some peers from CADET_get_peers()? |
3711 | 3738 | ||
@@ -3881,6 +3908,11 @@ shutdown_task (void *cls) | |||
3881 | View_destroy (); | 3908 | View_destroy (); |
3882 | CustomPeerMap_destroy (push_map); | 3909 | CustomPeerMap_destroy (push_map); |
3883 | CustomPeerMap_destroy (pull_map); | 3910 | CustomPeerMap_destroy (pull_map); |
3911 | if (NULL != stats) | ||
3912 | { | ||
3913 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | ||
3914 | stats = NULL; | ||
3915 | } | ||
3884 | #ifdef ENABLE_MALICIOUS | 3916 | #ifdef ENABLE_MALICIOUS |
3885 | struct AttackedPeer *tmp_att_peer; | 3917 | struct AttackedPeer *tmp_att_peer; |
3886 | GNUNET_free (file_name_view_log); | 3918 | GNUNET_free (file_name_view_log); |
@@ -4129,6 +4161,8 @@ run (void *cls, | |||
4129 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); | 4161 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); |
4130 | 4162 | ||
4131 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 4163 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
4164 | stats = GNUNET_STATISTICS_create ("rps", cfg); | ||
4165 | |||
4132 | } | 4166 | } |
4133 | 4167 | ||
4134 | 4168 | ||
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 6189557f6..c5a2c0458 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -236,6 +236,48 @@ struct RPSPeer | |||
236 | * Pending operation on that peer | 236 | * Pending operation on that peer |
237 | */ | 237 | */ |
238 | const struct OpListEntry *entry_op_manage; | 238 | const struct OpListEntry *entry_op_manage; |
239 | |||
240 | /** | ||
241 | * Testbed operation to connect to statistics service | ||
242 | */ | ||
243 | struct GNUNET_TESTBED_Operation *stat_op; | ||
244 | |||
245 | /** | ||
246 | * Handle to the statistics service | ||
247 | */ | ||
248 | struct GNUNET_STATISTICS_Handle *stats_h; | ||
249 | |||
250 | /** | ||
251 | * @brief flags to indicate which statistics values have been already | ||
252 | * collected from the statistics service. | ||
253 | * Used to check whether we are able to shutdown. | ||
254 | */ | ||
255 | uint32_t stat_collected_flags; | ||
256 | }; | ||
257 | |||
258 | enum STAT_TYPE | ||
259 | { | ||
260 | STAT_TYPE_ROUNDS = 0x1, /* 1 */ | ||
261 | STAT_TYPE_BLOCKS = 0x2, /* 2 */ | ||
262 | STAT_TYPE_BLOCKS_MANY_PUSH = 0x4, /* 3 */ | ||
263 | STAT_TYPE_BLOCKS_FEW_PUSH = 0x8, /* 4 */ | ||
264 | STAT_TYPE_BLOCKS_FEW_PULL = 0x10, /* 5 */ | ||
265 | STAT_TYPE_ISSUED_PUSH_SEND = 0x20, /* 6 */ | ||
266 | STAT_TYPE_ISSUED_PULL_REQ = 0x40, /* 7 */ | ||
267 | STAT_TYPE_ISSUED_PULL_REP = 0x80, /* 8 */ | ||
268 | STAT_TYPE_SENT_PUSH_SEND = 0x100, /* 9 */ | ||
269 | STAT_TYPE_SENT_PULL_REQ = 0x200, /* 10 */ | ||
270 | STAT_TYPE_SENT_PULL_REP = 0x400, /* 11 */ | ||
271 | STAT_TYPE_RECV_PUSH_SEND = 0x800, /* 12 */ | ||
272 | STAT_TYPE_RECV_PULL_REQ = 0x1000, /* 13 */ | ||
273 | STAT_TYPE_RECV_PULL_REP = 0x2000, /* 14 */ | ||
274 | STAT_TYPE_MAX = 0x80000000, /* 32 */ | ||
275 | }; | ||
276 | |||
277 | struct STATcls | ||
278 | { | ||
279 | struct RPSPeer *rps_peer; | ||
280 | enum STAT_TYPE stat_type; | ||
239 | }; | 281 | }; |
240 | 282 | ||
241 | 283 | ||
@@ -318,7 +360,7 @@ typedef void (*ReplyHandle) (void *cls, | |||
318 | /** | 360 | /** |
319 | * Called directly before disconnecting from the service | 361 | * Called directly before disconnecting from the service |
320 | */ | 362 | */ |
321 | typedef void (*PostTest) (void *cls, struct GNUNET_RPS_Handle *h); | 363 | typedef void (*PostTest) (struct RPSPeer *peer); |
322 | 364 | ||
323 | /** | 365 | /** |
324 | * Function called after disconnect to evaluate test success | 366 | * Function called after disconnect to evaluate test success |
@@ -355,6 +397,21 @@ enum OPTION_QUICK_QUIT { | |||
355 | }; | 397 | }; |
356 | 398 | ||
357 | /** | 399 | /** |
400 | * @brief Do we collect statistics at the end? | ||
401 | */ | ||
402 | enum OPTION_COLLECT_STATISTICS { | ||
403 | /** | ||
404 | * @brief We collect statistics at the end | ||
405 | */ | ||
406 | COLLECT_STATISTICS, | ||
407 | |||
408 | /** | ||
409 | * @brief We do not collect statistics at the end | ||
410 | */ | ||
411 | NO_COLLECT_STATISTICS, | ||
412 | }; | ||
413 | |||
414 | /** | ||
358 | * Structure to define a single test | 415 | * Structure to define a single test |
359 | */ | 416 | */ |
360 | struct SingleTestRun | 417 | struct SingleTestRun |
@@ -413,6 +470,17 @@ struct SingleTestRun | |||
413 | * Quit test before timeout? | 470 | * Quit test before timeout? |
414 | */ | 471 | */ |
415 | enum OPTION_QUICK_QUIT have_quick_quit; | 472 | enum OPTION_QUICK_QUIT have_quick_quit; |
473 | |||
474 | /** | ||
475 | * Collect statistics at the end? | ||
476 | */ | ||
477 | enum OPTION_COLLECT_STATISTICS have_collect_statistics; | ||
478 | |||
479 | /** | ||
480 | * @brief Mark which values from the statistics service to collect at the end | ||
481 | * of the run | ||
482 | */ | ||
483 | uint32_t stat_collect_flags; | ||
416 | } cur_test_run; | 484 | } cur_test_run; |
417 | 485 | ||
418 | /** | 486 | /** |
@@ -559,6 +627,52 @@ make_oplist_entry () | |||
559 | 627 | ||
560 | 628 | ||
561 | /** | 629 | /** |
630 | * @brief Checks if given peer already received its statistics value from the | ||
631 | * statistics service. | ||
632 | * | ||
633 | * @param rps_peer the peer to check for | ||
634 | * | ||
635 | * @return #GNUNET_YES if so | ||
636 | * #GNUNET_NO otherwise | ||
637 | */ | ||
638 | static int check_statistics_collect_completed_single_peer ( | ||
639 | const struct RPSPeer *rps_peer) | ||
640 | { | ||
641 | if (cur_test_run.stat_collect_flags != | ||
642 | (cur_test_run.stat_collect_flags & | ||
643 | rps_peer->stat_collected_flags)) | ||
644 | { | ||
645 | return GNUNET_NO; | ||
646 | } | ||
647 | return GNUNET_YES; | ||
648 | } | ||
649 | /** | ||
650 | * @brief Checks if all peers already received their statistics value from the | ||
651 | * statistics service. | ||
652 | * | ||
653 | * @return #GNUNET_YES if so | ||
654 | * #GNUNET_NO otherwise | ||
655 | */ | ||
656 | static int check_statistics_collect_completed () | ||
657 | { | ||
658 | uint32_t i; | ||
659 | |||
660 | for (i = 0; i < num_peers; i++) | ||
661 | { | ||
662 | if (GNUNET_NO == check_statistics_collect_completed_single_peer (&rps_peers[i])) | ||
663 | { | ||
664 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
665 | "At least Peer %" PRIu32 " did not yet receive all statistics values\n", | ||
666 | i); | ||
667 | return GNUNET_NO; | ||
668 | } | ||
669 | } | ||
670 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
671 | "All peers received their statistics values\n"); | ||
672 | return GNUNET_YES; | ||
673 | } | ||
674 | |||
675 | /** | ||
562 | * Task run on timeout to shut everything down. | 676 | * Task run on timeout to shut everything down. |
563 | */ | 677 | */ |
564 | static void | 678 | static void |
@@ -575,9 +689,21 @@ shutdown_op (void *cls) | |||
575 | churn_task = NULL; | 689 | churn_task = NULL; |
576 | } | 690 | } |
577 | for (i = 0; i < num_peers; i++) | 691 | for (i = 0; i < num_peers; i++) |
692 | { | ||
578 | if (NULL != rps_peers[i].op) | 693 | if (NULL != rps_peers[i].op) |
579 | GNUNET_TESTBED_operation_done (rps_peers[i].op); | 694 | GNUNET_TESTBED_operation_done (rps_peers[i].op); |
580 | GNUNET_SCHEDULER_shutdown (); | 695 | if (NULL != cur_test_run.post_test) |
696 | { | ||
697 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing post_test for peer %u\n", i); | ||
698 | cur_test_run.post_test (&rps_peers[i]); | ||
699 | } | ||
700 | } | ||
701 | /* If we do not collect statistics, shut down directly */ | ||
702 | if (NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics || | ||
703 | GNUNET_YES == check_statistics_collect_completed()) | ||
704 | { | ||
705 | GNUNET_SCHEDULER_shutdown (); | ||
706 | } | ||
581 | } | 707 | } |
582 | 708 | ||
583 | 709 | ||
@@ -753,6 +879,76 @@ rps_connect_adapter (void *cls, | |||
753 | return h; | 879 | return h; |
754 | } | 880 | } |
755 | 881 | ||
882 | /** | ||
883 | * Called to open a connection to the peer's statistics | ||
884 | * | ||
885 | * @param cls peer context | ||
886 | * @param cfg configuration of the peer to connect to; will be available until | ||
887 | * GNUNET_TESTBED_operation_done() is called on the operation returned | ||
888 | * from GNUNET_TESTBED_service_connect() | ||
889 | * @return service handle to return in 'op_result', NULL on error | ||
890 | */ | ||
891 | static void * | ||
892 | stat_connect_adapter (void *cls, | ||
893 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
894 | { | ||
895 | struct RPSPeer *peer = cls; | ||
896 | |||
897 | peer->stats_h = GNUNET_STATISTICS_create ("rps-profiler", cfg); | ||
898 | return peer->stats_h; | ||
899 | } | ||
900 | |||
901 | /** | ||
902 | * Called to disconnect from peer's statistics service | ||
903 | * | ||
904 | * @param cls peer context | ||
905 | * @param op_result service handle returned from the connect adapter | ||
906 | */ | ||
907 | static void | ||
908 | stat_disconnect_adapter (void *cls, void *op_result) | ||
909 | { | ||
910 | struct RPSPeer *peer = cls; | ||
911 | |||
912 | //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel | ||
913 | // (peer->stats_h, "core", "# peers connected", | ||
914 | // stat_iterator, peer)); | ||
915 | //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel | ||
916 | // (peer->stats_h, "nse", "# peers connected", | ||
917 | // stat_iterator, peer)); | ||
918 | GNUNET_STATISTICS_destroy (op_result, GNUNET_NO); | ||
919 | peer->stats_h = NULL; | ||
920 | } | ||
921 | |||
922 | /** | ||
923 | * Called after successfully opening a connection to a peer's statistics | ||
924 | * service; we register statistics monitoring for CORE and NSE here. | ||
925 | * | ||
926 | * @param cls the callback closure from functions generating an operation | ||
927 | * @param op the operation that has been finished | ||
928 | * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter() | ||
929 | * @param emsg error message in case the operation has failed; will be NULL if | ||
930 | * operation has executed successfully. | ||
931 | */ | ||
932 | static void | ||
933 | stat_complete_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | ||
934 | void *ca_result, const char *emsg ) | ||
935 | { | ||
936 | //struct GNUNET_STATISTICS_Handle *sh = ca_result; | ||
937 | //struct RPSPeer *peer = (struct RPSPeer *) cls; | ||
938 | |||
939 | if (NULL != emsg) | ||
940 | { | ||
941 | GNUNET_break (0); | ||
942 | return; | ||
943 | } | ||
944 | //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch | ||
945 | // (sh, "core", "# peers connected", | ||
946 | // stat_iterator, peer)); | ||
947 | //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch | ||
948 | // (sh, "nse", "# peers connected", | ||
949 | // stat_iterator, peer)); | ||
950 | } | ||
951 | |||
756 | 952 | ||
757 | /** | 953 | /** |
758 | * Adapter function called to destroy connection to | 954 | * Adapter function called to destroy connection to |
@@ -1296,7 +1492,7 @@ manage_service_wrapper (unsigned int i, unsigned int j, | |||
1296 | enum PEER_ONLINE_DELTA delta, | 1492 | enum PEER_ONLINE_DELTA delta, |
1297 | double prob_go_on_off) | 1493 | double prob_go_on_off) |
1298 | { | 1494 | { |
1299 | struct OpListEntry *entry; | 1495 | struct OpListEntry *entry = NULL; |
1300 | uint32_t prob; | 1496 | uint32_t prob; |
1301 | 1497 | ||
1302 | /* make sure that management operation is not already scheduled */ | 1498 | /* make sure that management operation is not already scheduled */ |
@@ -1541,6 +1737,159 @@ profiler_eval (void) | |||
1541 | return evaluate (); | 1737 | return evaluate (); |
1542 | } | 1738 | } |
1543 | 1739 | ||
1740 | /** | ||
1741 | * Continuation called by #GNUNET_STATISTICS_get() functions. | ||
1742 | * | ||
1743 | * Remembers that this specific statistics value was received for this peer. | ||
1744 | * Checks whether all peers received their statistics yet. | ||
1745 | * Issues the shutdown. | ||
1746 | * | ||
1747 | * @param cls closure | ||
1748 | * @param success #GNUNET_OK if statistics were | ||
1749 | * successfully obtained, #GNUNET_SYSERR if not. | ||
1750 | */ | ||
1751 | void | ||
1752 | post_test_shutdown_ready_cb (void *cls, | ||
1753 | int success) | ||
1754 | { | ||
1755 | struct STATcls *stat_cls = (struct STATcls *) cls; | ||
1756 | struct RPSPeer *rps_peer = stat_cls->rps_peer; | ||
1757 | if (GNUNET_OK == success) | ||
1758 | { | ||
1759 | /* set flag that we we got the value */ | ||
1760 | rps_peer->stat_collected_flags |= stat_cls->stat_type; | ||
1761 | } else { | ||
1762 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1763 | "Peer %u did not receive statistics value\n", | ||
1764 | rps_peer->index); | ||
1765 | GNUNET_free (stat_cls); | ||
1766 | GNUNET_break (0); | ||
1767 | } | ||
1768 | |||
1769 | if (NULL != rps_peer->stat_op && | ||
1770 | GNUNET_YES == check_statistics_collect_completed_single_peer (rps_peer)) | ||
1771 | { | ||
1772 | GNUNET_TESTBED_operation_done (rps_peer->stat_op); | ||
1773 | } | ||
1774 | |||
1775 | if (GNUNET_YES == check_statistics_collect_completed()) | ||
1776 | { | ||
1777 | GNUNET_free (stat_cls); | ||
1778 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1779 | "Shutting down\n"); | ||
1780 | GNUNET_SCHEDULER_shutdown (); | ||
1781 | } else { | ||
1782 | GNUNET_free (stat_cls); | ||
1783 | } | ||
1784 | } | ||
1785 | |||
1786 | /** | ||
1787 | * @brief Converts #STAT_TYPE enum to the equivalent string representation that | ||
1788 | * is stored with the statistics service. | ||
1789 | * | ||
1790 | * @param stat_type #STAT_TYPE enum | ||
1791 | * | ||
1792 | * @return string representation that matches statistics value | ||
1793 | */ | ||
1794 | char* stat_type_2_str (enum STAT_TYPE stat_type) | ||
1795 | { | ||
1796 | switch (stat_type) | ||
1797 | { | ||
1798 | case STAT_TYPE_ROUNDS: | ||
1799 | return "# rounds"; | ||
1800 | case STAT_TYPE_BLOCKS: | ||
1801 | return "# rounds blocked"; | ||
1802 | case STAT_TYPE_BLOCKS_MANY_PUSH: | ||
1803 | return "# rounds blocked - too many pushes"; | ||
1804 | case STAT_TYPE_BLOCKS_FEW_PUSH: | ||
1805 | return "# rounds blocked - no pushes"; | ||
1806 | case STAT_TYPE_BLOCKS_FEW_PULL: | ||
1807 | return "# rounds blocked - no pull replies"; | ||
1808 | case STAT_TYPE_ISSUED_PUSH_SEND: | ||
1809 | return "# push send issued"; | ||
1810 | case STAT_TYPE_ISSUED_PULL_REQ: | ||
1811 | return "# pull request send issued"; | ||
1812 | case STAT_TYPE_ISSUED_PULL_REP: | ||
1813 | return "# pull reply send issued"; | ||
1814 | case STAT_TYPE_SENT_PUSH_SEND: | ||
1815 | return "# pushes sent"; | ||
1816 | case STAT_TYPE_SENT_PULL_REQ: | ||
1817 | return "# pull requests sent"; | ||
1818 | case STAT_TYPE_SENT_PULL_REP: | ||
1819 | return "# pull replys sent"; | ||
1820 | case STAT_TYPE_RECV_PUSH_SEND: | ||
1821 | return "# push message received"; | ||
1822 | case STAT_TYPE_RECV_PULL_REQ: | ||
1823 | return "# pull request message received"; | ||
1824 | case STAT_TYPE_RECV_PULL_REP: | ||
1825 | return "# pull reply messages received"; | ||
1826 | case STAT_TYPE_MAX: | ||
1827 | default: | ||
1828 | return "ERROR"; | ||
1829 | ; | ||
1830 | } | ||
1831 | } | ||
1832 | |||
1833 | /** | ||
1834 | * Callback function to process statistic values. | ||
1835 | * | ||
1836 | * @param cls closure | ||
1837 | * @param subsystem name of subsystem that created the statistic | ||
1838 | * @param name the name of the datum | ||
1839 | * @param value the current value | ||
1840 | * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not | ||
1841 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration | ||
1842 | */ | ||
1843 | int | ||
1844 | stat_iterator (void *cls, | ||
1845 | const char *subsystem, | ||
1846 | const char *name, | ||
1847 | uint64_t value, | ||
1848 | int is_persistent) | ||
1849 | { | ||
1850 | const struct STATcls *stat_cls = (const struct STATcls *) cls; | ||
1851 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n", | ||
1852 | stat_type_2_str (stat_cls->stat_type), | ||
1853 | value); | ||
1854 | return GNUNET_OK; | ||
1855 | } | ||
1856 | |||
1857 | void post_profiler (struct RPSPeer *rps_peer) | ||
1858 | { | ||
1859 | if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics) | ||
1860 | { | ||
1861 | return; | ||
1862 | } | ||
1863 | |||
1864 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1865 | "Going to request statistic values with mask 0x%" PRIx32 "\n", | ||
1866 | cur_test_run.stat_collect_flags); | ||
1867 | |||
1868 | struct STATcls *stat_cls; | ||
1869 | uint32_t stat_type; | ||
1870 | for (stat_type = STAT_TYPE_ROUNDS; | ||
1871 | stat_type < STAT_TYPE_MAX; | ||
1872 | stat_type = stat_type <<1) | ||
1873 | { | ||
1874 | if (stat_type & cur_test_run.stat_collect_flags) | ||
1875 | { | ||
1876 | stat_cls = GNUNET_malloc (sizeof (struct STATcls)); | ||
1877 | stat_cls->rps_peer = rps_peer; | ||
1878 | stat_cls->stat_type = stat_type; | ||
1879 | GNUNET_STATISTICS_get (rps_peer->stats_h, | ||
1880 | "rps", | ||
1881 | stat_type_2_str (stat_type), | ||
1882 | post_test_shutdown_ready_cb, | ||
1883 | stat_iterator, | ||
1884 | (struct STATcls *) stat_cls); | ||
1885 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1886 | "Requested statistics for %s (peer %" PRIu32 ")\n", | ||
1887 | stat_type_2_str (stat_type), | ||
1888 | rps_peer->index); | ||
1889 | } | ||
1890 | } | ||
1891 | } | ||
1892 | |||
1544 | 1893 | ||
1545 | /*********************************************************************** | 1894 | /*********************************************************************** |
1546 | * /Definition of tests | 1895 | * /Definition of tests |
@@ -1623,6 +1972,19 @@ run (void *cls, | |||
1623 | &rps_disconnect_adapter, | 1972 | &rps_disconnect_adapter, |
1624 | &rps_peers[i]); | 1973 | &rps_peers[i]); |
1625 | } | 1974 | } |
1975 | /* Connect all peers to statistics service */ | ||
1976 | if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics) | ||
1977 | { | ||
1978 | rps_peers[i].stat_op = | ||
1979 | GNUNET_TESTBED_service_connect (NULL, | ||
1980 | peers[i], | ||
1981 | "statistics", | ||
1982 | stat_complete_cb, | ||
1983 | &rps_peers[i], | ||
1984 | &stat_connect_adapter, | ||
1985 | &stat_disconnect_adapter, | ||
1986 | &rps_peers[i]); | ||
1987 | } | ||
1626 | } | 1988 | } |
1627 | 1989 | ||
1628 | if (NULL != churn_task) | 1990 | if (NULL != churn_task) |
@@ -1649,7 +2011,10 @@ main (int argc, char *argv[]) | |||
1649 | cur_test_run.pre_test = NULL; | 2011 | cur_test_run.pre_test = NULL; |
1650 | cur_test_run.reply_handle = default_reply_handle; | 2012 | cur_test_run.reply_handle = default_reply_handle; |
1651 | cur_test_run.eval_cb = default_eval_cb; | 2013 | cur_test_run.eval_cb = default_eval_cb; |
2014 | cur_test_run.post_test = NULL; | ||
1652 | cur_test_run.have_churn = HAVE_CHURN; | 2015 | cur_test_run.have_churn = HAVE_CHURN; |
2016 | cur_test_run.have_collect_statistics = NO_COLLECT_STATISTICS; | ||
2017 | cur_test_run.stat_collect_flags = 0; | ||
1653 | churn_task = NULL; | 2018 | churn_task = NULL; |
1654 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); | 2019 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); |
1655 | 2020 | ||
@@ -1767,10 +2132,26 @@ main (int argc, char *argv[]) | |||
1767 | cur_test_run.main_test = profiler_cb; | 2132 | cur_test_run.main_test = profiler_cb; |
1768 | cur_test_run.reply_handle = profiler_reply_handle; | 2133 | cur_test_run.reply_handle = profiler_reply_handle; |
1769 | cur_test_run.eval_cb = profiler_eval; | 2134 | cur_test_run.eval_cb = profiler_eval; |
2135 | cur_test_run.post_test = post_profiler; | ||
1770 | cur_test_run.request_interval = 2; | 2136 | cur_test_run.request_interval = 2; |
1771 | cur_test_run.num_requests = 5; | 2137 | cur_test_run.num_requests = 5; |
1772 | cur_test_run.have_churn = HAVE_CHURN; | 2138 | cur_test_run.have_churn = HAVE_CHURN; |
1773 | cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT; | 2139 | cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT; |
2140 | cur_test_run.have_collect_statistics = COLLECT_STATISTICS; | ||
2141 | cur_test_run.stat_collect_flags = STAT_TYPE_ROUNDS | | ||
2142 | STAT_TYPE_BLOCKS | | ||
2143 | STAT_TYPE_BLOCKS_MANY_PUSH | | ||
2144 | STAT_TYPE_BLOCKS_FEW_PUSH | | ||
2145 | STAT_TYPE_BLOCKS_FEW_PULL | | ||
2146 | STAT_TYPE_ISSUED_PUSH_SEND | | ||
2147 | STAT_TYPE_ISSUED_PULL_REQ | | ||
2148 | STAT_TYPE_ISSUED_PULL_REP | | ||
2149 | STAT_TYPE_SENT_PUSH_SEND | | ||
2150 | STAT_TYPE_SENT_PULL_REQ | | ||
2151 | STAT_TYPE_SENT_PULL_REP | | ||
2152 | STAT_TYPE_RECV_PUSH_SEND | | ||
2153 | STAT_TYPE_RECV_PULL_REQ | | ||
2154 | STAT_TYPE_RECV_PULL_REP; | ||
1774 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300); | 2155 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300); |
1775 | 2156 | ||
1776 | /* 'Clean' directory */ | 2157 | /* 'Clean' directory */ |
diff --git a/src/topology/friends.c b/src/topology/friends.c index 65f2700bb..cdfedbc81 100644 --- a/src/topology/friends.c +++ b/src/topology/friends.c | |||
@@ -46,6 +46,7 @@ GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
46 | size_t start; | 46 | size_t start; |
47 | struct GNUNET_PeerIdentity pid; | 47 | struct GNUNET_PeerIdentity pid; |
48 | uint64_t fsize; | 48 | uint64_t fsize; |
49 | ssize_t ssize; | ||
49 | 50 | ||
50 | if (GNUNET_OK != | 51 | if (GNUNET_OK != |
51 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 52 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
@@ -57,13 +58,24 @@ GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
57 | "topology", "FRIENDS"); | 58 | "topology", "FRIENDS"); |
58 | return GNUNET_SYSERR; | 59 | return GNUNET_SYSERR; |
59 | } | 60 | } |
60 | if ( (GNUNET_OK != GNUNET_DISK_file_test (fn)) && | 61 | if (GNUNET_SYSERR == |
61 | (GNUNET_OK != GNUNET_DISK_fn_write (fn, | 62 | GNUNET_DISK_directory_create_for_file (fn)) |
62 | NULL, | 63 | { |
63 | 0, | 64 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
64 | GNUNET_DISK_PERM_USER_READ | | 65 | "mkdir", |
65 | GNUNET_DISK_PERM_USER_WRITE | | 66 | fn); |
66 | GNUNET_DISK_OPEN_CREATE)) ) | 67 | GNUNET_free (fn); |
68 | return GNUNET_SYSERR; | ||
69 | } | ||
70 | if ( (GNUNET_OK != | ||
71 | GNUNET_DISK_file_test (fn)) && | ||
72 | (GNUNET_OK != | ||
73 | GNUNET_DISK_fn_write (fn, | ||
74 | NULL, | ||
75 | 0, | ||
76 | GNUNET_DISK_PERM_USER_READ | | ||
77 | GNUNET_DISK_PERM_USER_WRITE | | ||
78 | GNUNET_DISK_OPEN_CREATE)) ) | ||
67 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | 79 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
68 | "write", | 80 | "write", |
69 | fn); | 81 | fn); |
@@ -84,9 +96,15 @@ GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
84 | GNUNET_free (fn); | 96 | GNUNET_free (fn); |
85 | return GNUNET_SYSERR; | 97 | return GNUNET_SYSERR; |
86 | } | 98 | } |
87 | if (fsize != GNUNET_DISK_fn_read (fn, data, fsize)) | 99 | ssize = GNUNET_DISK_fn_read (fn, |
100 | data, | ||
101 | fsize); | ||
102 | if ( (ssize < 0) || | ||
103 | (fsize != (uint64_t) ssize) ) | ||
88 | { | 104 | { |
89 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "read", "fn"); | 105 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
106 | "read", | ||
107 | "fn"); | ||
90 | GNUNET_free (fn); | 108 | GNUNET_free (fn); |
91 | GNUNET_free (data); | 109 | GNUNET_free (data); |
92 | return GNUNET_SYSERR; | 110 | return GNUNET_SYSERR; |
@@ -95,7 +113,8 @@ GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
95 | pos = 0; | 113 | pos = 0; |
96 | while (pos < fsize) | 114 | while (pos < fsize) |
97 | { | 115 | { |
98 | while ((pos < fsize) && (! isspace ((unsigned char) data[pos]))) | 116 | while ( (pos < fsize) && |
117 | (! isspace ((unsigned char) data[pos])) ) | ||
99 | pos++; | 118 | pos++; |
100 | if (GNUNET_OK != | 119 | if (GNUNET_OK != |
101 | GNUNET_CRYPTO_eddsa_public_key_from_string (&data[start], | 120 | GNUNET_CRYPTO_eddsa_public_key_from_string (&data[start], |
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 2bf07bcd7..e124f1667 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -1407,6 +1407,14 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) | |||
1407 | } | 1407 | } |
1408 | if (NULL == mq) | 1408 | if (NULL == mq) |
1409 | return; /* no more messages */ | 1409 | return; /* no more messages */ |
1410 | if (NULL == n->primary_address.address) | ||
1411 | { | ||
1412 | /* transmit_send_continuation() caused us to drop session, | ||
1413 | can't try transmission anymore. */ | ||
1414 | return; | ||
1415 | } | ||
1416 | |||
1417 | |||
1410 | GNUNET_CONTAINER_DLL_remove (n->messages_head, | 1418 | GNUNET_CONTAINER_DLL_remove (n->messages_head, |
1411 | n->messages_tail, | 1419 | n->messages_tail, |
1412 | mq); | 1420 | mq); |
@@ -2137,6 +2145,8 @@ inbound_bw_tracker_update (void *cls) | |||
2137 | "New inbound delay for peer `%s' is %llu ms\n", | 2145 | "New inbound delay for peer `%s' is %llu ms\n", |
2138 | GNUNET_i2s (&n->id), | 2146 | GNUNET_i2s (&n->id), |
2139 | (unsigned long long) delay.rel_value_us / 1000LL); | 2147 | (unsigned long long) delay.rel_value_us / 1000LL); |
2148 | if (NULL == n->primary_address.session) | ||
2149 | return; | ||
2140 | papi->update_inbound_delay (papi->cls, | 2150 | papi->update_inbound_delay (papi->cls, |
2141 | &n->id, | 2151 | &n->id, |
2142 | n->primary_address.session, | 2152 | n->primary_address.session, |
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 211e64e32..3ea5706d1 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -68,12 +68,12 @@ report () | |||
68 | 68 | ||
69 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; | 69 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; |
70 | datarate = (total_bytes_recv * 1000 * 1000) / delta; | 70 | datarate = (total_bytes_recv * 1000 * 1000) / delta; |
71 | 71 | ||
72 | FPRINTF (stderr, | 72 | FPRINTF (stderr, |
73 | "Throughput was %llu b/s\n", | 73 | "Throughput was %llu b/s\n", |
74 | datarate); | 74 | datarate); |
75 | ccc->global_ret = GNUNET_OK; | 75 | ccc->global_ret = GNUNET_OK; |
76 | if (datarate > 1.1 * quota_in[1]) | 76 | if (datarate > 1.5 * quota_in[1]) |
77 | { | 77 | { |
78 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 78 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
79 | "Datarate of %llu b/s significantly higher than allowed inbound quota of %llu b/s\n", | 79 | "Datarate of %llu b/s significantly higher than allowed inbound quota of %llu b/s\n", |
@@ -81,7 +81,7 @@ report () | |||
81 | quota_in[1]); | 81 | quota_in[1]); |
82 | ccc->global_ret = GNUNET_SYSERR; | 82 | ccc->global_ret = GNUNET_SYSERR; |
83 | } | 83 | } |
84 | if (datarate > 1.1 * quota_out[0]) | 84 | if (datarate > 1.5 * quota_out[0]) |
85 | { | 85 | { |
86 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 86 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
87 | "Datarate of %llu b/s significantly higher than allowed outbound quota of %llu b/s\n", | 87 | "Datarate of %llu b/s significantly higher than allowed outbound quota of %llu b/s\n", |
diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c index 95c05b9d7..db61c5221 100644 --- a/src/util/container_bloomfilter.c +++ b/src/util/container_bloomfilter.c | |||
@@ -660,7 +660,7 @@ GNUNET_CONTAINER_bloomfilter_init (const char *data, size_t size, | |||
660 | * @param bf bloomfilter to take the raw data from | 660 | * @param bf bloomfilter to take the raw data from |
661 | * @param data where to write the data | 661 | * @param data where to write the data |
662 | * @param size the size of the given data array | 662 | * @param size the size of the given data array |
663 | * @return GNUNET_SYSERR if the data array is not big enough | 663 | * @return #GNUNET_SYSERR if the data array is not big enough |
664 | */ | 664 | */ |
665 | int | 665 | int |
666 | GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct | 666 | GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct |
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 279a4ed02..6cf5e1168 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -135,18 +135,6 @@ struct GNUNET_SCHEDULER_Task | |||
135 | unsigned int fds_len; | 135 | unsigned int fds_len; |
136 | 136 | ||
137 | /** | 137 | /** |
138 | * if this task is related to multiple FDs this array contains | ||
139 | * all FdInfo structs that were marked as ready by calling | ||
140 | * #GNUNET_SCHEDULER_task_ready | ||
141 | */ | ||
142 | struct GNUNET_SCHEDULER_FdInfo *ready_fds; | ||
143 | |||
144 | /** | ||
145 | * Size of the @e ready_fds array | ||
146 | */ | ||
147 | unsigned int ready_fds_len; | ||
148 | |||
149 | /** | ||
150 | * Do we own the network and file handles referenced by the FdInfo | 138 | * Do we own the network and file handles referenced by the FdInfo |
151 | * structs in the fds array. This will only be GNUNET_YES if the | 139 | * structs in the fds array. This will only be GNUNET_YES if the |
152 | * task was created by the #GNUNET_SCHEDULER_add_select function. | 140 | * task was created by the #GNUNET_SCHEDULER_add_select function. |
@@ -342,14 +330,22 @@ static struct GNUNET_SCHEDULER_Task *ready_head[GNUNET_SCHEDULER_PRIORITY_COUNT] | |||
342 | static struct GNUNET_SCHEDULER_Task *ready_tail[GNUNET_SCHEDULER_PRIORITY_COUNT]; | 330 | static struct GNUNET_SCHEDULER_Task *ready_tail[GNUNET_SCHEDULER_PRIORITY_COUNT]; |
343 | 331 | ||
344 | /** | 332 | /** |
345 | * Number of tasks on the ready list. | 333 | * Task for installing parent control handlers (it might happen that the |
334 | * scheduler is shutdown before this task is executed, so | ||
335 | * GNUNET_SCHEDULER_shutdown must cancel it in that case) | ||
346 | */ | 336 | */ |
347 | static unsigned int ready_count; | 337 | static struct GNUNET_SCHEDULER_Task *install_parent_control_task; |
338 | |||
339 | /** | ||
340 | * Task for reading from a pipe that signal handlers will use to initiate | ||
341 | * shutdown | ||
342 | */ | ||
343 | static struct GNUNET_SCHEDULER_Task *shutdown_pipe_task; | ||
348 | 344 | ||
349 | /** | 345 | /** |
350 | * How many tasks have we run so far? | 346 | * Number of tasks on the ready list. |
351 | */ | 347 | */ |
352 | static unsigned long long tasks_run; | 348 | static unsigned int ready_count; |
353 | 349 | ||
354 | /** | 350 | /** |
355 | * Priority of the task running right now. Only | 351 | * Priority of the task running right now. Only |
@@ -441,7 +437,7 @@ get_timeout () | |||
441 | { | 437 | { |
442 | if (0 != pos->reason) | 438 | if (0 != pos->reason) |
443 | { | 439 | { |
444 | timeout = now; | 440 | return now; |
445 | } | 441 | } |
446 | else | 442 | else |
447 | { | 443 | { |
@@ -452,7 +448,7 @@ get_timeout () | |||
452 | { | 448 | { |
453 | if (0 != pos->reason) | 449 | if (0 != pos->reason) |
454 | { | 450 | { |
455 | timeout = now; | 451 | return now; |
456 | } | 452 | } |
457 | else if ((pos->timeout.abs_value_us != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) && | 453 | else if ((pos->timeout.abs_value_us != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) && |
458 | (timeout.abs_value_us > pos->timeout.abs_value_us)) | 454 | (timeout.abs_value_us > pos->timeout.abs_value_us)) |
@@ -493,6 +489,18 @@ GNUNET_SCHEDULER_shutdown () | |||
493 | { | 489 | { |
494 | struct GNUNET_SCHEDULER_Task *pos; | 490 | struct GNUNET_SCHEDULER_Task *pos; |
495 | 491 | ||
492 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
493 | "GNUNET_SCHEDULER_shutdown\n"); | ||
494 | if (NULL != install_parent_control_task) | ||
495 | { | ||
496 | GNUNET_SCHEDULER_cancel (install_parent_control_task); | ||
497 | install_parent_control_task = NULL; | ||
498 | } | ||
499 | if (NULL != shutdown_pipe_task) | ||
500 | { | ||
501 | GNUNET_SCHEDULER_cancel (shutdown_pipe_task); | ||
502 | shutdown_pipe_task = NULL; | ||
503 | } | ||
496 | while (NULL != (pos = shutdown_head)) | 504 | while (NULL != (pos = shutdown_head)) |
497 | { | 505 | { |
498 | GNUNET_CONTAINER_DLL_remove (shutdown_head, | 506 | GNUNET_CONTAINER_DLL_remove (shutdown_head, |
@@ -561,10 +569,6 @@ destroy_task (struct GNUNET_SCHEDULER_Task *t) | |||
561 | { | 569 | { |
562 | GNUNET_array_grow (t->fds, t->fds_len, 0); | 570 | GNUNET_array_grow (t->fds, t->fds_len, 0); |
563 | } | 571 | } |
564 | if (t->ready_fds_len > 0) | ||
565 | { | ||
566 | GNUNET_array_grow (t->ready_fds, t->ready_fds_len, 0); | ||
567 | } | ||
568 | #if EXECINFO | 572 | #if EXECINFO |
569 | GNUNET_free (t->backtrace_strings); | 573 | GNUNET_free (t->backtrace_strings); |
570 | #endif | 574 | #endif |
@@ -648,14 +652,7 @@ shutdown_if_no_lifeness () | |||
648 | for (t = pending_timeout_head; NULL != t; t = t->next) | 652 | for (t = pending_timeout_head; NULL != t; t = t->next) |
649 | if (GNUNET_YES == t->lifeness) | 653 | if (GNUNET_YES == t->lifeness) |
650 | return; | 654 | return; |
651 | /* No lifeness! Cancel all pending tasks the driver knows about and shutdown */ | 655 | /* No lifeness! */ |
652 | t = pending_head; | ||
653 | while (NULL != t) | ||
654 | { | ||
655 | struct GNUNET_SCHEDULER_Task *next = t->next; | ||
656 | GNUNET_SCHEDULER_cancel (t); | ||
657 | t = next; | ||
658 | } | ||
659 | GNUNET_SCHEDULER_shutdown (); | 656 | GNUNET_SCHEDULER_shutdown (); |
660 | } | 657 | } |
661 | 658 | ||
@@ -682,12 +679,12 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
682 | struct DriverContext context = {.scheduled_head = NULL, | 679 | struct DriverContext context = {.scheduled_head = NULL, |
683 | .scheduled_tail = NULL, | 680 | .scheduled_tail = NULL, |
684 | .timeout = GNUNET_TIME_UNIT_FOREVER_REL}; | 681 | .timeout = GNUNET_TIME_UNIT_FOREVER_REL}; |
685 | 682 | ||
686 | driver = GNUNET_SCHEDULER_driver_select (); | 683 | driver = GNUNET_SCHEDULER_driver_select (); |
687 | driver->cls = &context; | 684 | driver->cls = &context; |
688 | 685 | ||
689 | GNUNET_SCHEDULER_run_with_driver (driver, task, task_cls); | 686 | GNUNET_SCHEDULER_run_with_driver (driver, task, task_cls); |
690 | 687 | ||
691 | GNUNET_free (driver); | 688 | GNUNET_free (driver); |
692 | } | 689 | } |
693 | 690 | ||
@@ -863,7 +860,7 @@ driver_add_multiple (struct GNUNET_SCHEDULER_Task *t) | |||
863 | success = scheduler_driver->add (scheduler_driver->cls, | 860 | success = scheduler_driver->add (scheduler_driver->cls, |
864 | t, | 861 | t, |
865 | fdi) && success; | 862 | fdi) && success; |
866 | fdi->et = GNUNET_SCHEDULER_ET_NONE; | 863 | fdi->et = GNUNET_SCHEDULER_ET_NONE; |
867 | } | 864 | } |
868 | if (GNUNET_YES != success) | 865 | if (GNUNET_YES != success) |
869 | { | 866 | { |
@@ -874,12 +871,20 @@ driver_add_multiple (struct GNUNET_SCHEDULER_Task *t) | |||
874 | 871 | ||
875 | 872 | ||
876 | static void | 873 | static void |
877 | shutdown_cb (void *cls) | 874 | install_parent_control_handler (void *cls) |
875 | { | ||
876 | install_parent_control_task = NULL; | ||
877 | GNUNET_OS_install_parent_control_handler (NULL); | ||
878 | } | ||
879 | |||
880 | |||
881 | static void | ||
882 | shutdown_pipe_cb (void *cls) | ||
878 | { | 883 | { |
879 | char c; | 884 | char c; |
880 | const struct GNUNET_DISK_FileHandle *pr; | 885 | const struct GNUNET_DISK_FileHandle *pr; |
881 | 886 | ||
882 | (void) cls; | 887 | shutdown_pipe_task = NULL; |
883 | pr = GNUNET_DISK_pipe_handle (shutdown_pipe_handle, | 888 | pr = GNUNET_DISK_pipe_handle (shutdown_pipe_handle, |
884 | GNUNET_DISK_PIPE_END_READ); | 889 | GNUNET_DISK_PIPE_END_READ); |
885 | GNUNET_assert (! GNUNET_DISK_handle_invalid (pr)); | 890 | GNUNET_assert (! GNUNET_DISK_handle_invalid (pr)); |
@@ -1015,7 +1020,7 @@ GNUNET_SCHEDULER_add_with_reason_and_priority (GNUNET_SCHEDULER_TaskCallback tas | |||
1015 | t->start_time = GNUNET_TIME_absolute_get (); | 1020 | t->start_time = GNUNET_TIME_absolute_get (); |
1016 | #endif | 1021 | #endif |
1017 | t->reason = reason; | 1022 | t->reason = reason; |
1018 | t->priority = priority; | 1023 | t->priority = check_priority (priority); |
1019 | t->lifeness = current_lifeness; | 1024 | t->lifeness = current_lifeness; |
1020 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1025 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1021 | "Adding continuation task %p\n", | 1026 | "Adding continuation task %p\n", |
@@ -1057,7 +1062,7 @@ GNUNET_SCHEDULER_add_at_with_priority (struct GNUNET_TIME_Absolute at, | |||
1057 | t->start_time = GNUNET_TIME_absolute_get (); | 1062 | t->start_time = GNUNET_TIME_absolute_get (); |
1058 | #endif | 1063 | #endif |
1059 | t->timeout = at; | 1064 | t->timeout = at; |
1060 | t->priority = priority; | 1065 | t->priority = check_priority (priority); |
1061 | t->lifeness = current_lifeness; | 1066 | t->lifeness = current_lifeness; |
1062 | /* try tail first (optimization in case we are | 1067 | /* try tail first (optimization in case we are |
1063 | * appending to a long list of tasks with timeouts) */ | 1068 | * appending to a long list of tasks with timeouts) */ |
@@ -1116,8 +1121,8 @@ GNUNET_SCHEDULER_add_at_with_priority (struct GNUNET_TIME_Absolute at, | |||
1116 | */ | 1121 | */ |
1117 | struct GNUNET_SCHEDULER_Task * | 1122 | struct GNUNET_SCHEDULER_Task * |
1118 | GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay, | 1123 | GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay, |
1119 | enum GNUNET_SCHEDULER_Priority priority, | 1124 | enum GNUNET_SCHEDULER_Priority priority, |
1120 | GNUNET_SCHEDULER_TaskCallback task, | 1125 | GNUNET_SCHEDULER_TaskCallback task, |
1121 | void *task_cls) | 1126 | void *task_cls) |
1122 | { | 1127 | { |
1123 | return GNUNET_SCHEDULER_add_at_with_priority (GNUNET_TIME_relative_to_absolute (delay), | 1128 | return GNUNET_SCHEDULER_add_at_with_priority (GNUNET_TIME_relative_to_absolute (delay), |
@@ -1860,12 +1865,8 @@ GNUNET_SCHEDULER_task_ready (struct GNUNET_SCHEDULER_Task *task, | |||
1860 | struct GNUNET_SCHEDULER_FdInfo *fdi) | 1865 | struct GNUNET_SCHEDULER_FdInfo *fdi) |
1861 | { | 1866 | { |
1862 | enum GNUNET_SCHEDULER_Reason reason; | 1867 | enum GNUNET_SCHEDULER_Reason reason; |
1863 | struct GNUNET_TIME_Absolute now; | ||
1864 | 1868 | ||
1865 | now = GNUNET_TIME_absolute_get (); | ||
1866 | reason = task->reason; | 1869 | reason = task->reason; |
1867 | if (now.abs_value_us >= task->timeout.abs_value_us) | ||
1868 | reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; | ||
1869 | if ( (0 == (reason & GNUNET_SCHEDULER_REASON_READ_READY)) && | 1870 | if ( (0 == (reason & GNUNET_SCHEDULER_REASON_READ_READY)) && |
1870 | (0 != (GNUNET_SCHEDULER_ET_IN & fdi->et)) ) | 1871 | (0 != (GNUNET_SCHEDULER_ET_IN & fdi->et)) ) |
1871 | reason |= GNUNET_SCHEDULER_REASON_READ_READY; | 1872 | reason |= GNUNET_SCHEDULER_REASON_READ_READY; |
@@ -1910,8 +1911,10 @@ GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh) | |||
1910 | 1911 | ||
1911 | /* check for tasks that reached the timeout! */ | 1912 | /* check for tasks that reached the timeout! */ |
1912 | now = GNUNET_TIME_absolute_get (); | 1913 | now = GNUNET_TIME_absolute_get (); |
1913 | while (NULL != (pos = pending_timeout_head)) | 1914 | pos = pending_timeout_head; |
1915 | while (NULL != pos) | ||
1914 | { | 1916 | { |
1917 | struct GNUNET_SCHEDULER_Task *next = pos->next; | ||
1915 | if (now.abs_value_us >= pos->timeout.abs_value_us) | 1918 | if (now.abs_value_us >= pos->timeout.abs_value_us) |
1916 | pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; | 1919 | pos->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT; |
1917 | if (0 == pos->reason) | 1920 | if (0 == pos->reason) |
@@ -1922,6 +1925,7 @@ GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh) | |||
1922 | if (pending_timeout_last == pos) | 1925 | if (pending_timeout_last == pos) |
1923 | pending_timeout_last = NULL; | 1926 | pending_timeout_last = NULL; |
1924 | queue_ready_task (pos); | 1927 | queue_ready_task (pos); |
1928 | pos = next; | ||
1925 | } | 1929 | } |
1926 | pos = pending_head; | 1930 | pos = pending_head; |
1927 | while (NULL != pos) | 1931 | while (NULL != pos) |
@@ -2020,7 +2024,6 @@ GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh) | |||
2020 | active_task = NULL; | 2024 | active_task = NULL; |
2021 | dump_backtrace (pos); | 2025 | dump_backtrace (pos); |
2022 | destroy_task (pos); | 2026 | destroy_task (pos); |
2023 | tasks_run++; | ||
2024 | } | 2027 | } |
2025 | shutdown_if_no_lifeness (); | 2028 | shutdown_if_no_lifeness (); |
2026 | if (0 == ready_count) | 2029 | if (0 == ready_count) |
@@ -2030,7 +2033,7 @@ GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh) | |||
2030 | return GNUNET_NO; | 2033 | return GNUNET_NO; |
2031 | } | 2034 | } |
2032 | scheduler_driver->set_wakeup (scheduler_driver->cls, | 2035 | scheduler_driver->set_wakeup (scheduler_driver->cls, |
2033 | GNUNET_TIME_absolute_get ()); | 2036 | GNUNET_TIME_absolute_get ()); |
2034 | return GNUNET_OK; | 2037 | return GNUNET_OK; |
2035 | } | 2038 | } |
2036 | 2039 | ||
@@ -2110,12 +2113,14 @@ GNUNET_SCHEDULER_run_with_driver (const struct GNUNET_SCHEDULER_Driver *driver, | |||
2110 | 0, | 2113 | 0, |
2111 | sizeof (tsk)); | 2114 | sizeof (tsk)); |
2112 | active_task = &tsk; | 2115 | active_task = &tsk; |
2113 | GNUNET_SCHEDULER_add_now (&GNUNET_OS_install_parent_control_handler, | 2116 | install_parent_control_task = |
2114 | NULL); | 2117 | GNUNET_SCHEDULER_add_now (&install_parent_control_handler, |
2115 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 2118 | NULL); |
2116 | pr, | 2119 | shutdown_pipe_task = |
2117 | &shutdown_cb, | 2120 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
2118 | NULL); | 2121 | pr, |
2122 | &shutdown_pipe_cb, | ||
2123 | NULL); | ||
2119 | current_lifeness = GNUNET_YES; | 2124 | current_lifeness = GNUNET_YES; |
2120 | GNUNET_SCHEDULER_add_with_reason_and_priority (task, | 2125 | GNUNET_SCHEDULER_add_with_reason_and_priority (task, |
2121 | task_cls, | 2126 | task_cls, |
@@ -2130,6 +2135,13 @@ GNUNET_SCHEDULER_run_with_driver (const struct GNUNET_SCHEDULER_Driver *driver, | |||
2130 | GNUNET_NETWORK_fdset_handle_set (sh.rs, pr); | 2135 | GNUNET_NETWORK_fdset_handle_set (sh.rs, pr); |
2131 | ret = driver->loop (driver->cls, | 2136 | ret = driver->loop (driver->cls, |
2132 | &sh); | 2137 | &sh); |
2138 | GNUNET_assert (NULL == pending_head); | ||
2139 | GNUNET_assert (NULL == pending_timeout_head); | ||
2140 | GNUNET_assert (NULL == shutdown_head); | ||
2141 | for (int i = 0; i != GNUNET_SCHEDULER_PRIORITY_COUNT; ++i) | ||
2142 | { | ||
2143 | GNUNET_assert (NULL == ready_head[i]); | ||
2144 | } | ||
2133 | GNUNET_NETWORK_fdset_destroy (sh.rs); | 2145 | GNUNET_NETWORK_fdset_destroy (sh.rs); |
2134 | GNUNET_NETWORK_fdset_destroy (sh.ws); | 2146 | GNUNET_NETWORK_fdset_destroy (sh.ws); |
2135 | 2147 | ||
@@ -2220,7 +2232,7 @@ select_loop (void *cls, | |||
2220 | struct DriverContext *context; | 2232 | struct DriverContext *context; |
2221 | int select_result; | 2233 | int select_result; |
2222 | int tasks_ready; | 2234 | int tasks_ready; |
2223 | 2235 | ||
2224 | context = cls; | 2236 | context = cls; |
2225 | GNUNET_assert (NULL != context); | 2237 | GNUNET_assert (NULL != context); |
2226 | rs = GNUNET_NETWORK_fdset_create (); | 2238 | rs = GNUNET_NETWORK_fdset_create (); |
@@ -2298,24 +2310,27 @@ select_loop (void *cls, | |||
2298 | GNUNET_NETWORK_fdset_destroy (ws); | 2310 | GNUNET_NETWORK_fdset_destroy (ws); |
2299 | return GNUNET_SYSERR; | 2311 | return GNUNET_SYSERR; |
2300 | } | 2312 | } |
2301 | for (pos = context->scheduled_head; NULL != pos; pos = pos->next) | 2313 | if (select_result > 0) |
2302 | { | 2314 | { |
2303 | int is_ready = GNUNET_NO; | 2315 | for (pos = context->scheduled_head; NULL != pos; pos = pos->next) |
2304 | if (0 != (GNUNET_SCHEDULER_ET_IN & pos->et) && | ||
2305 | GNUNET_YES == GNUNET_NETWORK_fdset_test_native (rs, pos->fdi->sock)) | ||
2306 | { | 2316 | { |
2307 | pos->fdi->et |= GNUNET_SCHEDULER_ET_IN; | 2317 | int is_ready = GNUNET_NO; |
2308 | is_ready = GNUNET_YES; | 2318 | if (0 != (GNUNET_SCHEDULER_ET_IN & pos->et) && |
2309 | } | 2319 | GNUNET_YES == GNUNET_NETWORK_fdset_test_native (rs, pos->fdi->sock)) |
2310 | if (0 != (GNUNET_SCHEDULER_ET_OUT & pos->et) && | 2320 | { |
2311 | GNUNET_YES == GNUNET_NETWORK_fdset_test_native (ws, pos->fdi->sock)) | 2321 | pos->fdi->et |= GNUNET_SCHEDULER_ET_IN; |
2312 | { | 2322 | is_ready = GNUNET_YES; |
2313 | pos->fdi->et |= GNUNET_SCHEDULER_ET_OUT; | 2323 | } |
2314 | is_ready = GNUNET_YES; | 2324 | if (0 != (GNUNET_SCHEDULER_ET_OUT & pos->et) && |
2315 | } | 2325 | GNUNET_YES == GNUNET_NETWORK_fdset_test_native (ws, pos->fdi->sock)) |
2316 | if (GNUNET_YES == is_ready) | 2326 | { |
2317 | { | 2327 | pos->fdi->et |= GNUNET_SCHEDULER_ET_OUT; |
2318 | GNUNET_SCHEDULER_task_ready (pos->task, pos->fdi); | 2328 | is_ready = GNUNET_YES; |
2329 | } | ||
2330 | if (GNUNET_YES == is_ready) | ||
2331 | { | ||
2332 | GNUNET_SCHEDULER_task_ready (pos->task, pos->fdi); | ||
2333 | } | ||
2319 | } | 2334 | } |
2320 | } | 2335 | } |
2321 | tasks_ready = GNUNET_SCHEDULER_run_from_driver (sh); | 2336 | tasks_ready = GNUNET_SCHEDULER_run_from_driver (sh); |
@@ -2323,17 +2338,17 @@ select_loop (void *cls, | |||
2323 | } | 2338 | } |
2324 | GNUNET_NETWORK_fdset_destroy (rs); | 2339 | GNUNET_NETWORK_fdset_destroy (rs); |
2325 | GNUNET_NETWORK_fdset_destroy (ws); | 2340 | GNUNET_NETWORK_fdset_destroy (ws); |
2326 | return GNUNET_OK; | 2341 | return GNUNET_OK; |
2327 | } | 2342 | } |
2328 | 2343 | ||
2329 | 2344 | ||
2330 | void | 2345 | void |
2331 | select_set_wakeup(void *cls, | 2346 | select_set_wakeup (void *cls, |
2332 | struct GNUNET_TIME_Absolute dt) | 2347 | struct GNUNET_TIME_Absolute dt) |
2333 | { | 2348 | { |
2334 | struct DriverContext *context = cls; | 2349 | struct DriverContext *context = cls; |
2335 | GNUNET_assert (NULL != context); | 2350 | GNUNET_assert (NULL != context); |
2336 | 2351 | ||
2337 | context->timeout = GNUNET_TIME_absolute_get_remaining (dt); | 2352 | context->timeout = GNUNET_TIME_absolute_get_remaining (dt); |
2338 | } | 2353 | } |
2339 | 2354 | ||
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c index 55d4c7137..83319d2aa 100644 --- a/src/util/test_scheduler.c +++ b/src/util/test_scheduler.c | |||
@@ -29,6 +29,8 @@ static struct GNUNET_DISK_PipeHandle *p; | |||
29 | 29 | ||
30 | static const struct GNUNET_DISK_FileHandle *fds[2]; | 30 | static const struct GNUNET_DISK_FileHandle *fds[2]; |
31 | 31 | ||
32 | static struct GNUNET_SCHEDULER_Task *never_run_task; | ||
33 | |||
32 | 34 | ||
33 | static void | 35 | static void |
34 | task2 (void *cls) | 36 | task2 (void *cls) |
@@ -76,7 +78,7 @@ taskNeverRun (void *cls) | |||
76 | 78 | ||
77 | 79 | ||
78 | static void | 80 | static void |
79 | taskLast (void *cls) | 81 | taskLastRd (void *cls) |
80 | { | 82 | { |
81 | int *ok = cls; | 83 | int *ok = cls; |
82 | 84 | ||
@@ -86,6 +88,27 @@ taskLast (void *cls) | |||
86 | 88 | ||
87 | 89 | ||
88 | static void | 90 | static void |
91 | taskLastSig (void *cls) | ||
92 | { | ||
93 | int *ok = cls; | ||
94 | |||
95 | GNUNET_SCHEDULER_cancel (never_run_task); | ||
96 | GNUNET_assert (9 == *ok); | ||
97 | (*ok) = 0; | ||
98 | } | ||
99 | |||
100 | |||
101 | static void | ||
102 | taskLastShutdown (void *cls) | ||
103 | { | ||
104 | int *ok = cls; | ||
105 | |||
106 | GNUNET_assert (10 == *ok); | ||
107 | (*ok) = 0; | ||
108 | } | ||
109 | |||
110 | |||
111 | static void | ||
89 | taskRd (void *cls) | 112 | taskRd (void *cls) |
90 | { | 113 | { |
91 | static char c; | 114 | static char c; |
@@ -97,7 +120,7 @@ taskRd (void *cls) | |||
97 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); | 120 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); |
98 | GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); | 121 | GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); |
99 | (*ok) = 8; | 122 | (*ok) = 8; |
100 | GNUNET_SCHEDULER_add_shutdown (&taskLast, | 123 | GNUNET_SCHEDULER_add_shutdown (&taskLastRd, |
101 | cls); | 124 | cls); |
102 | GNUNET_SCHEDULER_shutdown (); | 125 | GNUNET_SCHEDULER_shutdown (); |
103 | } | 126 | } |
@@ -151,6 +174,8 @@ check () | |||
151 | { | 174 | { |
152 | int ok; | 175 | int ok; |
153 | 176 | ||
177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
178 | "[Check scheduling]\n"); | ||
154 | ok = 1; | 179 | ok = 1; |
155 | GNUNET_SCHEDULER_run (&task1, &ok); | 180 | GNUNET_SCHEDULER_run (&task1, &ok); |
156 | return ok; | 181 | return ok; |
@@ -163,8 +188,8 @@ taskShutdown (void *cls) | |||
163 | int *ok = cls; | 188 | int *ok = cls; |
164 | 189 | ||
165 | GNUNET_assert (1 == *ok); | 190 | GNUNET_assert (1 == *ok); |
166 | *ok = 8; | 191 | *ok = 10; |
167 | GNUNET_SCHEDULER_add_shutdown (&taskLast, cls); | 192 | GNUNET_SCHEDULER_add_shutdown (&taskLastShutdown, cls); |
168 | GNUNET_SCHEDULER_shutdown (); | 193 | GNUNET_SCHEDULER_shutdown (); |
169 | } | 194 | } |
170 | 195 | ||
@@ -178,6 +203,8 @@ checkShutdown () | |||
178 | { | 203 | { |
179 | int ok; | 204 | int ok; |
180 | 205 | ||
206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
207 | "[Check shutdown]\n"); | ||
181 | ok = 1; | 208 | ok = 1; |
182 | GNUNET_SCHEDULER_run (&taskShutdown, &ok); | 209 | GNUNET_SCHEDULER_run (&taskShutdown, &ok); |
183 | return ok; | 210 | return ok; |
@@ -191,8 +218,12 @@ taskSig (void *cls) | |||
191 | int *ok = cls; | 218 | int *ok = cls; |
192 | 219 | ||
193 | GNUNET_assert (1 == *ok); | 220 | GNUNET_assert (1 == *ok); |
194 | *ok = 8; | 221 | *ok = 9; |
195 | GNUNET_SCHEDULER_add_shutdown (&taskLast, cls); | 222 | GNUNET_SCHEDULER_add_shutdown (&taskLastSig, cls); |
223 | never_run_task = | ||
224 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | ||
225 | &taskNeverRun, | ||
226 | NULL); | ||
196 | GNUNET_break (0 == PLIBC_KILL (getpid (), | 227 | GNUNET_break (0 == PLIBC_KILL (getpid (), |
197 | GNUNET_TERM_SIG)); | 228 | GNUNET_TERM_SIG)); |
198 | } | 229 | } |
@@ -207,6 +238,8 @@ checkSignal () | |||
207 | { | 238 | { |
208 | int ok; | 239 | int ok; |
209 | 240 | ||
241 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
242 | "[Check signal handling]\n"); | ||
210 | ok = 1; | 243 | ok = 1; |
211 | GNUNET_SCHEDULER_run (&taskSig, &ok); | 244 | GNUNET_SCHEDULER_run (&taskSig, &ok); |
212 | return ok; | 245 | return ok; |
@@ -234,6 +267,8 @@ checkCancel () | |||
234 | { | 267 | { |
235 | int ok; | 268 | int ok; |
236 | 269 | ||
270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
271 | "[Check task cancellation]\n"); | ||
237 | ok = 1; | 272 | ok = 1; |
238 | GNUNET_SCHEDULER_run (&taskCancel, &ok); | 273 | GNUNET_SCHEDULER_run (&taskCancel, &ok); |
239 | return ok; | 274 | return ok; |
@@ -247,11 +282,11 @@ main (int argc, char *argv[]) | |||
247 | 282 | ||
248 | GNUNET_log_setup ("test_scheduler", "WARNING", NULL); | 283 | GNUNET_log_setup ("test_scheduler", "WARNING", NULL); |
249 | ret += check (); | 284 | ret += check (); |
285 | ret += checkCancel (); | ||
250 | #ifndef MINGW | 286 | #ifndef MINGW |
251 | ret += checkSignal (); | 287 | ret += checkSignal (); |
252 | #endif | 288 | #endif |
253 | ret += checkShutdown (); | 289 | ret += checkShutdown (); |
254 | ret += checkCancel (); | ||
255 | GNUNET_DISK_pipe_close (p); | 290 | GNUNET_DISK_pipe_close (p); |
256 | 291 | ||
257 | return ret; | 292 | return ret; |