[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30135 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30135 - gnunet/src/mesh |
Date: |
Fri, 11 Oct 2013 14:16:23 +0200 |
Author: bartpolot
Date: 2013-10-11 14:16:22 +0200 (Fri, 11 Oct 2013)
New Revision: 30135
Modified:
gnunet/src/mesh/gnunet-service-mesh_channel.c
gnunet/src/mesh/gnunet-service-mesh_channel.h
gnunet/src/mesh/gnunet-service-mesh_local.c
Log:
- fix compile errors in local
Modified: gnunet/src/mesh/gnunet-service-mesh_channel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.c 2013-10-11 12:07:44 UTC
(rev 30134)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.c 2013-10-11 12:16:22 UTC
(rev 30135)
@@ -853,47 +853,6 @@
/**
- * Iterator for deleting each channel whose client endpoint disconnected.
- *
- * @param cls Closure (client that has disconnected).
- * @param key The local channel id (used to access the hashmap).
- * @param value The value stored at the key (channel to destroy).
- *
- * @return GNUNET_OK, keep iterating.
- */
-static int
-channel_destroy_iterator (void *cls,
- uint32_t key,
- void *value)
-{
- struct MeshChannel *ch = value;
- struct MeshClient *c = cls;
- struct MeshTunnel3 *t;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- " Channel %X (%X / %X) destroy, due to client %s shutdown.\n",
- ch->gid, ch->lid_root, ch->lid_dest, GML_2s (c));
- GMCH_debug (ch);
-
- if (c == ch->dest)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, " Client %s is destination.\n", GML_2s (c));
- }
- if (c == ch->root)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, " Client %s is owner.\n", GML_2s (c));
- }
-
- t = ch->t;
- GMCH_send_destroy (ch);
- channel_destroy (ch);
- GMT_destroy_if_empty (t);
-
- return GNUNET_OK;
-}
-
-
-/**
* Handle a loopback message: call the appropriate handler for the message
type.
*
* @param ch Channel this message is on.
@@ -1277,34 +1236,29 @@
*
* @param ch Channel.
* @param c Client that requested the destruction (to avoid notifying him).
- * @param chid Channel ID used.
*/
void
GMCH_handle_local_destroy (struct MeshChannel *ch,
- struct MeshClient *c,
- MESH_ChannelNumber chid)
+ struct MeshClient *c)
{
struct MeshTunnel3 *t;
/* Cleanup after the tunnel */
- GML_client_delete_channel (c, ch, chid);
- if (c == ch->dest && GNUNET_MESH_LOCAL_CHANNEL_ID_SERV <= chid)
+ if (c == ch->dest)
{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " Client %s is destination.\n", GML_2s (c));
+ GML_client_delete_channel (c, ch, ch->lid_dest);
ch->dest = NULL;
}
- else if (c == ch->root && GNUNET_MESH_LOCAL_CHANNEL_ID_SERV > chid)
+ if (c == ch->root)
{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " Client %s is owner.\n", GML_2s (c));
+ GML_client_delete_channel (c, ch, ch->lid_root);
ch->root = NULL;
}
- else
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- " channel %X client %p (%p, %p)\n",
- chid, c, ch->root, ch->dest);
- GNUNET_break (0);
- }
t = ch->t;
+ GMCH_send_destroy (ch);
channel_destroy (ch);
GMT_destroy_if_empty (t);
}
@@ -1317,8 +1271,10 @@
*
* @param c Client that requested the creation (will be the root).
* @param msg Create Channel message.
+ *
+ * @return GNUNET_OK if everything went fine, GNUNET_SYSERR otherwise.
*/
-void
+int
GMCH_handle_local_create (struct MeshClient *c,
struct GNUNET_MESH_ChannelMessage *msg)
{
@@ -1335,15 +1291,14 @@
if (NULL != GML_channel_get (c, chid))
{
GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
+ return GNUNET_SYSERR;
}
peer = GMP_get (&msg->peer);
GMP_add_tunnel (peer);
- t = GMP_get_tunnel(peer);
+ t = GMP_get_tunnel (peer);
- if (GMP_get_short_id(peer) == myid)
+ if (GMP_get_short_id (peer) == myid)
{
GMT_change_state (t, MESH_TUNNEL3_READY);
}
@@ -1357,7 +1312,7 @@
if (NULL == ch)
{
GNUNET_break (0);
- return;
+ return GNUNET_SYSERR;
}
ch->port = ntohl (msg->port);
channel_set_options (ch, ntohl (msg->opt));
@@ -1368,7 +1323,7 @@
ch->root_rel->expected_delay = MESH_RETRANSMIT_TIME;
LOG (GNUNET_ERROR_TYPE_DEBUG, "CREATED CHANNEL %s[%x]:%u (%x)\n",
- peer2s (t->peer), ch->gid, ch->port, ch->lid_root);
+ GMT_2s (t), ch->gid, ch->port, ch->lid_root);
/* Send create channel */
{
@@ -1382,6 +1337,7 @@
GMT_queue_data (t, ch, &msgcc.header, GNUNET_YES);
}
+ return GNUNET_OK;
}
/**
@@ -1618,14 +1574,19 @@
const struct GNUNET_MESH_ChannelManage *msg,
int fwd)
{
+ struct MeshTunnel3 *t;
+
+ GMCH_debug (ch);
if ( (fwd && NULL == ch->dest) || (!fwd && NULL == ch->root) )
{
/* Not for us (don't destroy twice a half-open loopback channel) */
return;
}
+ t = ch->t;
GMCH_send_destroy (ch);
channel_destroy (ch);
+ GMT_destroy_if_empty (t);
}
@@ -1661,3 +1622,25 @@
GMT_send_prebuilt_message (message, ch->t, ch, fwd);
}
+
+
+/**
+ * Get the static string for identification of the channel.
+ *
+ * @param ch Channel.
+ *
+ * @return Static string with the channel IDs.
+ */
+const char *
+GMCH_2s (const struct MeshChannel *ch)
+{
+ static char buf[64];
+
+ if (NULL == ch)
+ return "(NULL Channel)";
+
+ sprintf (buf, "%s:%X (%X / %X)",
+ GMT_2s (ch->t), ch->gid, ch->lid_root, ch->lid_dest);
+
+ return buf;
+}
Modified: gnunet/src/mesh/gnunet-service-mesh_channel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.h 2013-10-11 12:07:44 UTC
(rev 30134)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.h 2013-10-11 12:16:22 UTC
(rev 30135)
@@ -192,12 +192,10 @@
*
* @param ch Channel.
* @param c Client that requested the destruction (to avoid notifying him).
- * @param chid Channel ID used.
*/
void
GMCH_handle_local_destroy (struct MeshChannel *ch,
- struct MeshClient *c,
- MESH_ChannelNumber chid);
+ struct MeshClient *c);
/**
* Handle a channel create requested by a client.
@@ -206,8 +204,10 @@
*
* @param c Client that requested the creation (will be the root).
* @param msg Create Channel message.
+ *
+ * @return GNUNET_OK if everything went fine, GNUNET_SYSERR otherwise.
*/
-void
+int
GMCH_handle_local_create (struct MeshClient *c,
struct GNUNET_MESH_ChannelMessage *msg);
@@ -287,7 +287,17 @@
GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
struct MeshChannel *ch, int fwd);
+/**
+ * Get the static string for identification of the channel.
+ *
+ * @param ch Channel.
+ *
+ * @return Static string with the channel IDs.
+ */
+const char *
+GMCH_2s (const struct MeshChannel *ch);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
Modified: gnunet/src/mesh/gnunet-service-mesh_local.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_local.c 2013-10-11 12:07:44 UTC (rev
30134)
+++ gnunet/src/mesh/gnunet-service-mesh_local.c 2013-10-11 12:16:22 UTC (rev
30135)
@@ -192,6 +192,31 @@
/**
+ * Iterator for deleting each channel whose client endpoint disconnected.
+ *
+ * @param cls Closure (client that has disconnected).
+ * @param key The local channel id (used to access the hashmap).
+ * @param value The value stored at the key (channel to destroy).
+ *
+ * @return GNUNET_OK, keep iterating.
+ */
+static int
+channel_destroy_iterator (void *cls,
+ uint32_t key,
+ void *value)
+{
+ struct MeshChannel *ch = value;
+ struct MeshClient *c = cls;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ " Channel %s destroy, due to client %s shutdown.\n",
+ GMCH_2s (ch), GML_2s (c));
+
+ GMCH_handle_local_destroy (ch, c);
+ return GNUNET_OK;
+}
+
+/**
* Handler for client disconnection
*
* @param cls closure
@@ -210,7 +235,7 @@
return;
}
- c = client_get (client);
+ c = GML_client_get (client);
if (NULL != c)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "matching client found (%u, %p)\n",
@@ -349,7 +374,13 @@
return;
}
- GMCH_handle_local_create (c, (struct GNUNET_MESH_ChannelMessage *) message);
+ if (GNUNET_OK !=
+ GMCH_handle_local_create (c,
+ (struct GNUNET_MESH_ChannelMessage *) message))
+ {
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
@@ -405,7 +436,7 @@
return;
}
- GMCH_handle_local_destroy (ch, c, chid);
+ GMCH_handle_local_destroy (ch, c);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30135 - gnunet/src/mesh,
gnunet <=