diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-04-11 11:37:46 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-04-11 11:37:46 +0200 |
commit | 51e9f26b1014d6f935cacad7da75d98234653482 (patch) | |
tree | ecbd7394cfd571c8041767287ea17e7cb862f1ca /src/cadet/cadet_api.c | |
parent | 2b3d804abaff87da0b07f8f6da115a05f6664ebe (diff) |
fix #4985
Diffstat (limited to 'src/cadet/cadet_api.c')
-rw-r--r-- | src/cadet/cadet_api.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index decf473a9c..3fdeffe130 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c @@ -1583,7 +1583,7 @@ GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) * @param window_changes Function called when the transmit window size changes. * @param disconnects Function called when a channel is disconnected. * @param handlers Callbacks for messages we care about, NULL-terminated. - * @return Port handle. + * @return Port handle, NULL if port is in use */ struct GNUNET_CADET_Port * GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h, @@ -1604,17 +1604,21 @@ GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h, p = GNUNET_new (struct GNUNET_CADET_Port); p->cadet = h; p->id = *port; + if (GNUNET_OK != + GNUNET_CONTAINER_multihashmap_put (h->ports, + &p->id, + p, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) + { + GNUNET_free (p); + return NULL; + } p->connects = connects; p->cls = connects_cls; p->window_changes = window_changes; p->disconnects = disconnects; p->handlers = GNUNET_MQ_copy_handlers (handlers); - GNUNET_assert (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_put (h->ports, - &p->id, - p, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN); |