use assert to guard better against double-close on client side
authorChristian Grothoff <christian@grothoff.org>
Sat, 13 Jan 2018 13:47:16 +0000 (14:47 +0100)
committerChristian Grothoff <christian@grothoff.org>
Sat, 13 Jan 2018 13:47:16 +0000 (14:47 +0100)
src/cadet/cadet_api.c

index 6b07ab7b721edba48f8c8156ee20b69791e8918c..3c142a95c69f2f5a2e79e5c282aca6b52ce584c9 100644 (file)
@@ -1276,15 +1276,15 @@ GNUNET_CADET_close_port (struct GNUNET_CADET_Port *p)
   struct GNUNET_CADET_PortMessage *msg;
   struct GNUNET_MQ_Envelope *env;
 
+  GNUNET_assert (GNUNET_YES ==
+                 GNUNET_CONTAINER_multihashmap_remove (p->cadet->ports,
+                                                       &p->id,
+                                                       p));
   env = GNUNET_MQ_msg (msg,
                        GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE);
   msg->port = p->id;
   GNUNET_MQ_send (p->cadet->mq,
                   env);
-  GNUNET_assert (GNUNET_YES ==
-                 GNUNET_CONTAINER_multihashmap_remove (p->cadet->ports,
-                                                       &p->id,
-                                                       p));
   GNUNET_free_non_null (p->handlers);
   GNUNET_free (p);
 }
@@ -1673,7 +1673,7 @@ GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Listening to CADET port %s\n",
              GNUNET_h2s (port));
-  
+
   p = GNUNET_new (struct GNUNET_CADET_Port);
   p->cadet = h;
   p->id = *port;