gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r16226 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r16226 - gnunet/src/mesh
Date: Wed, 27 Jul 2011 09:28:16 +0200

Author: toelke
Date: 2011-07-27 09:28:16 +0200 (Wed, 27 Jul 2011)
New Revision: 16226

Modified:
   gnunet/src/mesh/mesh_api.c
Log:
do not allow more than one notify_transmit_ready per tunnel

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2011-07-27 07:28:15 UTC (rev 16225)
+++ gnunet/src/mesh/mesh_api.c  2011-07-27 07:28:16 UTC (rev 16226)
@@ -73,6 +73,8 @@
    */
   uint16_t application_type;
 
+  struct GNUNET_MESH_TransmitHandle* notify_handle;
+
   /* The context of the receive-function. */
   void *ctx;
 };
@@ -611,6 +613,7 @@
 {
   struct notify_cls *ncls = cls;
   struct GNUNET_MESH_Tunnel *tunnel = ncls->tunnel;
+  tunnel->notify_handle = NULL;
   struct tunnel_message* message = buf;
   void* cbuf = (void*) &message[1];
   GNUNET_assert(NULL != ncls->notify);
@@ -653,37 +656,49 @@
  */
 struct GNUNET_MESH_TransmitHandle *
 GNUNET_MESH_notify_transmit_ready (struct
-                                  GNUNET_MESH_Tunnel
-                                  *tunnel,
-                                  int cork,
-                                  uint32_t priority,
-                                  struct
-                                  GNUNET_TIME_Relative
-                                  maxdelay,
-                                  const struct GNUNET_PeerIdentity *target 
__attribute__((unused)),
-                                  size_t
-                                  notify_size,
-                                  GNUNET_CONNECTION_TransmitReadyNotify
-                                  notify, void *notify_cls)
+                                   GNUNET_MESH_Tunnel
+                                   *tunnel,
+                                   int cork,
+                                   uint32_t priority,
+                                   struct
+                                   GNUNET_TIME_Relative
+                                   maxdelay,
+                                   const struct GNUNET_PeerIdentity *target
+                                   __attribute__ ((unused)),
+                                   size_t notify_size,
+                                   GNUNET_CONNECTION_TransmitReadyNotify
+                                   notify, void *notify_cls)
 {
-  struct notify_cls *cls = GNUNET_malloc(sizeof(struct notify_cls));
+  if (NULL != tunnel->notify_handle)
+    {
+      GNUNET_break(0);
+      return NULL;
+    }
+
+  struct notify_cls *cls = GNUNET_malloc (sizeof (struct notify_cls));
   cls->notify_cls = notify_cls;
-  GNUNET_assert(NULL != notify);
+  GNUNET_assert (NULL != notify);
   cls->notify = notify;
   cls->tunnel = tunnel;
-  GNUNET_CORE_notify_transmit_ready(tunnel->handle->core,
-                                   cork,
-                                   priority,
-                                   maxdelay,
-                                   &tunnel->peer,
-                                   notify_size + sizeof(struct tunnel_message),
-                                   &core_notify,
-                                   (void*)cls);
 
-  /* aborting is not implemented yet */
-  return (struct GNUNET_MESH_TransmitHandle*) 1;
+  tunnel->notify_handle = (struct GNUNET_MESH_TransmitHandle *)
+    GNUNET_CORE_notify_transmit_ready (tunnel->handle->core, cork, priority,
+                                       maxdelay, &tunnel->peer,
+                                       notify_size +
+                                       sizeof (struct tunnel_message),
+                                       &core_notify, (void *) cls);
+
+  return tunnel->notify_handle;
 }
 
+void
+GNUNET_MESH_notify_transmit_ready_cancel (struct GNUNET_MESH_TransmitHandle
+                                          *th)
+{
+  GNUNET_CORE_notify_transmit_ready_cancel ((struct GNUNET_CORE_TransmitHandle
+                                             *) th);
+}
+
 void build_hello_message(struct GNUNET_MESH_Handle* handle,
                          const GNUNET_MESH_ApplicationType *stypes)
 {




reply via email to

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