X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcore_api.c;h=e9a38271bf317cce14072f629e842e521ca4fa6d;hb=9706e822ff61a85bf2353d2c233eb766ffc13323;hp=9001b21d9f0993b0e0802b6e6c0f9114ce7e5ecc;hpb=4d4e195ebed909301f50f6fe6b9523f91f8e453b;p=oweals%2Fgnunet.git diff --git a/src/core/core_api.c b/src/core/core_api.c index 9001b21d9..e9a38271b 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -921,7 +921,7 @@ main_notify_handler (void *cls, &cnm->peer, sizeof (struct GNUNET_PeerIdentity))) { - /* disconnect from self!? */ + /* connect to self!? */ GNUNET_break (0); return; } @@ -1231,7 +1231,13 @@ main_notify_handler (void *cls, return; } if (pr->rim_id != ntohl (cim->rim_id)) - break; + { +#if DEBUG_CORE + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Reservation ID mismatch in notification...\n"); +#endif + break; + } pcic = pr->pcic; pr->pcic = NULL; if (pcic != NULL) @@ -1472,9 +1478,9 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle) /** * Ask the core to call "notify" once it is ready to transmit the - * given number of bytes to the specified "target". If we are not yet - * connected to the specified peer, a call to this function will cause - * us to try to establish a connection. + * given number of bytes to the specified "target". Must only be + * called after a connection to the respective peer has been + * established (and the client has been informed about this). * * @param handle connection to core service * @param priority how important is the message? @@ -1518,6 +1524,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, GNUNET_SERVER_MAX_MESSAGE_SIZE); th = GNUNET_malloc (sizeof (struct GNUNET_CORE_TransmitHandle)); th->peer = pr; + GNUNET_assert(NULL != notify); th->get_message = notify; th->get_message_cls = notify_cls; th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay); @@ -1709,7 +1716,9 @@ peer_request_connect_cont (void *cls, * @param peer who should we connect to * @param cont function to call once the request has been completed (or timed out) * @param cont_cls closure for cont - * @return NULL on error (cont will not be called), otherwise handle for cancellation + * + * @return NULL on error or already connected, + * otherwise handle for cancellation */ struct GNUNET_CORE_PeerRequestHandle * GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h, @@ -1721,6 +1730,11 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_CORE_Handle *h, struct GNUNET_CORE_PeerRequestHandle *ret; struct ControlMessage *cm; struct ConnectMessage *msg; + + if (NULL != GNUNET_CONTAINER_multihashmap_get (h->peers, + &peer->hashPubKey)) + return NULL; /* Already connected, means callback should have happened already! */ + cm = GNUNET_malloc (sizeof (struct ControlMessage) + sizeof (struct ConnectMessage));