gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated: fix #4985


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: fix #4985
Date: Tue, 11 Apr 2017 11:38:26 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 51e9f26b1 fix #4985
51e9f26b1 is described below

commit 51e9f26b1014d6f935cacad7da75d98234653482
Author: Christian Grothoff <address@hidden>
AuthorDate: Tue Apr 11 11:37:46 2017 +0200

    fix #4985
---
 src/cadet/cadet_api.c                          | 16 ++++++++++------
 src/conversation/gnunet-service-conversation.c |  8 ++++++++
 src/include/gnunet_cadet_service.h             |  2 +-
 src/include/gnunet_disk_lib.h                  |  3 ++-
 src/util/strings.c                             |  1 +
 5 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index decf473a9..3fdeffe13 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);
diff --git a/src/conversation/gnunet-service-conversation.c 
b/src/conversation/gnunet-service-conversation.c
index 5f43bfe80..7d319e51e 100644
--- a/src/conversation/gnunet-service-conversation.c
+++ b/src/conversation/gnunet-service-conversation.c
@@ -1270,6 +1270,14 @@ handle_client_register_message (void *cls,
                                        NULL,
                                        &inbound_end,
                                        cadet_handlers);
+  if (NULL == line->port)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                _("Could not open line, port %s already in use!\n"),
+                GNUNET_h2s (&msg->line_port));
+    GNUNET_SERVICE_client_drop (line->client);
+    return;
+  }
   GNUNET_SERVICE_client_continue (line->client);
 }
 
diff --git a/src/include/gnunet_cadet_service.h 
b/src/include/gnunet_cadet_service.h
index f76f17a51..e2edbcc2c 100644
--- a/src/include/gnunet_cadet_service.h
+++ b/src/include/gnunet_cadet_service.h
@@ -221,7 +221,7 @@ GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle 
*handle);
  *                       Can be NULL.
  * @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,
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h
index 02c4b3674..be2885460 100644
--- a/src/include/gnunet_disk_lib.h
+++ b/src/include/gnunet_disk_lib.h
@@ -331,7 +331,8 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle 
*h, off_t offset,
  * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
  */
 int
-GNUNET_DISK_file_size (const char *filename, uint64_t *size,
+GNUNET_DISK_file_size (const char *filename,
+                       uint64_t *size,
                        int include_symbolic_links,
                        int single_file_mode);
 
diff --git a/src/util/strings.c b/src/util/strings.c
index d3268f4d9..f554a9e83 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -818,6 +818,7 @@ GNUNET_STRINGS_get_short_name (const char *filename)
 {
   const char *short_fn = filename;
   const char *ss;
+
   while (NULL != (ss = strstr (short_fn, DIR_SEPARATOR_STR))
       && (ss[1] != '\0'))
     short_fn = 1 + ss;

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]