diff options
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/test_dht_multipeer_data.conf | 2 | ||||
-rw-r--r-- | src/dht/test_dht_twopeer.c | 62 | ||||
-rw-r--r-- | src/dht/test_dht_twopeer_data.conf | 2 | ||||
-rw-r--r-- | src/dht/test_dhtlog_data.conf | 2 |
4 files changed, 64 insertions, 4 deletions
diff --git a/src/dht/test_dht_multipeer_data.conf b/src/dht/test_dht_multipeer_data.conf index 8c4c903ff..be8578e8a 100644 --- a/src/dht/test_dht_multipeer_data.conf +++ b/src/dht/test_dht_multipeer_data.conf | |||
@@ -47,7 +47,7 @@ PORT = 12092 | |||
47 | DEBUG = NO | 47 | DEBUG = NO |
48 | 48 | ||
49 | [arm] | 49 | [arm] |
50 | DEFAULTSERVICES = core dht | 50 | DEFAULTSERVICES = dht |
51 | ACCEPT_FROM6 = ::1; | 51 | ACCEPT_FROM6 = ::1; |
52 | ACCEPT_FROM = 127.0.0.1; | 52 | ACCEPT_FROM = 127.0.0.1; |
53 | BINARY = gnunet-service-arm | 53 | BINARY = gnunet-service-arm |
diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c index 095bc7cb7..f3f9e4cbd 100644 --- a/src/dht/test_dht_twopeer.c +++ b/src/dht/test_dht_twopeer.c | |||
@@ -30,6 +30,8 @@ | |||
30 | /* DEFINES */ | 30 | /* DEFINES */ |
31 | #define VERBOSE GNUNET_YES | 31 | #define VERBOSE GNUNET_YES |
32 | 32 | ||
33 | #define MAX_GET_ATTEMPTS 10 | ||
34 | |||
33 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5) | 35 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5) |
34 | 36 | ||
35 | #define DEFAULT_NUM_PEERS 2 | 37 | #define DEFAULT_NUM_PEERS 2 |
@@ -43,6 +45,10 @@ struct PeerGetContext | |||
43 | struct GNUNET_DHT_Handle *dht_handle; | 45 | struct GNUNET_DHT_Handle *dht_handle; |
44 | 46 | ||
45 | struct GNUNET_DHT_GetHandle *get_handle; | 47 | struct GNUNET_DHT_GetHandle *get_handle; |
48 | |||
49 | unsigned int get_attempts; | ||
50 | |||
51 | GNUNET_SCHEDULER_TaskIdentifier retry_task; | ||
46 | }; | 52 | }; |
47 | 53 | ||
48 | /* Globals */ | 54 | /* Globals */ |
@@ -116,11 +122,17 @@ end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
116 | 122 | ||
117 | if (pg != NULL) | 123 | if (pg != NULL) |
118 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 124 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
125 | |||
126 | if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK) | ||
127 | GNUNET_SCHEDULER_cancel(sched, curr_get_ctx.retry_task); | ||
119 | } | 128 | } |
120 | 129 | ||
121 | static void | 130 | static void |
122 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | 131 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) |
123 | { | 132 | { |
133 | if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK) | ||
134 | GNUNET_SCHEDULER_cancel(sched, curr_get_ctx.retry_task); | ||
135 | |||
124 | if (curr_get_ctx.get_handle != NULL) | 136 | if (curr_get_ctx.get_handle != NULL) |
125 | { | 137 | { |
126 | GNUNET_DHT_get_stop(curr_get_ctx.get_handle, &end_badly_cont, NULL); | 138 | GNUNET_DHT_get_stop(curr_get_ctx.get_handle, &end_badly_cont, NULL); |
@@ -152,6 +164,7 @@ void get_result_iterator (void *cls, | |||
152 | const void *data) | 164 | const void *data) |
153 | { | 165 | { |
154 | struct PeerGetContext *get_context = cls; | 166 | struct PeerGetContext *get_context = cls; |
167 | |||
155 | if (0 != memcmp(&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode))) | 168 | if (0 != memcmp(&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode))) |
156 | { | 169 | { |
157 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Key returned is not the same key as was searched for!\n"); | 170 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Key returned is not the same key as was searched for!\n"); |
@@ -160,6 +173,12 @@ void get_result_iterator (void *cls, | |||
160 | return; | 173 | return; |
161 | } | 174 | } |
162 | 175 | ||
176 | if (get_context->retry_task != GNUNET_SCHEDULER_NO_TASK) | ||
177 | { | ||
178 | GNUNET_SCHEDULER_cancel(sched, get_context->retry_task); | ||
179 | get_context->retry_task = GNUNET_SCHEDULER_NO_TASK; | ||
180 | } | ||
181 | |||
163 | if (get_context->peer == &peer2id) | 182 | if (get_context->peer == &peer2id) |
164 | { | 183 | { |
165 | get_context->peer = &peer1id; | 184 | get_context->peer = &peer1id; |
@@ -174,7 +193,43 @@ void get_result_iterator (void *cls, | |||
174 | GNUNET_DHT_get_stop(get_context->get_handle, &finish_testing, NULL); | 193 | GNUNET_DHT_get_stop(get_context->get_handle, &finish_testing, NULL); |
175 | } | 194 | } |
176 | 195 | ||
196 | } | ||
197 | |||
198 | static void | ||
199 | stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc); | ||
200 | |||
201 | static void | ||
202 | get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | ||
203 | { | ||
204 | struct PeerGetContext *get_context = cls; | ||
177 | 205 | ||
206 | if (get_context->get_attempts < MAX_GET_ATTEMPTS) | ||
207 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Get attempt %u failed, retrying request!\n", get_context->get_attempts); | ||
208 | else | ||
209 | { | ||
210 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Too many attempts failed, ending test!\n", get_context->get_attempts); | ||
211 | GNUNET_SCHEDULER_cancel(sched, die_task); | ||
212 | GNUNET_SCHEDULER_add_now(sched, &end_badly, "key mismatch in get response!\n"); | ||
213 | return; | ||
214 | } | ||
215 | get_context->get_attempts++; | ||
216 | get_context->retry_task = GNUNET_SCHEDULER_add_delayed(sched, | ||
217 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), | ||
218 | &stop_retry_get, get_context); | ||
219 | get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | ||
220 | 0, &get_context->peer->hashPubKey, &get_result_iterator, get_context, NULL, NULL); | ||
221 | } | ||
222 | |||
223 | static void | ||
224 | stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | ||
225 | { | ||
226 | struct PeerGetContext *get_context = cls; | ||
227 | get_context->retry_task = GNUNET_SCHEDULER_NO_TASK; | ||
228 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Get attempt %u failed, canceling request!\n", get_context->get_attempts); | ||
229 | //if (get_context->get_sent == GNUNET_YES) | ||
230 | GNUNET_DHT_get_stop(get_context->get_handle, &get_stop_finished, get_context); | ||
231 | //else | ||
232 | // GNUNET_SCHEDULER_add_now(sched, &get_stop_finished, get_context); | ||
178 | } | 233 | } |
179 | 234 | ||
180 | static void | 235 | static void |
@@ -182,7 +237,12 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
182 | { | 237 | { |
183 | struct PeerGetContext *get_context = cls; | 238 | struct PeerGetContext *get_context = cls; |
184 | 239 | ||
185 | get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, GNUNET_TIME_relative_get_forever(), 0, &get_context->peer->hashPubKey, &get_result_iterator, get_context, NULL, NULL); | 240 | get_context->retry_task = GNUNET_SCHEDULER_add_delayed(sched, |
241 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), | ||
242 | &stop_retry_get, get_context); | ||
243 | |||
244 | get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | ||
245 | 0, &get_context->peer->hashPubKey, &get_result_iterator, get_context, NULL, NULL); | ||
186 | } | 246 | } |
187 | 247 | ||
188 | 248 | ||
diff --git a/src/dht/test_dht_twopeer_data.conf b/src/dht/test_dht_twopeer_data.conf index ae76b4ddb..06ad96212 100644 --- a/src/dht/test_dht_twopeer_data.conf +++ b/src/dht/test_dht_twopeer_data.conf | |||
@@ -25,7 +25,7 @@ HOSTNAME = localhost | |||
25 | PORT = 12092 | 25 | PORT = 12092 |
26 | 26 | ||
27 | [arm] | 27 | [arm] |
28 | DEFAULTSERVICES = core dht | 28 | DEFAULTSERVICES = dht |
29 | PORT = 12366 | 29 | PORT = 12366 |
30 | DEBUG = NO | 30 | DEBUG = NO |
31 | 31 | ||
diff --git a/src/dht/test_dhtlog_data.conf b/src/dht/test_dhtlog_data.conf index 609a0b383..2cb9af38a 100644 --- a/src/dht/test_dhtlog_data.conf +++ b/src/dht/test_dhtlog_data.conf | |||
@@ -17,7 +17,7 @@ TOTAL_QUOTA_IN = 3932160 | |||
17 | PORT = 12092 | 17 | PORT = 12092 |
18 | 18 | ||
19 | [arm] | 19 | [arm] |
20 | DEFAULTSERVICES = core dht | 20 | DEFAULTSERVICES = dht |
21 | PORT = 12366 | 21 | PORT = 12366 |
22 | DEBUG = NO | 22 | DEBUG = NO |
23 | 23 | ||