diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-06-17 15:39:23 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-06-17 15:39:23 +0000 |
commit | ce4ebee5643eeff8ba5888247205bb8426ccf362 (patch) | |
tree | 24c9a4713e4ca4e7dd2c73340f9185c9f37f8bfa /src | |
parent | b90fdb9329d445cb2829205cc134b06689f1fe7b (diff) | |
download | gnunet-ce4ebee5643eeff8ba5888247205bb8426ccf362.tar.gz gnunet-ce4ebee5643eeff8ba5888247205bb8426ccf362.zip |
more error checks
Diffstat (limited to 'src')
-rw-r--r-- | src/core/core_api.c | 27 | ||||
-rw-r--r-- | src/core/gnunet-service-core.c | 1 | ||||
-rw-r--r-- | src/core/test_core_api_preferences.c | 48 |
3 files changed, 54 insertions, 22 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index 5b90a11ed..af46c6e63 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -417,17 +417,6 @@ disconnect_and_free_peer_entry (void *cls, | |||
417 | GNUNET_CORE_PeerConfigurationInfoCallback pcic; | 417 | GNUNET_CORE_PeerConfigurationInfoCallback pcic; |
418 | void *pcic_cls; | 418 | void *pcic_cls; |
419 | 419 | ||
420 | if (NULL != (pcic = pr->pcic)) | ||
421 | { | ||
422 | pcic_cls = pr->pcic_cls; | ||
423 | GNUNET_CORE_peer_change_preference_cancel (pr->pcic_ptr); | ||
424 | pcic (pcic_cls, | ||
425 | &pr->peer, | ||
426 | zero, | ||
427 | 0, | ||
428 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
429 | 0); | ||
430 | } | ||
431 | if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 420 | if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
432 | { | 421 | { |
433 | GNUNET_SCHEDULER_cancel (pr->timeout_task); | 422 | GNUNET_SCHEDULER_cancel (pr->timeout_task); |
@@ -449,6 +438,18 @@ disconnect_and_free_peer_entry (void *cls, | |||
449 | &pr->peer); | 438 | &pr->peer); |
450 | /* all requests should have been cancelled, clean up anyway, just in case */ | 439 | /* all requests should have been cancelled, clean up anyway, just in case */ |
451 | GNUNET_break (pr->queue_size == 0); | 440 | GNUNET_break (pr->queue_size == 0); |
441 | if (NULL != (pcic = pr->pcic)) | ||
442 | { | ||
443 | GNUNET_break (0); | ||
444 | pcic_cls = pr->pcic_cls; | ||
445 | GNUNET_CORE_peer_change_preference_cancel (pr->pcic_ptr); | ||
446 | pcic (pcic_cls, | ||
447 | &pr->peer, | ||
448 | zero, | ||
449 | 0, | ||
450 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
451 | 0); | ||
452 | } | ||
452 | while (NULL != (th = pr->pending_head)) | 453 | while (NULL != (th = pr->pending_head)) |
453 | { | 454 | { |
454 | GNUNET_break (0); | 455 | GNUNET_break (0); |
@@ -460,6 +461,7 @@ disconnect_and_free_peer_entry (void *cls, | |||
460 | th->cm->th = NULL; | 461 | th->cm->th = NULL; |
461 | GNUNET_free (th); | 462 | GNUNET_free (th); |
462 | } | 463 | } |
464 | /* done with 'voluntary' cleanups, now on to normal freeing */ | ||
463 | GNUNET_assert (GNUNET_YES == | 465 | GNUNET_assert (GNUNET_YES == |
464 | GNUNET_CONTAINER_multihashmap_remove (h->peers, | 466 | GNUNET_CONTAINER_multihashmap_remove (h->peers, |
465 | key, | 467 | key, |
@@ -1512,6 +1514,7 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle) | |||
1512 | handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | 1514 | handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; |
1513 | } | 1515 | } |
1514 | GNUNET_CONTAINER_multihashmap_destroy (handle->peers); | 1516 | GNUNET_CONTAINER_multihashmap_destroy (handle->peers); |
1517 | handle->peers = NULL; | ||
1515 | GNUNET_break (handle->ready_peer_head == NULL); | 1518 | GNUNET_break (handle->ready_peer_head == NULL); |
1516 | GNUNET_free (handle); | 1519 | GNUNET_free (handle); |
1517 | } | 1520 | } |
@@ -1942,7 +1945,7 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h, | |||
1942 | if (NULL == pr) | 1945 | if (NULL == pr) |
1943 | { | 1946 | { |
1944 | /* attempt to change preference on peer that is not connected */ | 1947 | /* attempt to change preference on peer that is not connected */ |
1945 | GNUNET_break (0); | 1948 | GNUNET_assert (0); |
1946 | return NULL; | 1949 | return NULL; |
1947 | } | 1950 | } |
1948 | if (pr->pcic != NULL) | 1951 | if (pr->pcic != NULL) |
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 1b0a93d6a..7a444847c 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -3883,6 +3883,7 @@ send_p2p_message_to_client (struct Neighbour *sender, | |||
3883 | struct NotifyTrafficMessage *ntm; | 3883 | struct NotifyTrafficMessage *ntm; |
3884 | struct GNUNET_TRANSPORT_ATS_Information *ats; | 3884 | struct GNUNET_TRANSPORT_ATS_Information *ats; |
3885 | 3885 | ||
3886 | GNUNET_assert (GNUNET_YES == sender->is_connected); | ||
3886 | if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 3887 | if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
3887 | { | 3888 | { |
3888 | GNUNET_break (0); | 3889 | GNUNET_break (0); |
diff --git a/src/core/test_core_api_preferences.c b/src/core/test_core_api_preferences.c index b0b23776f..c725543b0 100644 --- a/src/core/test_core_api_preferences.c +++ b/src/core/test_core_api_preferences.c | |||
@@ -66,6 +66,8 @@ static int ok; | |||
66 | 66 | ||
67 | static struct GNUNET_CORE_InformationRequestContext *irc; | 67 | static struct GNUNET_CORE_InformationRequestContext *irc; |
68 | 68 | ||
69 | static struct GNUNET_CORE_TransmitHandle *th; | ||
70 | |||
69 | static GNUNET_SCHEDULER_TaskIdentifier irc_task; | 71 | static GNUNET_SCHEDULER_TaskIdentifier irc_task; |
70 | 72 | ||
71 | static GNUNET_SCHEDULER_TaskIdentifier ask_task; | 73 | static GNUNET_SCHEDULER_TaskIdentifier ask_task; |
@@ -99,9 +101,15 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
99 | #endif | 101 | #endif |
100 | GNUNET_break (0); | 102 | GNUNET_break (0); |
101 | if (NULL != irc) | 103 | if (NULL != irc) |
102 | GNUNET_CORE_peer_change_preference_cancel (irc); | 104 | { |
105 | GNUNET_CORE_peer_change_preference_cancel (irc); | ||
106 | irc = NULL; | ||
107 | } | ||
103 | if (GNUNET_SCHEDULER_NO_TASK != irc_task) | 108 | if (GNUNET_SCHEDULER_NO_TASK != irc_task) |
104 | GNUNET_SCHEDULER_cancel (irc_task); | 109 | { |
110 | GNUNET_SCHEDULER_cancel (irc_task); | ||
111 | irc_task = GNUNET_SCHEDULER_NO_TASK; | ||
112 | } | ||
105 | if (GNUNET_SCHEDULER_NO_TASK != ask_task) | 113 | if (GNUNET_SCHEDULER_NO_TASK != ask_task) |
106 | { | 114 | { |
107 | GNUNET_SCHEDULER_cancel (ask_task); | 115 | GNUNET_SCHEDULER_cancel (ask_task); |
@@ -121,6 +129,7 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
121 | struct PeerContext *p = cls; | 129 | struct PeerContext *p = cls; |
122 | struct GNUNET_MessageHeader *m; | 130 | struct GNUNET_MessageHeader *m; |
123 | 131 | ||
132 | th = NULL; | ||
124 | GNUNET_assert (ok == 4); | 133 | GNUNET_assert (ok == 4); |
125 | OKPP; | 134 | OKPP; |
126 | GNUNET_assert (p == &p1); | 135 | GNUNET_assert (p == &p1); |
@@ -203,13 +212,13 @@ preference_cb (void *cls, | |||
203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
204 | "Asking core (1) for transmission to peer `%4s'\n", | 213 | "Asking core (1) for transmission to peer `%4s'\n", |
205 | GNUNET_i2s (&p2.id)); | 214 | GNUNET_i2s (&p2.id)); |
206 | if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch, | 215 | if (NULL == (th = GNUNET_CORE_notify_transmit_ready (p1.ch, |
207 | GNUNET_YES, | 216 | GNUNET_YES, |
208 | 0, | 217 | 0, |
209 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45), | 218 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45), |
210 | &p2.id, | 219 | &p2.id, |
211 | sizeof (struct GNUNET_MessageHeader), | 220 | sizeof (struct GNUNET_MessageHeader), |
212 | &transmit_ready, &p1)) | 221 | &transmit_ready, &p1))) |
213 | { | 222 | { |
214 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
215 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | 224 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", |
@@ -261,8 +270,27 @@ disconnect_notify (void *cls, | |||
261 | sizeof (struct GNUNET_PeerIdentity))) | 270 | sizeof (struct GNUNET_PeerIdentity))) |
262 | return; | 271 | return; |
263 | pc->connect_status = 0; | 272 | pc->connect_status = 0; |
273 | if (GNUNET_SCHEDULER_NO_TASK != irc_task) | ||
274 | { | ||
275 | GNUNET_SCHEDULER_cancel (irc_task); | ||
276 | irc_task = GNUNET_SCHEDULER_NO_TASK; | ||
277 | } | ||
278 | if (0 == memcmp (peer, &p1.id, sizeof (struct GNUNET_PeerIdentity))) | ||
279 | { | ||
280 | if (irc != NULL) | ||
281 | { | ||
282 | GNUNET_CORE_peer_change_preference_cancel (irc); | ||
283 | irc = NULL; | ||
284 | } | ||
285 | if (th != NULL) | ||
286 | { | ||
287 | GNUNET_CORE_notify_transmit_ready_cancel (th); | ||
288 | th = NULL; | ||
289 | } | ||
290 | } | ||
264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
265 | "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); | 292 | "Encrypted connection to `%4s' cut\n", |
293 | GNUNET_i2s (peer)); | ||
266 | } | 294 | } |
267 | 295 | ||
268 | 296 | ||