gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r30057 - gnunet/src/mesh
Date: Wed, 9 Oct 2013 17:52:55 +0200

Author: bartpolot
Date: 2013-10-09 17:52:55 +0200 (Wed, 09 Oct 2013)
New Revision: 30057

Modified:
   gnunet/src/mesh/gnunet-service-mesh_channel.c
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_local.c
   gnunet/src/mesh/gnunet-service-mesh_local.h
   gnunet/src/mesh/gnunet-service-mesh_tunnel.c
Log:
- local channel id better accounted for per-client


Modified: gnunet/src/mesh/gnunet-service-mesh_channel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.c       2013-10-09 15:20:16 UTC 
(rev 30056)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.c       2013-10-09 15:52:55 UTC 
(rev 30057)
@@ -33,8 +33,10 @@
 
 #define LOG(level, ...) GNUNET_log_from(level,"mesh-chn",__VA_ARGS__)
 
+#define MESH_RETRANSMIT_TIME    GNUNET_TIME_UNIT_SECONDS
 #define MESH_RETRANSMIT_MARGIN  4
 
+
 /**
  * All the states a connection can be in.
  */
@@ -356,8 +358,8 @@
  * @param ch Channel to which add the client.
  * @param c Client which to add to the channel.
  */
-static void
-channel_add_client (struct MeshChannel *ch, struct MeshClient *c)
+void
+GMCH_add_client (struct MeshChannel *ch, struct MeshClient *c)
 {
   struct MeshTunnel3 *t = ch->t;
 
@@ -368,20 +370,10 @@
   }
 
   /* Assign local id as destination */
-  while (NULL != GML_channel_get (c, t->next_local_chid))
-    t->next_local_chid = (t->next_local_chid + 1) | 
GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
-  ch->lid_dest = t->next_local_chid++;
-  t->next_local_chid = t->next_local_chid | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
+  ch->lid_dest = GML_get_next_chid (c);
 
   /* Store in client's hashmap */
-  if (GNUNET_OK !=
-      GNUNET_CONTAINER_multihashmap32_put (c->incoming_channels,
-                                           ch->lid_dest, ch,
-                                           
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
-  {
-    GNUNET_break (0);
-    return;
-  }
+  GML_channel_add (c, ch->lid_dest, ch);
 
   GNUNET_break (NULL == ch->dest_rel);
   ch->dest_rel = GNUNET_new (struct MeshChannelReliability);
@@ -540,7 +532,7 @@
    */
   payload = (struct GNUNET_MESH_Data *) &copy[1];
   fwd = (rel == ch->root_rel);
-  c = tunnel_get_connection (ch->t, fwd);
+  c = GMT_get_connection (ch->t, fwd);
   hop = connection_get_hop (c, fwd);
   for (q = hop->queue_head; NULL != q; q = q->next)
   {
@@ -558,7 +550,7 @@
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %u\n", copy->mid);
 
-    send_prebuilt_message_channel (&payload->header, ch, fwd);
+    GMCH_send_prebuilt_message (&payload->header, ch, fwd);
     GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO);
   }
   else
@@ -588,7 +580,6 @@
 {
   struct MeshTunnel3 *t = ch->t;
   struct MeshConnection *c;
-  struct MeshFlowControl *fc;
   uint32_t allowed;
   uint32_t to_allow;
   uint32_t allow_per_connection;
@@ -599,10 +590,11 @@
               fwd ? "FWD" : "BCK", peer2s (ch->t->peer), ch->gid);
 
   /* Count connections, how many messages are already allowed */
+  cs = GMT_count_connections (t);
   for (cs = 0, allowed = 0, c = t->connection_head; NULL != c; c = c->next)
   {
     fc = fwd ? &c->fwd_fc : &c->bck_fc;
-    if (GMC_is_pid_bigger(fc->last_pid_recv, fc->last_ack_sent))
+    if (GMC_is_pid_bigger (fc->last_pid_recv, fc->last_ack_sent))
     {
       GNUNET_break (0);
       continue;
@@ -631,7 +623,7 @@
     {
       continue;
     }
-    connection_send_ack (c, allow_per_connection, fwd);
+    GMC_send_ack (c, allow_per_connection, fwd);
   }
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,

Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-09 15:20:16 UTC 
(rev 30056)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2013-10-09 15:52:55 UTC 
(rev 30057)
@@ -40,8 +40,6 @@
 #define MESH_MAX_POLL_TIME      GNUNET_TIME_relative_multiply (\
                                   GNUNET_TIME_UNIT_MINUTES,\
                                   10)
-#define MESH_RETRANSMIT_TIME    GNUNET_TIME_UNIT_SECONDS
-
 #define LOG(level, ...) GNUNET_log_from (level,"mesh-con",__VA_ARGS__)
 
 

Modified: gnunet/src/mesh/gnunet-service-mesh_local.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_local.c 2013-10-09 15:20:16 UTC (rev 
30056)
+++ gnunet/src/mesh/gnunet-service-mesh_local.c 2013-10-09 15:52:55 UTC (rev 
30057)
@@ -58,12 +58,17 @@
      */
   struct GNUNET_CONTAINER_MultiHashMap32 *own_channels;
 
-   /**
+    /**
      * Tunnels this client has accepted, indexed by incoming local id
      */
   struct GNUNET_CONTAINER_MultiHashMap32 *incoming_channels;
 
     /**
+     * Channel ID for the next incoming channel.
+     */
+  MESH_ChannelNumber next_chid;
+
+    /**
      * Handle to communicate with the client
      */
   struct GNUNET_SERVER_Client *handle;
@@ -177,9 +182,10 @@
 
   if (NULL == client)
     return;
-  c = GNUNET_malloc (sizeof (struct MeshClient));
+  c = GNUNET_new (struct MeshClient);
   c->handle = client;
   c->id = next_client_id++; /* overflow not important: just for debug */
+  c->next_chid = GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
   GNUNET_SERVER_client_keep (client);
   GNUNET_SERVER_client_set_user_context (client, c);
   GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, c);
