gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r30107 - gnunet/src/mesh
Date: Thu, 10 Oct 2013 17:15:25 +0200

Author: bartpolot
Date: 2013-10-10 17:15:25 +0200 (Thu, 10 Oct 2013)
New Revision: 30107

Modified:
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_connection.h
   gnunet/src/mesh/gnunet-service-mesh_peer.c
   gnunet/src/mesh/gnunet-service-mesh_peer.h
Log:
- fixes


Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-10 15:02:16 UTC 
(rev 30106)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-10 15:15:25 UTC 
(rev 30107)
@@ -470,7 +470,8 @@
                  GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK,
                  sizeof (struct GNUNET_MESH_ConnectionACK),
                  connection, NULL, fwd,
-                 &message_sent, sizeof (struct GNUNET_MESH_ConnectionACK));
+                 &message_sent,
+                 (void *) sizeof (struct GNUNET_MESH_ConnectionACK));
   if (MESH_TUNNEL3_NEW == GMT_get_state (t))
     GMT_change_state (t, MESH_TUNNEL3_WAITING);
   if (MESH_CONNECTION_READY != connection->state)
@@ -498,7 +499,7 @@
                  size,
                  connection,
                  NULL,
-                 GNUNET_YES, &message_sent, size);
+                 GNUNET_YES, &message_sent, (void *) size);
   state = GMT_get_state (connection->t);
   if (MESH_TUNNEL3_SEARCHING == state || MESH_TUNNEL3_NEW == state)
     GMT_change_state (connection->t, MESH_TUNNEL3_WAITING);
@@ -679,34 +680,6 @@
 
 
 /**
- * Get the first transmittable message for a connection.
- *
- * @param c Connection.
- * @param fwd Is this FWD?
- *
- * @return First transmittable message.
- */
-static struct MeshPeerQueue *
-connection_get_first_message (struct MeshConnection *c, int fwd)
-{
-  struct MeshPeerQueue *q;
-  struct MeshPeer *p;
-
-  p = connection_get_hop (c, fwd);
-
-  for (q = p->queue_head; NULL != q; q = q->next)
-  {
-    if (q->c != c)
-      continue;
-    if (queue_is_sendable (q))
-      return q;
-  }
-
-  return NULL;
-}
-
-
-/**
  * @brief Re-initiate traffic on this connection if necessary.
  *
  * Check if there is traffic queued towards this peer
@@ -720,8 +693,6 @@
 connection_unlock_queue (struct MeshConnection *c, int fwd)
 {
   struct MeshPeer *peer;
-  struct MeshPeerQueue *q;
-  size_t size;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
               "connection_unlock_queue %s on %s\n",
@@ -734,30 +705,7 @@
   }
 
   peer = connection_get_hop (c, fwd);
-
-  if (NULL != peer->core_transmit)
-  {
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "  already unlocked!\n");
-    return; /* Already unlocked */
-  }
-
-  q = connection_get_first_message (c, fwd);
-  if (NULL == q)
-  {
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "  queue empty!\n");
-    return; /* Nothing to transmit */
-  }
-
-  size = q->size;
-  peer->core_transmit =
-      GNUNET_CORE_notify_transmit_ready (core_handle,
-                                         GNUNET_NO,
-                                         0,
-                                         GNUNET_TIME_UNIT_FOREVER_REL,
-                                         GNUNET_PEER_resolve2 (peer->id),
-                                         size,
-                                         &queue_send,
-                                         peer);
+  GMP_queue_unlock (peer, c);
 }
 
 
@@ -822,7 +770,7 @@
   msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_POLL);
   msg.header.size = htons (sizeof (msg));
   LOG (GNUNET_ERROR_TYPE_DEBUG, " *** pid (%u)!\n", fc->last_pid_sent);
-  send_prebuilt_message_connection (&msg.header, c, NULL, fc == &c->fwd_fc);
+  GMC_send_prebuilt_message (&msg.header, c, NULL, fc == &c->fwd_fc);
   fc->poll_time = GNUNET_TIME_STD_BACKOFF (fc->poll_time);
   fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
                                                 &connection_poll, fc);
@@ -940,14 +888,14 @@
   if (GNUNET_NO == GMP_is_neighbor (peer))
   {
     GMC_destroy (c);
-    return NULL;
+    return;
   }
   GMP_add_connection (peer, c);
   peer = connection_get_prev_hop (c);
   if (GNUNET_NO == GMP_is_neighbor (peer))
   {
     GMC_destroy (c);
-    return NULL;
+    return;
   }
   GMP_add_connection (peer, c);
 }
@@ -1048,10 +996,10 @@
       LOG (GNUNET_ERROR_TYPE_DEBUG, "  ... adding %s\n",
                   GNUNET_i2s (&id[i]));
       path->peers[i] = GNUNET_PEER_intern (&id[i]);
-      if (path->peers[i] == my_short_id)
+      if (path->peers[i] == myid)
         own_pos = i;
     }
