From 0c1c5a9be5e6cd117736a569e60ae79c739c56ef Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Sun, 30 Sep 2012 15:11:39 +0000 Subject: [PATCH] more fixes for #2570 --- src/stream/perf_stream_api.c | 9 +++++++++ src/stream/test_stream_2peers.c | 9 ++++++++- src/stream/test_stream_2peers_halfclose.c | 12 ++++++++---- src/stream/test_stream_big.c | 8 ++++++++ src/stream/test_stream_local.c | 8 ++++++++ src/stream/test_stream_sequence_wraparound.c | 8 ++++++++ 6 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/stream/perf_stream_api.c b/src/stream/perf_stream_api.c index 3dbdda256..e7e37792a 100644 --- a/src/stream/perf_stream_api.c +++ b/src/stream/perf_stream_api.c @@ -588,6 +588,15 @@ stream_listen_cb (void *cls, struct GNUNET_STREAM_Socket *socket, { struct PeerData *pdata = cls; + + if ((NULL == socket) || (NULL == initiator)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Binding error\n"); + if (GNUNET_SCHEDULER_NO_TASK != abort_task) + GNUNET_SCHEDULER_cancel (abort_task); + abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); + return GNUNET_OK; + } GNUNET_assert (NULL != socket); GNUNET_assert (pdata == &peer_data[1]); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer connected: %s\n", diff --git a/src/stream/test_stream_2peers.c b/src/stream/test_stream_2peers.c index 86d1a84ad..c517cc2b1 100644 --- a/src/stream/test_stream_2peers.c +++ b/src/stream/test_stream_2peers.c @@ -427,7 +427,14 @@ stream_listen_cb (void *cls, struct GNUNET_STREAM_Socket *socket, const struct GNUNET_PeerIdentity *initiator) { - GNUNET_assert (NULL != socket); + if ((NULL == socket) || (NULL == initiator)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Binding error\n"); + if (GNUNET_SCHEDULER_NO_TASK != abort_task) + GNUNET_SCHEDULER_cancel (abort_task); + abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); + return GNUNET_OK; + } GNUNET_assert (NULL != initiator); GNUNET_assert (socket != peer2.socket); GNUNET_assert (0 == memcmp (initiator, &peer2.our_id, diff --git a/src/stream/test_stream_2peers_halfclose.c b/src/stream/test_stream_2peers_halfclose.c index 2d14acfe3..2502615c2 100644 --- a/src/stream/test_stream_2peers_halfclose.c +++ b/src/stream/test_stream_2peers_halfclose.c @@ -661,15 +661,19 @@ stream_listen_cb (void *cls, struct GNUNET_STREAM_Socket *socket, const struct GNUNET_PeerIdentity *initiator) { - GNUNET_assert (NULL != socket); - GNUNET_assert (NULL != initiator); + if ((NULL == socket) || (NULL == initiator)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Binding error\n"); + if (GNUNET_SCHEDULER_NO_TASK != abort_task) + GNUNET_SCHEDULER_cancel (abort_task); + abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); + return GNUNET_OK; + } GNUNET_assert (socket != peer1.socket); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s: Peer connected: %s\n", GNUNET_i2s (&peer2.our_id), GNUNET_i2s(initiator)); - peer2.socket = socket; /* FIXME: reading should be done right now instead of a scheduled call */ read_task = GNUNET_SCHEDULER_add_now (&stream_read, (void *) socket); diff --git a/src/stream/test_stream_big.c b/src/stream/test_stream_big.c index 19c7e571a..05da82691 100644 --- a/src/stream/test_stream_big.c +++ b/src/stream/test_stream_big.c @@ -302,6 +302,14 @@ stream_listen_cb (void *cls, struct GNUNET_STREAM_Socket *socket, const struct GNUNET_PeerIdentity *initiator) { + if ((NULL == socket) || (NULL == initiator)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Binding error\n"); + if (GNUNET_SCHEDULER_NO_TASK != abort_task) + GNUNET_SCHEDULER_cancel (abort_task); + abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); + return GNUNET_OK; + } GNUNET_assert (NULL != socket); GNUNET_assert (socket != peer1.socket); diff --git a/src/stream/test_stream_local.c b/src/stream/test_stream_local.c index 699bc8032..3286ade5f 100644 --- a/src/stream/test_stream_local.c +++ b/src/stream/test_stream_local.c @@ -320,6 +320,14 @@ stream_listen_cb (void *cls, { struct PeerData *peer=cls; + if ((NULL == socket) || (NULL == initiator)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Binding error\n"); + if (GNUNET_SCHEDULER_NO_TASK != abort_task) + GNUNET_SCHEDULER_cancel (abort_task); + abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); + return GNUNET_OK; + } GNUNET_assert (NULL != socket); GNUNET_assert (socket != peer1.socket); GNUNET_assert (&peer2 == peer); diff --git a/src/stream/test_stream_sequence_wraparound.c b/src/stream/test_stream_sequence_wraparound.c index 8f35a41d3..f23171661 100644 --- a/src/stream/test_stream_sequence_wraparound.c +++ b/src/stream/test_stream_sequence_wraparound.c @@ -302,6 +302,14 @@ stream_listen_cb (void *cls, struct GNUNET_STREAM_Socket *socket, const struct GNUNET_PeerIdentity *initiator) { + if ((NULL == socket) || (NULL == initiator)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Binding error\n"); + if (GNUNET_SCHEDULER_NO_TASK != abort_task) + GNUNET_SCHEDULER_cancel (abort_task); + abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); + return GNUNET_OK; + } GNUNET_assert (NULL != socket); GNUNET_assert (socket != peer1.socket); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, -- 2.25.1