diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-07-26 18:22:54 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-07-26 18:22:54 +0000 |
commit | 81eae49a1b5dfeadb9aac5974ec87cd01aed9ffd (patch) | |
tree | 35b65462b9209af4bd610552bb485ad22487400e | |
parent | bf4a9d8364675b34ac18d505e508006e2b773670 (diff) | |
download | gnunet-81eae49a1b5dfeadb9aac5974ec87cd01aed9ffd.tar.gz gnunet-81eae49a1b5dfeadb9aac5974ec87cd01aed9ffd.zip |
start service
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/dht/gnunet-dht-driver.c | 4 | ||||
-rw-r--r-- | src/dht/gnunet-dht-put.c | 15 | ||||
-rw-r--r-- | src/include/gnunet_peerinfo_service.h | 71 | ||||
-rw-r--r-- | src/include/gnunet_testing_lib.h | 38 | ||||
-rw-r--r-- | src/nse/nse-profiler.c | 16 | ||||
-rw-r--r-- | src/nse/nse_profiler_test.conf | 40 | ||||
-rw-r--r-- | src/nse/test_nse.conf | 2 | ||||
-rw-r--r-- | src/peerinfo/Makefile.am | 3 | ||||
-rw-r--r-- | src/peerinfo/gnunet-service-peerinfo.c | 22 | ||||
-rw-r--r-- | src/peerinfo/test_peerinfo_api.c | 19 | ||||
-rw-r--r-- | src/testing/testing.c | 89 | ||||
-rw-r--r-- | src/testing/testing_group.c | 129 | ||||
-rw-r--r-- | src/util/service.c | 4 |
14 files changed, 402 insertions, 51 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index c3cf0836a..d912ac173 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -22,6 +22,7 @@ SUBDIRS = \ | |||
22 | transport \ | 22 | transport \ |
23 | peerinfo-tool \ | 23 | peerinfo-tool \ |
24 | core \ | 24 | core \ |
25 | nse \ | ||
25 | testing \ | 26 | testing \ |
26 | nse \ | 27 | nse \ |
27 | dv \ | 28 | dv \ |
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index 7c602cfca..6039e196b 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c | |||
@@ -3354,8 +3354,8 @@ hostkey_callback(void *cls, const struct GNUNET_PeerIdentity *id, | |||
3354 | } | 3354 | } |
3355 | 3355 | ||
3356 | static void | 3356 | static void |
3357 | run(void *cls, char * const *args, const char *cfgfile, | 3357 | run (void *cls, char * const *args, const char *cfgfile, |
3358 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 3358 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
3359 | { | 3359 | { |
3360 | struct stat frstat; | 3360 | struct stat frstat; |
3361 | struct GNUNET_DHTLOG_TrialInfo trial_info; | 3361 | struct GNUNET_DHTLOG_TrialInfo trial_info; |
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index 6bd9f9045..02a4fc217 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c | |||
@@ -149,18 +149,11 @@ run (void *cls, | |||
149 | expiration_seconds)); | 149 | expiration_seconds)); |
150 | 150 | ||
151 | if (verbose) | 151 | if (verbose) |
152 | fprintf (stderr, | 152 | fprintf (stderr, _("Issuing put request for `%s' with data `%s'!\n"), |
153 | _("Issuing put request for `%s' with data `%s'!\n"), | ||
154 | query_key, data); | 153 | query_key, data); |
155 | GNUNET_DHT_put (dht_handle, | 154 | GNUNET_DHT_put (dht_handle, &key, DEFAULT_PUT_REPLICATION, |
156 | &key, | 155 | GNUNET_DHT_RO_NONE, query_type, strlen (data), data, |
157 | DEFAULT_PUT_REPLICATION, | 156 | expiration, timeout, &message_sent_cont, NULL); |
158 | GNUNET_DHT_RO_NONE, | ||
159 | query_type, | ||
160 | strlen (data), data, | ||
161 | expiration, | ||
162 | timeout, | ||
163 | &message_sent_cont, NULL); | ||
164 | 157 | ||
165 | } | 158 | } |
166 | 159 | ||
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h index 1411168c0..ff4d99d95 100644 --- a/src/include/gnunet_peerinfo_service.h +++ b/src/include/gnunet_peerinfo_service.h | |||
@@ -89,6 +89,45 @@ GNUNET_PEERINFO_add_peer (struct GNUNET_PEERINFO_Handle *h, | |||
89 | 89 | ||
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Connect to the peerinfo service. | ||
93 | * | ||
94 | * @param cfg configuration to use | ||
95 | * @return NULL on error (configuration related, actual connection | ||
96 | * etablishment may happen asynchronously). | ||
97 | */ | ||
98 | struct GNUNET_PEERINFO_Handle * | ||
99 | GNUNET_PEERINFO_standalone_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
100 | |||
101 | |||
102 | /** | ||
103 | * Disconnect from the peerinfo service. Note that all iterators must | ||
104 | * have completed or have been cancelled by the time this function is | ||
105 | * called (otherwise, calling this function is a serious error). | ||
106 | * Furthermore, if 'GNUNET_PEERINFO_add_peer' operations are still | ||
107 | * pending, they will be cancelled silently on disconnect. | ||
108 | * | ||
109 | * @param h handle to disconnect | ||
110 | */ | ||
111 | void | ||
112 | GNUNET_PEERINFO_standalone_disconnect (struct GNUNET_PEERINFO_Handle *h); | ||
113 | |||
114 | |||
115 | /** | ||
116 | * Add a host to the persistent list. This method operates in | ||
117 | * semi-reliable mode: if the transmission is not completed by | ||
118 | * the time 'GNUNET_PEERINFO_disconnect' is called, it will be | ||
119 | * aborted. Furthermore, if a second HELLO is added for the | ||
120 | * same peer before the first one was transmitted, PEERINFO may | ||
121 | * merge the two HELLOs prior to transmission to the service. | ||
122 | * | ||
123 | * @param h handle to the peerinfo service | ||
124 | * @param hello the verified (!) HELLO message | ||
125 | */ | ||
126 | void | ||
127 | GNUNET_PEERINFO_standalone_add_peer (struct GNUNET_PEERINFO_Handle *h, | ||
128 | const struct GNUNET_HELLO_Message *hello); | ||
129 | |||
130 | /** | ||
92 | * Type of an iterator over the hosts. Note that each | 131 | * Type of an iterator over the hosts. Note that each |
93 | * host will be called with each available protocol. | 132 | * host will be called with each available protocol. |
94 | * | 133 | * |
@@ -144,9 +183,41 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, | |||
144 | void | 183 | void |
145 | GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic); | 184 | GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic); |
146 | 185 | ||
186 | /** | ||
187 | * Call a method for each known matching host and change its trust | ||
188 | * value. The callback method will be invoked once for each matching | ||
189 | * host and then finally once with a NULL pointer. After that final | ||
190 | * invocation, the iterator context must no longer be used. | ||
191 | * | ||
192 | * Instead of calling this function with 'peer == NULL' | ||
193 | * it is often better to use 'GNUNET_PEERINFO_notify'. | ||
194 | * | ||
195 | * @param h handle to the peerinfo service | ||
196 | * @param peer restrict iteration to this peer only (can be NULL) | ||
197 | * @param timeout how long to wait until timing out | ||
198 | * @param callback the method to call for each peer | ||
199 | * @param callback_cls closure for callback | ||
200 | * @return NULL on error (in this case, 'callback' is never called!), | ||
201 | * otherwise an iterator context | ||
202 | */ | ||
203 | struct GNUNET_PEERINFO_IteratorContext * | ||
204 | GNUNET_PEERINFO_standalone_iterate (struct GNUNET_PEERINFO_Handle *h, | ||
205 | const struct GNUNET_PeerIdentity *peer, | ||
206 | struct GNUNET_TIME_Relative timeout, | ||
207 | GNUNET_PEERINFO_Processor callback, | ||
208 | void *callback_cls); | ||
209 | |||
147 | 210 | ||
148 | 211 | ||
149 | /** | 212 | /** |
213 | * Cancel an iteration over peer information. | ||
214 | * | ||
215 | * @param ic context of the iterator to cancel | ||
216 | */ | ||
217 | void | ||
218 | GNUNET_PEERINFO_standalone_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic); | ||
219 | |||
220 | /** | ||
150 | * Handle for notifications about changes to the set of known peers. | 221 | * Handle for notifications about changes to the set of known peers. |
151 | */ | 222 | */ |
152 | struct GNUNET_PEERINFO_NotifyContext; | 223 | struct GNUNET_PEERINFO_NotifyContext; |
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index 0b998cf95..9d85f3af9 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h | |||
@@ -514,12 +514,27 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, | |||
514 | void *cb_cls); | 514 | void *cb_cls); |
515 | 515 | ||
516 | /** | 516 | /** |
517 | * Stops a GNUnet daemon. | 517 | * Starts a GNUnet daemon's service. |
518 | * | 518 | * |
519 | * @param d the daemon for which the service should be started | 519 | * @param d the daemon for which the service should be started |
520 | * @param service the name of the service to start | 520 | * @param service the name of the service to start |
521 | * @param timeout how long to wait for process for shutdown to complete | 521 | * @param timeout how long to wait for process for startup |
522 | * @param cb function called once the daemon was stopped | 522 | * @param cb function called once gnunet-arm returns |
523 | * @param cb_cls closure for cb | ||
524 | */ | ||
525 | void | ||
526 | GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d, | ||
527 | char *service, | ||
528 | struct GNUNET_TIME_Relative timeout, | ||
529 | GNUNET_TESTING_NotifyDaemonRunning cb, void *cb_cls); | ||
530 | |||
531 | /** | ||
532 | * Starts a GNUnet daemon's service which has been previously turned off. | ||
533 | * | ||
534 | * @param d the daemon for which the service should be started | ||
535 | * @param service the name of the service to start | ||
536 | * @param timeout how long to wait for process for startup | ||
537 | * @param cb function called once gnunet-arm returns | ||
523 | * @param cb_cls closure for cb | 538 | * @param cb_cls closure for cb |
524 | */ | 539 | */ |
525 | void | 540 | void |
@@ -759,6 +774,23 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg, | |||
759 | struct GNUNET_TIME_Relative timeout, | 774 | struct GNUNET_TIME_Relative timeout, |
760 | GNUNET_TESTING_NotifyCompletion cb, | 775 | GNUNET_TESTING_NotifyCompletion cb, |
761 | void *cb_cls); | 776 | void *cb_cls); |
777 | /* | ||
778 | * Start a given service for each of the peers in the peer group. | ||
779 | * | ||
780 | * @param pg handle for the peer group | ||
781 | * @param service the service to start | ||
782 | * @param timeout how long to wait for operations to finish before | ||
783 | * giving up | ||
784 | * @param cb function to call once finished | ||
785 | * @param cb_cls closure for cb | ||
786 | * | ||
787 | */ | ||
788 | void | ||
789 | GNUNET_TESTING_daemons_start_service (struct GNUNET_TESTING_PeerGroup *pg, | ||
790 | char *service, | ||
791 | struct GNUNET_TIME_Relative timeout, | ||
792 | GNUNET_TESTING_NotifyCompletion cb, | ||
793 | void *cb_cls); | ||
762 | 794 | ||
763 | /** | 795 | /** |
764 | * Callback function to process statistic values. | 796 | * Callback function to process statistic values. |
diff --git a/src/nse/nse-profiler.c b/src/nse/nse-profiler.c index f019165d1..3b7371ccc 100644 --- a/src/nse/nse-profiler.c +++ b/src/nse/nse-profiler.c | |||
@@ -507,6 +507,13 @@ churn_peers (void *cls, | |||
507 | 507 | ||
508 | 508 | ||
509 | static void | 509 | static void |
510 | nse_started_cb(void *cls, const char *emsg) | ||
511 | { | ||
512 | GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL); | ||
513 | disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, &disconnect_nse_peers, NULL); | ||
514 | } | ||
515 | |||
516 | static void | ||
510 | my_cb (void *cls, | 517 | my_cb (void *cls, |
511 | const char *emsg) | 518 | const char *emsg) |
512 | { | 519 | { |
@@ -538,10 +545,13 @@ my_cb (void *cls, | |||
538 | GNUNET_free (buf); | 545 | GNUNET_free (buf); |
539 | } | 546 | } |
540 | peers_running = GNUNET_TESTING_daemons_running(pg); | 547 | peers_running = GNUNET_TESTING_daemons_running(pg); |
541 | GNUNET_SCHEDULER_add_now(&connect_nse_service, NULL); | 548 | GNUNET_TESTING_daemons_start_service (pg, |
542 | disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, &disconnect_nse_peers, NULL); | 549 | "nse", |
543 | } | 550 | wait_time, |
551 | &nse_started_cb, | ||
552 | NULL); | ||
544 | 553 | ||
554 | } | ||
545 | 555 | ||
546 | /** | 556 | /** |
547 | * Function that will be called whenever two daemons are connected by | 557 | * Function that will be called whenever two daemons are connected by |
diff --git a/src/nse/nse_profiler_test.conf b/src/nse/nse_profiler_test.conf index 7da26b232..ad113b24f 100644 --- a/src/nse/nse_profiler_test.conf +++ b/src/nse/nse_profiler_test.conf | |||
@@ -11,6 +11,12 @@ BINARY = gnunet-service-nse | |||
11 | AUTOSTART = YES | 11 | AUTOSTART = YES |
12 | DEBUG = NO | 12 | DEBUG = NO |
13 | CONFIG = $DEFAULTCONFIG | 13 | CONFIG = $DEFAULTCONFIG |
14 | # Overriding network settings for faster testing (do NOT use | ||
15 | # these values in production just because they are here) | ||
16 | WORKDELAY = 10000 | ||
17 | INTERVAL = 15000 | ||
18 | WORKBITS = 0 | ||
19 | PROOFFILE = $SERVICEHOME/nse.proof | ||
14 | 20 | ||
15 | [arm] | 21 | [arm] |
16 | PORT = 0 | 22 | PORT = 0 |
@@ -19,7 +25,7 @@ UNIXPATH = /tmp/test-nse-service-arm.unix | |||
19 | #DEBUG = YES | 25 | #DEBUG = YES |
20 | 26 | ||
21 | [statistics] | 27 | [statistics] |
22 | AUTOSTART = NO | 28 | AUTOSTART = YES |
23 | 29 | ||
24 | [fs] | 30 | [fs] |
25 | AUTOSTART = NO | 31 | AUTOSTART = NO |
@@ -34,6 +40,15 @@ AUTOSTART = NO | |||
34 | PORT = 0 | 40 | PORT = 0 |
35 | AUTOSTART = YES | 41 | AUTOSTART = YES |
36 | 42 | ||
43 | [nat] | ||
44 | DISABLEV6 = YES | ||
45 | BINDTO = 127.0.0.1 | ||
46 | ENABLE_UPNP = NO | ||
47 | BEHIND_NAT = NO | ||
48 | ALLOW_NAT = NO | ||
49 | INTERNAL_ADDRESS = 127.0.0.1 | ||
50 | EXTERNAL_ADDRESS = 127.0.0.1 | ||
51 | |||
37 | [transport-unix] | 52 | [transport-unix] |
38 | PORT = 11111 | 53 | PORT = 11111 |
39 | 54 | ||
@@ -55,11 +70,15 @@ PORT = 0 | |||
55 | plugins = unix | 70 | plugins = unix |
56 | 71 | ||
57 | [testing] | 72 | [testing] |
58 | NUM_PEERS = 1000 | 73 | NUM_PEERS = 100 |
59 | WEAKRANDOM = YES | 74 | WEAKRANDOM = YES |
60 | TOPOLOGY = NONE | 75 | TOPOLOGY = NONE |
61 | CONNECT_TOPOLOGY = SMALL_WORLD_RING | 76 | CONNECT_TOPOLOGY = SMALL_WORLD_RING |
62 | PERCENTAGE = 4 | 77 | #CONNECT_TOPOLOGY = ERDOS_RENYI |
78 | #CONNECT_TOPOLOGY_OPTION = CONNECT_MINIMUM | ||
79 | #CONNECT_TOPOLOGY_OPTION_MODIFIER = 20 | ||
80 | PERCENTAGE = 3 | ||
81 | #PROBABILITY = .1 | ||
63 | F2F = NO | 82 | F2F = NO |
64 | CONNECT_TIMEOUT = 60 | 83 | CONNECT_TIMEOUT = 60 |
65 | CONNECT_ATTEMPTS = 3 | 84 | CONNECT_ATTEMPTS = 3 |
@@ -74,12 +93,17 @@ MAX_OUTSTANDING_CONNECTIONS = 200 | |||
74 | #NUM_PEERINFO_PER_HOST = 10 | 93 | #NUM_PEERINFO_PER_HOST = 10 |
75 | #SINGLE_STATISTICS_PER_HOST = YES | 94 | #SINGLE_STATISTICS_PER_HOST = YES |
76 | #NUM_STATISTICS_PER_HOST = 10 | 95 | #NUM_STATISTICS_PER_HOST = 10 |
96 | DELETE_FILES = NO | ||
77 | 97 | ||
78 | [nse-profiler] | 98 | [nse-profiler] |
79 | #OUTPUT_FILE = nse_output_1000_peers.dat | 99 | #OUTPUT_FILE = nse_output_100_peers.dat |
80 | #TOPOLOGY_OUTPUT_FILE = nse_topo_1000_peers | 100 | TOPOLOGY_OUTPUT_FILE = nse_topo_100_peers |
81 | #ROUND0 = 75 | 101 | DATA_OUTPUT_FILE = nse_topo_100_peers_stats |
82 | #ROUND1 = 750 | 102 | #ROUND0 = 90 |
103 | #ROUND1 = 100 | ||
104 | #ROUND2 = 50 | ||
105 | #ROUND3 = 100 | ||
83 | #ROUND2 = 500 | 106 | #ROUND2 = 500 |
84 | #ROUND3 = 1000 | 107 | #ROUND3 = 1000 |
85 | WAIT_TIME = 7200 | 108 | WAIT_TIME = 120 |
109 | CONNECTION_LIMIT = 10 | ||
diff --git a/src/nse/test_nse.conf b/src/nse/test_nse.conf index 475f87eaf..ab64dffe2 100644 --- a/src/nse/test_nse.conf +++ b/src/nse/test_nse.conf | |||
@@ -11,7 +11,7 @@ BINARY = gnunet-service-nse | |||
11 | AUTOSTART = YES | 11 | AUTOSTART = YES |
12 | DEBUG = YES | 12 | DEBUG = YES |
13 | CONFIG = $DEFAULTCONFIG | 13 | CONFIG = $DEFAULTCONFIG |
14 | 14 | PROOFFILE = $SERVICEHOME/proof.nse | |
15 | # Overriding network settings for faster testing (do NOT use | 15 | # Overriding network settings for faster testing (do NOT use |
16 | # these values in production just because they are here) | 16 | # these values in production just because they are here) |
17 | WORKDELAY = 1 | 17 | WORKDELAY = 1 |
diff --git a/src/peerinfo/Makefile.am b/src/peerinfo/Makefile.am index d58425730..2a078536f 100644 --- a/src/peerinfo/Makefile.am +++ b/src/peerinfo/Makefile.am | |||
@@ -13,7 +13,8 @@ lib_LTLIBRARIES = libgnunetpeerinfo.la | |||
13 | 13 | ||
14 | libgnunetpeerinfo_la_SOURCES = \ | 14 | libgnunetpeerinfo_la_SOURCES = \ |
15 | peerinfo_api.c peerinfo.h \ | 15 | peerinfo_api.c peerinfo.h \ |
16 | peerinfo_api_notify.c | 16 | peerinfo_api_notify.c \ |
17 | standalone-peerinfo.c | ||
17 | libgnunetpeerinfo_la_LIBADD = \ | 18 | libgnunetpeerinfo_la_LIBADD = \ |
18 | $(top_builddir)/src/hello/libgnunethello.la \ | 19 | $(top_builddir)/src/hello/libgnunethello.la \ |
19 | $(top_builddir)/src/util/libgnunetutil.la \ | 20 | $(top_builddir)/src/util/libgnunetutil.la \ |
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index d5d153b65..0d86e483c 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -51,6 +51,8 @@ | |||
51 | */ | 51 | */ |
52 | #define DATA_HOST_CLEAN_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 60) | 52 | #define DATA_HOST_CLEAN_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 60) |
53 | 53 | ||
54 | #define WRITE_TO_DISK GNUNET_NO | ||
55 | |||
54 | /** | 56 | /** |
55 | * In-memory cache of known hosts. | 57 | * In-memory cache of known hosts. |
56 | */ | 58 | */ |
@@ -113,6 +115,7 @@ make_info_message (const struct HostEntry *he) | |||
113 | } | 115 | } |
114 | 116 | ||
115 | 117 | ||
118 | #if WRITE_TO_DISK | ||
116 | /** | 119 | /** |
117 | * Address iterator that causes expired entries to be discarded. | 120 | * Address iterator that causes expired entries to be discarded. |
118 | * | 121 | * |
@@ -157,6 +160,7 @@ get_host_filename (const struct GNUNET_PeerIdentity *id) | |||
157 | "%s%s%s", networkIdDirectory, DIR_SEPARATOR_STR, &fil); | 160 | "%s%s%s", networkIdDirectory, DIR_SEPARATOR_STR, &fil); |
158 | return fn; | 161 | return fn; |
159 | } | 162 | } |
163 | #endif | ||
160 | 164 | ||
161 | 165 | ||
162 | /** | 166 | /** |
@@ -187,12 +191,14 @@ static void | |||
187 | add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) | 191 | add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) |
188 | { | 192 | { |
189 | struct HostEntry *entry; | 193 | struct HostEntry *entry; |
194 | #if WRITE_TO_DISK | ||
190 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; | 195 | char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; |
191 | const struct GNUNET_HELLO_Message *hello; | 196 | const struct GNUNET_HELLO_Message *hello; |
192 | struct GNUNET_HELLO_Message *hello_clean; | 197 | struct GNUNET_HELLO_Message *hello_clean; |
193 | int size; | 198 | int size; |
194 | struct GNUNET_TIME_Absolute now; | 199 | struct GNUNET_TIME_Absolute now; |
195 | char *fn; | 200 | char *fn; |
201 | #endif | ||
196 | 202 | ||
197 | entry = GNUNET_CONTAINER_multihashmap_get (hostmap, | 203 | entry = GNUNET_CONTAINER_multihashmap_get (hostmap, |
198 | &identity->hashPubKey); | 204 | &identity->hashPubKey); |
@@ -204,7 +210,7 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) | |||
204 | GNUNET_NO); | 210 | GNUNET_NO); |
205 | entry = GNUNET_malloc (sizeof (struct HostEntry)); | 211 | entry = GNUNET_malloc (sizeof (struct HostEntry)); |
206 | entry->identity = *identity; | 212 | entry->identity = *identity; |
207 | 213 | #if WRITE_TO_DISK | |
208 | fn = get_host_filename (identity); | 214 | fn = get_host_filename (identity); |
209 | if (GNUNET_DISK_file_test (fn) == GNUNET_YES) | 215 | if (GNUNET_DISK_file_test (fn) == GNUNET_YES) |
210 | { | 216 | { |
@@ -230,6 +236,7 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) | |||
230 | } | 236 | } |
231 | } | 237 | } |
232 | GNUNET_free (fn); | 238 | GNUNET_free (fn); |
239 | #endif | ||
233 | GNUNET_CONTAINER_multihashmap_put (hostmap, | 240 | GNUNET_CONTAINER_multihashmap_put (hostmap, |
234 | &identity->hashPubKey, | 241 | &identity->hashPubKey, |
235 | entry, | 242 | entry, |
@@ -237,7 +244,7 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) | |||
237 | notify_all (entry); | 244 | notify_all (entry); |
238 | } | 245 | } |
239 | 246 | ||
240 | 247 | #if WRITE_TO_DISK | |
241 | /** | 248 | /** |
242 | * Remove a file that should not be there. LOG | 249 | * Remove a file that should not be there. LOG |
243 | * success or failure. | 250 | * success or failure. |
@@ -319,7 +326,7 @@ cron_scan_directory_data_hosts (void *cls, | |||
319 | GNUNET_SCHEDULER_add_delayed (DATA_HOST_FREQ, | 326 | GNUNET_SCHEDULER_add_delayed (DATA_HOST_FREQ, |
320 | &cron_scan_directory_data_hosts, NULL); | 327 | &cron_scan_directory_data_hosts, NULL); |
321 | } | 328 | } |
322 | 329 | #endif | |
323 | 330 | ||
324 | /** | 331 | /** |
325 | * Bind a host address (hello) to a hostId. | 332 | * Bind a host address (hello) to a hostId. |
@@ -331,7 +338,9 @@ static void | |||
331 | bind_address (const struct GNUNET_PeerIdentity *peer, | 338 | bind_address (const struct GNUNET_PeerIdentity *peer, |
332 | const struct GNUNET_HELLO_Message *hello) | 339 | const struct GNUNET_HELLO_Message *hello) |
333 | { | 340 | { |
341 | #if WRITE_TO_DISK | ||
334 | char *fn; | 342 | char *fn; |
343 | #endif | ||
335 | struct HostEntry *host; | 344 | struct HostEntry *host; |
336 | struct GNUNET_HELLO_Message *mrg; | 345 | struct GNUNET_HELLO_Message *mrg; |
337 | struct GNUNET_TIME_Absolute delta; | 346 | struct GNUNET_TIME_Absolute delta; |
@@ -359,6 +368,7 @@ bind_address (const struct GNUNET_PeerIdentity *peer, | |||
359 | GNUNET_free (host->hello); | 368 | GNUNET_free (host->hello); |
360 | host->hello = mrg; | 369 | host->hello = mrg; |
361 | } | 370 | } |
371 | #if WRITE_TO_DISK | ||
362 | fn = get_host_filename (peer); | 372 | fn = get_host_filename (peer); |
363 | if (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn)) | 373 | if (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn)) |
364 | { | 374 | { |
@@ -374,6 +384,7 @@ bind_address (const struct GNUNET_PeerIdentity *peer, | |||
374 | 384 | ||
375 | } | 385 | } |
376 | GNUNET_free (fn); | 386 | GNUNET_free (fn); |
387 | #endif | ||
377 | notify_all (host); | 388 | notify_all (host); |
378 | } | 389 | } |
379 | 390 | ||
@@ -417,7 +428,7 @@ add_to_tc (void *cls, | |||
417 | return GNUNET_YES; | 428 | return GNUNET_YES; |
418 | } | 429 | } |
419 | 430 | ||
420 | 431 | #if WRITE_TO_DISK | |
421 | /** | 432 | /** |
422 | * @brief delete expired HELLO entries in data/hosts/ | 433 | * @brief delete expired HELLO entries in data/hosts/ |
423 | */ | 434 | */ |
@@ -478,6 +489,7 @@ cron_clean_data_hosts (void *cls, | |||
478 | GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, | 489 | GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, |
479 | &cron_clean_data_hosts, NULL); | 490 | &cron_clean_data_hosts, NULL); |
480 | } | 491 | } |
492 | #endif | ||
481 | 493 | ||
482 | 494 | ||
483 | /** | 495 | /** |
@@ -683,6 +695,7 @@ run (void *cls, | |||
683 | hostmap = GNUNET_CONTAINER_multihashmap_create (1024); | 695 | hostmap = GNUNET_CONTAINER_multihashmap_create (1024); |
684 | stats = GNUNET_STATISTICS_create ("peerinfo", cfg); | 696 | stats = GNUNET_STATISTICS_create ("peerinfo", cfg); |
685 | notify_list = GNUNET_SERVER_notification_context_create (server, 0); | 697 | notify_list = GNUNET_SERVER_notification_context_create (server, 0); |
698 | #if WRITE_TO_DISK | ||
686 | GNUNET_assert (GNUNET_OK == | 699 | GNUNET_assert (GNUNET_OK == |
687 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 700 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
688 | "peerinfo", | 701 | "peerinfo", |
@@ -693,6 +706,7 @@ run (void *cls, | |||
693 | &cron_scan_directory_data_hosts, NULL); | 706 | &cron_scan_directory_data_hosts, NULL); |
694 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 707 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
695 | &cron_clean_data_hosts, NULL); | 708 | &cron_clean_data_hosts, NULL); |
709 | #endif | ||
696 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 710 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
697 | &shutdown_task, NULL); | 711 | &shutdown_task, NULL); |
698 | GNUNET_SERVER_add_handlers (server, handlers); | 712 | GNUNET_SERVER_add_handlers (server, handlers); |
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c index 460a3764d..15efeccad 100644 --- a/src/peerinfo/test_peerinfo_api.c +++ b/src/peerinfo/test_peerinfo_api.c | |||
@@ -44,6 +44,8 @@ static struct GNUNET_PEERINFO_Handle *h; | |||
44 | 44 | ||
45 | static unsigned int retries; | 45 | static unsigned int retries; |
46 | 46 | ||
47 | struct GNUNET_PeerIdentity pid; | ||
48 | |||
47 | static int | 49 | static int |
48 | check_it (void *cls, | 50 | check_it (void *cls, |
49 | const char *tname, | 51 | const char *tname, |
@@ -83,7 +85,6 @@ static void | |||
83 | add_peer () | 85 | add_peer () |
84 | { | 86 | { |
85 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; | 87 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; |
86 | struct GNUNET_PeerIdentity pid; | ||
87 | struct GNUNET_HELLO_Message *h2; | 88 | struct GNUNET_HELLO_Message *h2; |
88 | size_t agc; | 89 | size_t agc; |
89 | 90 | ||
@@ -91,7 +92,7 @@ add_peer () | |||
91 | memset (&pkey, 32, sizeof (pkey)); | 92 | memset (&pkey, 32, sizeof (pkey)); |
92 | GNUNET_CRYPTO_hash (&pkey, sizeof (pkey), &pid.hashPubKey); | 93 | GNUNET_CRYPTO_hash (&pkey, sizeof (pkey), &pid.hashPubKey); |
93 | h2 = GNUNET_HELLO_create (&pkey, &address_generator, &agc); | 94 | h2 = GNUNET_HELLO_create (&pkey, &address_generator, &agc); |
94 | GNUNET_PEERINFO_add_peer (h, h2); | 95 | GNUNET_PEERINFO_standalone_add_peer (h, h2); |
95 | GNUNET_free (h2); | 96 | GNUNET_free (h2); |
96 | 97 | ||
97 | } | 98 | } |
@@ -108,7 +109,7 @@ process (void *cls, | |||
108 | 109 | ||
109 | if (err_msg != NULL) | 110 | if (err_msg != NULL) |
110 | { | 111 | { |
111 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 112 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
112 | _("Error in communication with PEERINFO service\n")); | 113 | _("Error in communication with PEERINFO service\n")); |
113 | } | 114 | } |
114 | 115 | ||
@@ -121,8 +122,8 @@ process (void *cls, | |||
121 | /* try again */ | 122 | /* try again */ |
122 | retries++; | 123 | retries++; |
123 | add_peer (); | 124 | add_peer (); |
124 | ic = GNUNET_PEERINFO_iterate (h, | 125 | ic = GNUNET_PEERINFO_standalone_iterate (h, |
125 | NULL, | 126 | &pid, |
126 | GNUNET_TIME_relative_multiply | 127 | GNUNET_TIME_relative_multiply |
127 | (GNUNET_TIME_UNIT_SECONDS, 15), | 128 | (GNUNET_TIME_UNIT_SECONDS, 15), |
128 | &process, cls); | 129 | &process, cls); |
@@ -130,7 +131,7 @@ process (void *cls, | |||
130 | } | 131 | } |
131 | GNUNET_assert (peer == NULL); | 132 | GNUNET_assert (peer == NULL); |
132 | GNUNET_assert (2 == *ok); | 133 | GNUNET_assert (2 == *ok); |
133 | GNUNET_PEERINFO_disconnect (h); | 134 | GNUNET_PEERINFO_standalone_disconnect (h); |
134 | h = NULL; | 135 | h = NULL; |
135 | *ok = 0; | 136 | *ok = 0; |
136 | return; | 137 | return; |
@@ -153,11 +154,11 @@ run (void *cls, | |||
153 | const struct GNUNET_CONFIGURATION_Handle *c) | 154 | const struct GNUNET_CONFIGURATION_Handle *c) |
154 | { | 155 | { |
155 | cfg = c; | 156 | cfg = c; |
156 | h = GNUNET_PEERINFO_connect (cfg); | 157 | h = GNUNET_PEERINFO_standalone_connect (cfg); |
157 | GNUNET_assert (h != NULL); | 158 | GNUNET_assert (h != NULL); |
158 | add_peer (); | 159 | add_peer (); |
159 | ic = GNUNET_PEERINFO_iterate (h, | 160 | ic = GNUNET_PEERINFO_standalone_iterate (h, |
160 | NULL, | 161 | &pid, |
161 | GNUNET_TIME_relative_multiply | 162 | GNUNET_TIME_relative_multiply |
162 | (GNUNET_TIME_UNIT_SECONDS, 15), | 163 | (GNUNET_TIME_UNIT_SECONDS, 15), |
163 | &process, cls); | 164 | &process, cls); |
diff --git a/src/testing/testing.c b/src/testing/testing.c index 79c67e89c..a079390ad 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -1043,12 +1043,12 @@ GNUNET_TESTING_daemon_running (struct GNUNET_TESTING_Daemon *daemon) | |||
1043 | 1043 | ||
1044 | 1044 | ||
1045 | /** | 1045 | /** |
1046 | * Stops a GNUnet daemon. | 1046 | * Starts a GNUnet daemon service which has been previously stopped. |
1047 | * | 1047 | * |
1048 | * @param d the daemon for which the service should be started | 1048 | * @param d the daemon for which the service should be started |
1049 | * @param service the name of the service to start | 1049 | * @param service the name of the service to start |
1050 | * @param timeout how long to wait for process for shutdown to complete | 1050 | * @param timeout how long to wait for process for shutdown to complete |
1051 | * @param cb function called once the daemon was stopped | 1051 | * @param cb function called once the service starts |
1052 | * @param cb_cls closure for cb | 1052 | * @param cb_cls closure for cb |
1053 | */ | 1053 | */ |
1054 | void | 1054 | void |
@@ -1069,13 +1069,9 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d, | |||
1069 | d->phase = SP_START_DONE; | 1069 | d->phase = SP_START_DONE; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | #if DEBUG_TESTING | ||
1073 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1074 | _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); | ||
1075 | #endif | ||
1076 | if (d->churned_services == NULL) | 1072 | if (d->churned_services == NULL) |
1077 | { | 1073 | { |
1078 | d->dead_cb(d->dead_cb_cls, "No service has been churned off yet!!"); | 1074 | d->cb(d->cb_cls, &d->id, d->cfg, d, "No service has been churned off yet!!"); |
1079 | return; | 1075 | return; |
1080 | } | 1076 | } |
1081 | d->phase = SP_SERVICE_START; | 1077 | d->phase = SP_SERVICE_START; |
@@ -1132,6 +1128,85 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d, | |||
1132 | } | 1128 | } |
1133 | 1129 | ||
1134 | /** | 1130 | /** |
1131 | * Starts a GNUnet daemon's service. | ||
1132 | * | ||
1133 | * @param d the daemon for which the service should be started | ||
1134 | * @param service the name of the service to start | ||
1135 | * @param timeout how long to wait for process for startup | ||
1136 | * @param cb function called once gnunet-arm returns | ||
1137 | * @param cb_cls closure for cb | ||
1138 | */ | ||
1139 | void | ||
1140 | GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d, | ||
1141 | char *service, | ||
1142 | struct GNUNET_TIME_Relative timeout, | ||
1143 | GNUNET_TESTING_NotifyDaemonRunning cb, void *cb_cls) | ||
1144 | { | ||
1145 | char *arg; | ||
1146 | d->cb = cb; | ||
1147 | d->cb_cls = cb_cls; | ||
1148 | |||
1149 | GNUNET_assert(service != NULL); | ||
1150 | GNUNET_assert(d->running == GNUNET_YES); | ||
1151 | GNUNET_assert(d->phase == SP_START_DONE); | ||
1152 | |||
1153 | #if DEBUG_TESTING | ||
1154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1155 | _("Starting service %s for peer `%4s'\n"), service, GNUNET_i2s (&d->id)); | ||
1156 | #endif | ||
1157 | |||
1158 | d->phase = SP_SERVICE_START; | ||
1159 | |||
1160 | /* Check if this is a local or remote process */ | ||
1161 | if (NULL != d->hostname) | ||
1162 | { | ||
1163 | #if DEBUG_TESTING | ||
1164 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1165 | "Starting gnunet-arm with config `%s' on host `%s'.\n", | ||
1166 | d->cfgfile, d->hostname); | ||
1167 | #endif | ||
1168 | |||
1169 | if (d->username != NULL) | ||
1170 | GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname); | ||
1171 | else | ||
1172 | arg = GNUNET_strdup (d->hostname); | ||
1173 | |||
1174 | d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", | ||
1175 | #if !DEBUG_TESTING | ||
1176 | "-q", | ||
1177 | #endif | ||
1178 | arg, "gnunet-arm", | ||
1179 | #if DEBUG_TESTING | ||
1180 | "-L", "DEBUG", | ||
1181 | #endif | ||
1182 | "-c", d->cfgfile, "-i", service, "-q", | ||
1183 | NULL); | ||
1184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1185 | "Starting gnunet-arm with command ssh %s gnunet-arm -c %s -i %s -q\n", | ||
1186 | arg, "gnunet-arm", d->cfgfile, service); | ||
1187 | GNUNET_free (arg); | ||
1188 | } | ||
1189 | else | ||
1190 | { | ||
1191 | #if DEBUG_TESTING | ||
1192 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1193 | "Starting gnunet-arm with config `%s' locally.\n", | ||
1194 | d->cfgfile); | ||
1195 | #endif | ||
1196 | d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", | ||
1197 | "gnunet-arm", | ||
1198 | #if DEBUG_TESTING | ||
1199 | "-L", "DEBUG", | ||
1200 | #endif | ||
1201 | "-c", d->cfgfile, "-i", service, "-q", | ||
1202 | NULL); | ||
1203 | } | ||
1204 | |||
1205 | d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); | ||
1206 | d->task = GNUNET_SCHEDULER_add_now (&start_fsm, d); | ||
1207 | } | ||
1208 | |||
1209 | /** | ||
1135 | * Start a peer that has previously been stopped using the daemon_stop | 1210 | * Start a peer that has previously been stopped using the daemon_stop |
1136 | * call (and files weren't deleted and the allow restart flag) | 1211 | * call (and files weren't deleted and the allow restart flag) |
1137 | * | 1212 | * |
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 7986d1b5f..ba4b29150 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -279,6 +279,33 @@ struct PeerRestartContext | |||
279 | struct GNUNET_TESTING_Daemon *daemon; | 279 | struct GNUNET_TESTING_Daemon *daemon; |
280 | }; | 280 | }; |
281 | 281 | ||
282 | struct ServiceStartContext | ||
283 | { | ||
284 | struct GNUNET_TESTING_PeerGroup *pg; | ||
285 | unsigned int remaining; | ||
286 | GNUNET_TESTING_NotifyCompletion cb; | ||
287 | unsigned int outstanding; | ||
288 | char *service; | ||
289 | struct GNUNET_TIME_Relative timeout; | ||
290 | void *cb_cls; | ||
291 | }; | ||
292 | |||
293 | /** | ||
294 | * Individual shutdown context for a particular peer. | ||
295 | */ | ||
296 | struct PeerServiceStartContext | ||
297 | { | ||
298 | /** | ||
299 | * Pointer to the high level start context. | ||
300 | */ | ||
301 | struct ServiceStartContext *start_ctx; | ||
302 | |||
303 | /** | ||
304 | * The daemon handle for the peer to start the service on. | ||
305 | */ | ||
306 | struct GNUNET_TESTING_Daemon *daemon; | ||
307 | }; | ||
308 | |||
282 | struct CreateTopologyContext | 309 | struct CreateTopologyContext |
283 | { | 310 | { |
284 | 311 | ||
@@ -5605,6 +5632,66 @@ schedule_churn_restart(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
5605 | } | 5632 | } |
5606 | } | 5633 | } |
5607 | 5634 | ||
5635 | /** | ||
5636 | * Callback for informing us about a successful | ||
5637 | * or unsuccessful churn start call. | ||
5638 | * | ||
5639 | * @param cls a struct ServiceStartContext *startup_ctx | ||
5640 | * @param id the peer identity of the started peer | ||
5641 | * @param cfg the handle to the configuration of the peer | ||
5642 | * @param d handle to the daemon for the peer | ||
5643 | * @param emsg NULL on success, non-NULL on failure | ||
5644 | * | ||
5645 | */ | ||
5646 | void | ||
5647 | service_start_callback(void *cls, | ||
5648 | const struct GNUNET_PeerIdentity *id, | ||
5649 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
5650 | struct GNUNET_TESTING_Daemon *d, | ||
5651 | const char *emsg) | ||
5652 | { | ||
5653 | struct ServiceStartContext *startup_ctx = (struct ServiceStartContext *)cls; | ||
5654 | |||
5655 | if (emsg != NULL) | ||
5656 | { | ||
5657 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
5658 | "Service start failed with error `%s'\n", emsg); | ||
5659 | } | ||
5660 | |||
5661 | startup_ctx->outstanding--; | ||
5662 | startup_ctx->remaining--; | ||
5663 | |||
5664 | if (startup_ctx->remaining == 0) | ||
5665 | { | ||
5666 | startup_ctx->cb (startup_ctx->cb_cls, NULL); | ||
5667 | GNUNET_free (startup_ctx->service); | ||
5668 | GNUNET_free (startup_ctx); | ||
5669 | } | ||
5670 | } | ||
5671 | |||
5672 | static void | ||
5673 | schedule_service_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
5674 | { | ||
5675 | struct PeerServiceStartContext *peer_ctx = cls; | ||
5676 | struct ServiceStartContext *startup_ctx = peer_ctx->start_ctx; | ||
5677 | |||
5678 | if (startup_ctx->outstanding > startup_ctx->pg->max_concurrent_ssh) | ||
5679 | GNUNET_SCHEDULER_add_delayed ( | ||
5680 | GNUNET_TIME_relative_multiply ( | ||
5681 | GNUNET_TIME_UNIT_MILLISECONDS, | ||
5682 | 100), | ||
5683 | &schedule_service_start, peer_ctx); | ||
5684 | else | ||
5685 | { | ||
5686 | |||
5687 | GNUNET_TESTING_daemon_start_service (peer_ctx->daemon, | ||
5688 | startup_ctx->service, | ||
5689 | startup_ctx->timeout, | ||
5690 | &service_start_callback, startup_ctx); | ||
5691 | GNUNET_free (peer_ctx); | ||
5692 | } | ||
5693 | } | ||
5694 | |||
5608 | 5695 | ||
5609 | static void | 5696 | static void |
5610 | internal_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 5697 | internal_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -6635,6 +6722,48 @@ GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg, | |||
6635 | GNUNET_free_non_null (stopped_permute); | 6722 | GNUNET_free_non_null (stopped_permute); |
6636 | } | 6723 | } |
6637 | 6724 | ||
6725 | /* | ||
6726 | * Start a given service for each of the peers in the peer group. | ||
6727 | * | ||
6728 | * @param pg handle for the peer group | ||
6729 | * @param service the service to start | ||
6730 | * @param timeout how long to wait for operations to finish before | ||
6731 | * giving up | ||
6732 | * @param cb function to call once finished | ||
6733 | * @param cb_cls closure for cb | ||
6734 | * | ||
6735 | */ | ||
6736 | void | ||
6737 | GNUNET_TESTING_daemons_start_service (struct GNUNET_TESTING_PeerGroup *pg, | ||
6738 | char *service, | ||
6739 | struct GNUNET_TIME_Relative timeout, | ||
6740 | GNUNET_TESTING_NotifyCompletion cb, | ||
6741 | void *cb_cls) | ||
6742 | { | ||
6743 | struct ServiceStartContext *start_ctx; | ||
6744 | struct PeerServiceStartContext *peer_start_ctx; | ||
6745 | unsigned int i; | ||
6746 | |||
6747 | GNUNET_assert(service != NULL); | ||
6748 | |||
6749 | start_ctx = GNUNET_malloc(sizeof(struct ServiceStartContext)); | ||
6750 | start_ctx->pg = pg; | ||
6751 | start_ctx->remaining = pg->total; | ||
6752 | start_ctx->cb = cb; | ||
6753 | start_ctx->cb_cls = cb_cls; | ||
6754 | start_ctx->service = GNUNET_strdup(service); | ||
6755 | |||
6756 | for (i = 0; i < pg->total; i++) | ||
6757 | { | ||
6758 | #if DEBUG_START | ||
6759 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Starting up service %s on peer %d!\n", service, stopped_arr[stopped_permute[i]]); | ||
6760 | #endif | ||
6761 | peer_start_ctx = GNUNET_malloc (sizeof (struct PeerServiceStartContext)); | ||
6762 | peer_start_ctx->start_ctx = start_ctx; | ||
6763 | peer_start_ctx->daemon = pg->peers[i].daemon; | ||
6764 | GNUNET_SCHEDULER_add_now (&schedule_service_start, peer_start_ctx); | ||
6765 | } | ||
6766 | } | ||
6638 | 6767 | ||
6639 | /** | 6768 | /** |
6640 | * Restart all peers in the given group. | 6769 | * Restart all peers in the given group. |
diff --git a/src/util/service.c b/src/util/service.c index abf3b2ab1..4d88aff43 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -1630,8 +1630,8 @@ GNUNET_SERVICE_run (int argc, | |||
1630 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(sctx.cfg, "testing", "skew_variance", &skew_variance))) | 1630 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(sctx.cfg, "testing", "skew_variance", &skew_variance))) |
1631 | { | 1631 | { |
1632 | clock_offset = skew_offset - skew_variance; | 1632 | clock_offset = skew_offset - skew_variance; |
1633 | #if 1 | 1633 | #if DEBUG_SERVICE |
1634 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Skewing clock by %ll\n", clock_offset); | 1634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Skewing clock by %dll\n", clock_offset); |
1635 | #endif | 1635 | #endif |
1636 | } | 1636 | } |
1637 | /* actually run service */ | 1637 | /* actually run service */ |