diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-25 19:30:46 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-25 19:30:46 +0000 |
commit | 0a1d08331fda73bad092dc93b3cafea99eb310a0 (patch) | |
tree | daff25049c7e0c34e938cd8faa0c3b61be866724 | |
parent | 703f79ac9ec77195dcfbf957da8622ff0ca324c3 (diff) | |
download | gnunet-0a1d08331fda73bad092dc93b3cafea99eb310a0.tar.gz gnunet-0a1d08331fda73bad092dc93b3cafea99eb310a0.zip |
handle mq being NULL
-rw-r--r-- | src/ats/ats_api_scheduling.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 9e65c3fb0..b1ceb4083 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -584,7 +584,8 @@ send_add_address_message (struct GNUNET_ATS_SchedulingHandle *sh, | |||
584 | * @param cls the `struct GNUNET_ATS_SchedulingHandle` | 584 | * @param cls the `struct GNUNET_ATS_SchedulingHandle` |
585 | * @param peer peer to ask for an address suggestion for | 585 | * @param peer peer to ask for an address suggestion for |
586 | * @param value the `struct GNUNET_ATS_SuggestHandle` | 586 | * @param value the `struct GNUNET_ATS_SuggestHandle` |
587 | * @return #GNUNET_OK (continue to iterate) | 587 | * @return #GNUNET_OK (continue to iterate), #GNUNET_SYSERR on |
588 | * failure (message queue no longer exists) | ||
588 | */ | 589 | */ |
589 | static int | 590 | static int |
590 | transmit_suggestion (void *cls, | 591 | transmit_suggestion (void *cls, |
@@ -595,6 +596,8 @@ transmit_suggestion (void *cls, | |||
595 | struct GNUNET_MQ_Envelope *ev; | 596 | struct GNUNET_MQ_Envelope *ev; |
596 | struct RequestAddressMessage *m; | 597 | struct RequestAddressMessage *m; |
597 | 598 | ||
599 | if (NULL == sh->mq) | ||
600 | return GNUNET_SYSERR; | ||
598 | ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS); | 601 | ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS); |
599 | m->reserved = htonl (0); | 602 | m->reserved = htonl (0); |
600 | m->peer = *peer; | 603 | m->peer = *peer; |
@@ -662,6 +665,8 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh) | |||
662 | GNUNET_MESSAGE_TYPE_ATS_START); | 665 | GNUNET_MESSAGE_TYPE_ATS_START); |
663 | init->start_flag = htonl (START_FLAG_SCHEDULING); | 666 | init->start_flag = htonl (START_FLAG_SCHEDULING); |
664 | GNUNET_MQ_send (sh->mq, ev); | 667 | GNUNET_MQ_send (sh->mq, ev); |
668 | if (NULL == sh->mq) | ||
669 | return; | ||
665 | for (i=0;i<sh->session_array_size;i++) | 670 | for (i=0;i<sh->session_array_size;i++) |
666 | { | 671 | { |
667 | ar = sh->session_array[i]; | 672 | ar = sh->session_array[i]; |
@@ -670,6 +675,8 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh) | |||
670 | send_add_address_message (sh, ar); | 675 | send_add_address_message (sh, ar); |
671 | if (ar->in_use) | 676 | if (ar->in_use) |
672 | send_in_use_message (ar, GNUNET_YES); | 677 | send_in_use_message (ar, GNUNET_YES); |
678 | if (NULL == sh->mq) | ||
679 | return; | ||
673 | } | 680 | } |
674 | GNUNET_CONTAINER_multipeermap_iterate (sh->sug_requests, | 681 | GNUNET_CONTAINER_multipeermap_iterate (sh->sug_requests, |
675 | &transmit_suggestion, | 682 | &transmit_suggestion, |
@@ -1344,6 +1351,12 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, | |||
1344 | struct GNUNET_ATS_Information *am; | 1351 | struct GNUNET_ATS_Information *am; |
1345 | size_t msize; | 1352 | size_t msize; |
1346 | 1353 | ||
1354 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1355 | "Adding address for peer `%s', plugin `%s', session %p id %u\n", | ||
1356 | GNUNET_i2s (&ar->address->peer), | ||
1357 | ar->address->transport_name, | ||
1358 | ar->session, | ||
1359 | ar->slot); | ||
1347 | GNUNET_array_grow (ar->ats, | 1360 | GNUNET_array_grow (ar->ats, |
1348 | ar->ats_count, | 1361 | ar->ats_count, |
1349 | ats_count); | 1362 | ats_count); |
@@ -1351,22 +1364,13 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, | |||
1351 | ats, | 1364 | ats, |
1352 | ats_count * sizeof (struct GNUNET_ATS_Information)); | 1365 | ats_count * sizeof (struct GNUNET_ATS_Information)); |
1353 | 1366 | ||
1354 | |||
1355 | if (NULL == sh->mq) | 1367 | if (NULL == sh->mq) |
1356 | return; /* disconnected, skip for now */ | 1368 | return; /* disconnected, skip for now */ |
1357 | msize = ar->ats_count * sizeof (struct GNUNET_ATS_Information); | 1369 | msize = ar->ats_count * sizeof (struct GNUNET_ATS_Information); |
1358 | |||
1359 | ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE); | 1370 | ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE); |
1360 | m->ats_count = htonl (ar->ats_count); | 1371 | m->ats_count = htonl (ar->ats_count); |
1361 | m->peer = ar->address->peer; | 1372 | m->peer = ar->address->peer; |
1362 | m->session_id = htonl (ar->slot); | 1373 | m->session_id = htonl (ar->slot); |
1363 | |||
1364 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1365 | "Adding address for peer `%s', plugin `%s', session %p id %u\n", | ||
1366 | GNUNET_i2s (&ar->address->peer), | ||
1367 | ar->address->transport_name, | ||
1368 | ar->session, | ||
1369 | ar->slot); | ||
1370 | am = (struct GNUNET_ATS_Information *) &m[1]; | 1374 | am = (struct GNUNET_ATS_Information *) &m[1]; |
1371 | memcpy (am, | 1375 | memcpy (am, |
1372 | ar->ats, | 1376 | ar->ats, |
@@ -1393,6 +1397,8 @@ GNUNET_ATS_address_set_in_use (struct GNUNET_ATS_AddressRecord *ar, | |||
1393 | ar->address->transport_name, | 1397 | ar->address->transport_name, |
1394 | ar->session); | 1398 | ar->session); |
1395 | ar->in_use = in_use; | 1399 | ar->in_use = in_use; |
1400 | if (NULL == ar->sh->mq) | ||
1401 | return; | ||
1396 | send_in_use_message (ar, in_use); | 1402 | send_in_use_message (ar, in_use); |
1397 | } | 1403 | } |
1398 | 1404 | ||
@@ -1409,21 +1415,23 @@ GNUNET_ATS_address_destroy (struct GNUNET_ATS_AddressRecord *ar) | |||
1409 | struct GNUNET_MQ_Envelope *ev; | 1415 | struct GNUNET_MQ_Envelope *ev; |
1410 | struct AddressDestroyedMessage *m; | 1416 | struct AddressDestroyedMessage *m; |
1411 | 1417 | ||
1412 | GNUNET_break (NULL == ar->session); | ||
1413 | ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED); | ||
1414 | m->session_id = htonl (ar->slot); | ||
1415 | m->peer = ar->address->peer; | ||
1416 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1417 | "Deleting address for peer `%s', plugin `%s', session %p\n", | 1419 | "Deleting address for peer `%s', plugin `%s', session %p\n", |
1418 | GNUNET_i2s (&ar->address->peer), | 1420 | GNUNET_i2s (&ar->address->peer), |
1419 | ar->address->transport_name, | 1421 | ar->address->transport_name, |
1420 | ar->session); | 1422 | ar->session); |
1421 | GNUNET_MQ_send (sh->mq, ev); | 1423 | GNUNET_break (NULL == ar->session); |
1422 | ar->session = NULL; | 1424 | ar->session = NULL; |
1423 | ar->in_destroy = GNUNET_YES; | 1425 | ar->in_destroy = GNUNET_YES; |
1424 | GNUNET_array_grow (ar->ats, | 1426 | GNUNET_array_grow (ar->ats, |
1425 | ar->ats_count, | 1427 | ar->ats_count, |
1426 | 0); | 1428 | 0); |
1429 | if (NULL == sh->mq) | ||
1430 | return; | ||
1431 | ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED); | ||
1432 | m->session_id = htonl (ar->slot); | ||
1433 | m->peer = ar->address->peer; | ||
1434 | GNUNET_MQ_send (sh->mq, ev); | ||
1427 | } | 1435 | } |
1428 | 1436 | ||
1429 | 1437 | ||