@@ -894,6 +900,7 @@
     GNUNET_break (0);
 }
 
+
 /**
  * Remove a channel from a client
  *
@@ -914,7 +921,32 @@
     GNUNET_break (0);
 }
 
+
 /**
+ * Get the tunnel's next free local channel ID.
+ *
+ * @param c Client.
+ *
+ * @return LID of a channel free to use.
+ */
+MESH_ChannelNumber
+GML_get_next_chid (struct MeshClient *c)
+{
+  MESH_ChannelNumber chid;
+
+  while (NULL != GML_channel_get (c, c->next_chid))
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %u exists...\n", c->next_chid);
+    c->next_chid = (c->next_chid + 1) | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
+  }
+  chid = c->next_chid;
+  c->next_chid = (c->next_chid + 1) | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
+
+  return chid;
+}
+
+
+/**
  * Check if client has registered with the service and has not disconnected
  *
  * @param client the client to check

Modified: gnunet/src/mesh/gnunet-service-mesh_local.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_local.h 2013-10-09 15:20:16 UTC (rev 
30056)
+++ gnunet/src/mesh/gnunet-service-mesh_local.h 2013-10-09 15:52:55 UTC (rev 
30057)
@@ -107,6 +107,16 @@
                     struct MeshChannel *ch);
 
 /**
+ * Get the tunnel's next free local channel ID.
+ *
+ * @param c Client.
+ *
+ * @return LID of a channel free to use.
+ */
+MESH_ChannelNumber
+GML_get_next_chid (struct MeshClient *c);
+
+/**
  * Check if client has registered with the service and has not disconnected
  *
  * @param client the client to check

Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-10-09 15:20:16 UTC 
(rev 30056)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c        2013-10-09 15:52:55 UTC 
(rev 30057)
@@ -115,11 +115,6 @@
   MESH_ChannelNumber next_chid;
 
   /**
-   * Channel ID for the next incoming channel.
-   */
-  MESH_ChannelNumber next_local_chid;
-
-  /**
    * Pending message count.
    */
   int pending_messages;
@@ -589,7 +584,6 @@
 
   t = GNUNET_new (struct MeshTunnel3);
   t->next_chid = 0;
-  t->next_local_chid = GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
 //   if (GNUNET_OK !=
 //       GNUNET_CONTAINER_multihashmap_put (tunnels, tid, t,
 //                                          
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
@@ -1074,13 +1068,12 @@
 }
 
 
-
 /**
- * Get the tunnel's next free Channel ID.
+ * Get the tunnel's next free global channel ID.
  *
  * @param t Tunnel.
  *
- * @return ID of a channel free to use.
+ * @return GID of a channel free to use.
  */
 MESH_ChannelNumber
 GMT_get_next_chid (struct MeshTunnel3 *t)




reply via email to

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