aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests/perf_ats.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-21 20:55:20 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-21 20:55:20 +0000
commit61cb58f43e90c66637e395bd852832a49c61794b (patch)
treeb77f80d15302ba74d9a82a9359d9b40a76d82363 /src/ats-tests/perf_ats.c
parent4163470a5d81f09a8b8cdc39e2f6306712633c1c (diff)
downloadgnunet-61cb58f43e90c66637e395bd852832a49c61794b.tar.gz
gnunet-61cb58f43e90c66637e395bd852832a49c61794b.zip
find partner function
fixed crash during shutdown
Diffstat (limited to 'src/ats-tests/perf_ats.c')
-rw-r--r--src/ats-tests/perf_ats.c148
1 files changed, 81 insertions, 67 deletions
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c
index 696d1c186..822666b2f 100644
--- a/src/ats-tests/perf_ats.c
+++ b/src/ats-tests/perf_ats.c
@@ -212,6 +212,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
212 int c_m; 212 int c_m;
213 int c_s; 213 int c_s;
214 int c_op; 214 int c_op;
215 struct BenchmarkPeer *p;
215 216
216 if (GNUNET_YES == logging) 217 if (GNUNET_YES == logging)
217 perf_logging_stop(); 218 perf_logging_stop();
@@ -230,94 +231,90 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
230 231
231 for (c_m = 0; c_m < num_masters; c_m++) 232 for (c_m = 0; c_m < num_masters; c_m++)
232 { 233 {
234 p = &mps[c_m];
233 if (NULL != mps[c_m].peer_id_op) 235 if (NULL != mps[c_m].peer_id_op)
234 { 236 {
235 GNUNET_TESTBED_operation_done (mps[c_m].peer_id_op); 237 GNUNET_TESTBED_operation_done (p->peer_id_op);
236 mps[c_m].peer_id_op = NULL; 238 p->peer_id_op = NULL;
237 } 239 }
238 240
239 if (GNUNET_SCHEDULER_NO_TASK != mps[c_m].ats_task) 241 if (GNUNET_SCHEDULER_NO_TASK != p->ats_task)
240 GNUNET_SCHEDULER_cancel (mps[c_m].ats_task); 242 GNUNET_SCHEDULER_cancel (p->ats_task);
241 mps[c_m].ats_task = GNUNET_SCHEDULER_NO_TASK; 243 p->ats_task = GNUNET_SCHEDULER_NO_TASK;
242 244
243 for (c_op = 0; c_op < num_slaves; c_op++) 245 for (c_op = 0; c_op < p->num_partners; c_op++)
244 { 246 {
245 247 if (NULL != p->partners[c_op].cth)
246 if (NULL != mps[c_m].partners[c_op].cth)
247 { 248 {
248 GNUNET_CORE_notify_transmit_ready_cancel (mps[c_m].partners[c_op].cth); 249 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
249 mps[c_m].partners[c_op].cth = NULL; 250 p->partners[c_op].cth = NULL;
250 } 251 }
251 if (NULL != mps[c_m].partners[c_op].tth) 252 if (NULL != p->partners[c_op].tth)
252 { 253 {
253 GNUNET_TRANSPORT_notify_transmit_ready_cancel (mps[c_m].partners[c_op].tth); 254 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
254 mps[c_m].partners[c_op].tth = NULL; 255 p->partners[c_op].tth = NULL;
255 } 256 }
256 257 if (NULL != p->core_connect_ops[c_op].connect_op)
257
258 if (NULL != mps[c_m].core_connect_ops[c_op].connect_op)
259 { 258 {
260 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 259 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
261 _("Failed to connect peer 0 and %u\n"), c_op); 260 _("Failed to connect peer 0 and %u\n"), c_op);
262 GNUNET_TESTBED_operation_done ( 261 GNUNET_TESTBED_operation_done (
263 mps[c_m].core_connect_ops[c_op].connect_op); 262 p->core_connect_ops[c_op].connect_op);
264 mps[c_m].core_connect_ops[c_op].connect_op = NULL; 263 p->core_connect_ops[c_op].connect_op = NULL;
265 result = 1; 264 result = 1;
266 } 265 }
267 } 266 }
268 267
269 if (NULL != mps[c_m].ats_perf_op) 268 if (NULL != p->ats_perf_op)
270 { 269 {
271 GNUNET_TESTBED_operation_done (mps[c_m].ats_perf_op); 270 GNUNET_TESTBED_operation_done (p->ats_perf_op);
272 mps[c_m].ats_perf_op = NULL; 271 p->ats_perf_op = NULL;
273 } 272 }
274 273
275 if (NULL != mps[c_m].comm_op) 274 if (NULL != p->comm_op)
276 { 275 {
277 GNUNET_TESTBED_operation_done (mps[c_m].comm_op); 276 GNUNET_TESTBED_operation_done (p->comm_op);
278 mps[c_m].comm_op = NULL; 277 p->comm_op = NULL;
279 } 278 }
280 GNUNET_free(mps[c_m].core_connect_ops); 279 GNUNET_free(p->core_connect_ops);
281 GNUNET_free(mps[c_m].partners); 280 GNUNET_free(p->partners);
282 mps[c_m].partners = NULL; 281 p->partners = NULL;
283 } 282 }
284 283
285 for (c_s = 0; c_s < num_slaves; c_s++) 284 for (c_s = 0; c_s < num_slaves; c_s++)
286 { 285 {
287 if (NULL != sps[c_s].peer_id_op) 286 p = &sps[c_s];
287 if (NULL != p->peer_id_op)
288 { 288 {
289 GNUNET_TESTBED_operation_done (sps[c_s].peer_id_op); 289 GNUNET_TESTBED_operation_done (p->peer_id_op);
290 sps[c_s].peer_id_op = NULL; 290 p->peer_id_op = NULL;
291 } 291 }
292 292
293 for (c_op = 0; c_op < num_slaves; c_op++) 293 for (c_op = 0; c_op < p->num_partners; c_op++)
294 { 294 {
295 if (NULL != sps[c_s].partners[c_op].cth) 295 if (NULL != p->partners[c_op].cth)
296 { 296 {
297 GNUNET_CORE_notify_transmit_ready_cancel (sps[c_s].partners[c_op].cth); 297 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
298 sps[c_s].partners[c_op].cth = NULL; 298 p->partners[c_op].cth = NULL;
299 } 299 }
300 300 if (NULL != p->partners[c_op].tth)
301 if (NULL != sps[c_s].partners[c_op].tth)
302 { 301 {
303 GNUNET_TRANSPORT_notify_transmit_ready_cancel (sps[c_s].partners[c_op].tth); 302 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
304 sps[c_s].partners[c_op].tth = NULL; 303 p->partners[c_op].tth = NULL;
305 } 304 }
306 } 305 }
307 306 if (NULL != p->ats_perf_op)
308 if (NULL != sps[c_s].ats_perf_op)
309 { 307 {
310 GNUNET_TESTBED_operation_done (sps[c_s].ats_perf_op); 308 GNUNET_TESTBED_operation_done (p->ats_perf_op);
311 sps[c_s].ats_perf_op = NULL; 309 p->ats_perf_op = NULL;
312 } 310 }
313 if (NULL != sps[c_s].comm_op) 311 if (NULL != p->comm_op)
314 { 312 {
315 GNUNET_TESTBED_operation_done (sps[c_s].comm_op); 313 GNUNET_TESTBED_operation_done (p->comm_op);
316 sps[c_s].comm_op = NULL; 314 p->comm_op = NULL;
317 } 315 }
318 316 GNUNET_free(p->partners);
319 GNUNET_free(sps[c_s].partners); 317 p->partners = NULL;
320 sps[c_s].partners = NULL;
321 } 318 }
322 319
323 GNUNET_SCHEDULER_shutdown (); 320 GNUNET_SCHEDULER_shutdown ();
@@ -628,19 +625,35 @@ comm_connect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
628 GNUNET_free(id); 625 GNUNET_free(id);
629} 626}
630 627
628static struct BenchmarkPartner *
629find_partner (struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity * peer)
630{
631 int c_m;
632 GNUNET_assert (NULL != me);
633 GNUNET_assert (NULL != peer);
634
635 for (c_m = 0; c_m < me->num_partners; c_m++)
636 {
637 /* Find a partner with other as destination */
638 if (0 == memcmp (peer, &me->partners[c_m].dest->id,
639 sizeof(struct GNUNET_PeerIdentity)))
640 {
641 return &me->partners[c_m];
642 }
643 }
644
645 return NULL;
646}
647
631static void 648static void
632comm_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity * peer) 649comm_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
633{ 650{
634 struct BenchmarkPeer *me = cls; 651 struct BenchmarkPeer *me = cls;
635 struct BenchmarkPeer *remote; 652 struct BenchmarkPartner *p;
636 char *id; 653 char *id;
637 654
638 remote = find_peer (peer); 655 if (NULL == (p = find_partner (me, peer)))
639 if (NULL == remote)
640 {
641 GNUNET_break(0);
642 return; 656 return;
643 }
644 657
645 id = GNUNET_strdup (GNUNET_i2s (&me->id)); 658 id = GNUNET_strdup (GNUNET_i2s (&me->id));
646 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s disconnected from %s \n", id, 659 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s disconnected from %s \n", id,
@@ -649,10 +662,20 @@ comm_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
649 me->core_connections--; 662 me->core_connections--;
650 663
651 if ((GNUNET_YES == state.benchmarking) 664 if ((GNUNET_YES == state.benchmarking)
652 && ((GNUNET_YES == me->master) || (GNUNET_YES == remote->master))) 665 && ((GNUNET_YES == me->master) || (GNUNET_YES == p->dest->master)))
653 { 666 {
654 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 667 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
655 "%s disconnected from %s while benchmarking \n", id, GNUNET_i2s (peer)); 668 "%s disconnected from %s while benchmarking \n", id, GNUNET_i2s (peer));
669 if (NULL != p->tth)
670 {
671 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->tth);
672 p->tth = NULL;
673 }
674 if (NULL != p->cth)
675 {
676 GNUNET_CORE_notify_transmit_ready_cancel (p->cth);
677 p->cth = NULL;
678 }
656 } 679 }
657 GNUNET_free(id); 680 GNUNET_free(id);
658} 681}
@@ -687,20 +710,11 @@ static int
687comm_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other, 710comm_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other,
688 const struct GNUNET_MessageHeader *message) 711 const struct GNUNET_MessageHeader *message)
689{ 712{
690 int c_m; 713
691 struct BenchmarkPeer *me = cls; 714 struct BenchmarkPeer *me = cls;
692 struct BenchmarkPartner *p = NULL; 715 struct BenchmarkPartner *p = NULL;
693 for (c_m = 0; c_m < num_masters; c_m++) 716
694 { 717 if (NULL == (p = find_partner(me, other)))
695 /* Find a partner with other as destination */
696 if (0 == memcmp (other, &me->partners[c_m].dest->id,
697 sizeof(struct GNUNET_PeerIdentity)))
698 {
699 p = &me->partners[c_m];
700 break;
701 }
702 }
703 if (NULL == p)
704 { 718 {
705 GNUNET_break(0); 719 GNUNET_break(0);
706 return GNUNET_SYSERR; 720 return GNUNET_SYSERR;