-    if (own_pos == 0 && path->peers[own_pos] != my_short_id)
+    if (own_pos == 0 && path->peers[own_pos] != myid)
     {
       /* create path: self not found in path through self */
       GNUNET_break_op (0);
@@ -1086,7 +1034,7 @@
 
     if (NULL == orig_peer->tunnel)
     {
-      orig_peer->tunnel = tunnel_new ();
+      orig_peer->tunnel = GMT_new ();
       orig_peer->tunnel->peer = orig_peer;
     }
     GMT_add_connection (orig_peer->tunnel, c);
@@ -1986,6 +1934,25 @@
 
 
 /**
+ * See if we are allowed to send by the next hop in the given direction.
+ *
+ * @param c Connection.
+ * @param fwd Is this about fwd traffic?
+ *
+ * @return GNUNET_YES in case it's OK.
+ */
+int
+GMC_is_sendable (struct MeshConnection *c, int fwd)
+{
+  struct MeshFlowControl *fc;
+
+  fc = fwd ? &c->fwd_fc : &c->bck_fc;
+  if (GMC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
+    return GNUNET_YES;
+  return GNUNET_NO;
+}
+
+/**
  * Sends an already built message on a connection, properly registering
  * all used resources.
  *

Modified: gnunet/src/mesh/gnunet-service-mesh_connection.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.h    2013-10-10 15:02:16 UTC 
(rev 30106)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.h    2013-10-10 15:15:25 UTC 
(rev 30107)
@@ -370,6 +370,17 @@
 GMC_is_terminal (struct MeshConnection *c, int fwd);
 
 /**
+ * See if we are allowed to send by the next hop in the given direction.
+ *
+ * @param c Connection.
+ * @param fwd Is this about fwd traffic?
+ *
+ * @return GNUNET_YES in case it's OK.
+ */
+int
+GMC_is_sendable (struct MeshConnection *c, int fwd);
+
+/**
  * Sends an already built message on a connection, properly registering
  * all used resources.
  *

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-10-10 15:02:16 UTC (rev 
30106)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c  2013-10-10 15:15:25 UTC (rev 
30107)
@@ -1002,7 +1002,7 @@
     if (GNUNET_YES == t->destroy && 0 == t->pending_messages)
     {
 //       LOG (GNUNET_ERROR_TYPE_DEBUG, "*  destroying tunnel!\n");
-      tunnel_destroy (t);
+      GMT_destroy (t);
     }
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "*  Return %d\n", data_size);
@@ -1010,7 +1010,23 @@
 }
 
 
+static int
+queue_is_sendable (struct MeshPeerQueue *q)
+{
+  /* Is PID-independent? */
+  switch (q->type)
+  {
+    case GNUNET_MESSAGE_TYPE_MESH_ACK:
+    case GNUNET_MESSAGE_TYPE_MESH_POLL:
+      return GNUNET_YES;
+  }
 
+  if (GMC_is_sendable (q->c, q->fwd))
+    return GNUNET_YES;
+
+  return GNUNET_NO;
+}
+
 /**
  * Get first sendable message.
  *
@@ -1033,28 +1049,8 @@
 }
 
 
-static int
-queue_is_sendable (struct MeshPeerQueue *q)
-{
-  struct MeshFlowControl *fc;
 
-  /* Is PID-independent? */
-  switch (q->type)
-  {
-    case GNUNET_MESSAGE_TYPE_MESH_ACK:
-    case GNUNET_MESSAGE_TYPE_MESH_POLL:
-      return GNUNET_YES;
-  }
 
-  /* Is PID allowed? */
-  fc = q->fwd ? &q->c->fwd_fc : &q->c->bck_fc;
-  if (GMC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
-    return GNUNET_YES;
-
-  return GNUNET_NO;
-}
-
-
 
/******************************************************************************/
 /********************************    API    
***********************************/
 
/******************************************************************************/
@@ -1314,6 +1310,62 @@
 
 
 /**
+ * Get the first transmittable message for a connection.
+ *
+ * @param peer Neighboring peer.
+ * @param c Connection.
+ *
+ * @return First transmittable message.
+ */
+static struct MeshPeerQueue *
+connection_get_first_message (struct MeshPeer *peer, struct MeshConnection *c)
+{
+  struct MeshPeerQueue *q;
+
+  for (q = peer->queue_head; NULL != q; q = q->next)
+  {
+    if (q->c != c)
+      continue;
+    if (queue_is_sendable (q))
+      return q;
+  }
+
+  return NULL;
+}
+
+void
+GMP_queue_unlock (struct MeshPeer *peer, struct MeshConnection *c)
+{
+  struct MeshPeerQueue *q;
+  size_t size;
+
+  if (NULL != peer->core_transmit)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "  already unlocked!\n");
+    return; /* Already unlocked */
+  }
+
+  q = connection_get_first_message (c);
+  if (NULL == q)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "  queue empty!\n");
+    return; /* Nothing to transmit */
+  }
+
+  size = q->size;
+  peer->core_transmit =
+      GNUNET_CORE_notify_transmit_ready (core_handle,
+                                         GNUNET_NO,
+                                         0,
+                                         GNUNET_TIME_UNIT_FOREVER_REL,
+                                         GNUNET_PEER_resolve2 (peer->id),
+                                         size,
+                                         &queue_send,
+                                         peer);
+}
+
+
+/**
  * Initialize the peer subsystem.
  *
  * @param c Configuration.

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.h  2013-10-10 15:02:16 UTC (rev 
30106)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.h  2013-10-10 15:15:25 UTC (rev 
30107)
@@ -106,6 +106,9 @@
 void
 GMP_queue_cancel (struct MeshPeer *peer, struct MeshConnection *c);
 
+void
+GMP_queue_unlock (struct MeshPeer *peer, struct MeshConnection *c);
+
 /**
  * Set tunnel.
  *




reply via email to

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