aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-11-26 17:53:57 +0000
committerBart Polot <bart@net.in.tum.de>2013-11-26 17:53:57 +0000
commitfdbe690beeec04066f18302401096eb5212c3f6a (patch)
tree023dc33773ff1d54ee796ff0dc2956eb814f3da4
parent00528ceb103a5eba463987a68063dc1850f5f0c7 (diff)
downloadgnunet-fdbe690beeec04066f18302401096eb5212c3f6a.tar.gz
gnunet-fdbe690beeec04066f18302401096eb5212c3f6a.zip
- dont resend useless channel_destroy messages
-rw-r--r--src/mesh/gnunet-service-mesh_channel.c66
-rw-r--r--src/mesh/gnunet-service-mesh_channel.h8
2 files changed, 34 insertions, 40 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c
index 6801525bb..e741d96ff 100644
--- a/src/mesh/gnunet-service-mesh_channel.c
+++ b/src/mesh/gnunet-service-mesh_channel.c
@@ -504,6 +504,38 @@ send_client_nack (struct MeshChannel *ch)
504 504
505 505
506/** 506/**
507 * Notify a client that the channel is no longer valid.
508 *
509 * @param ch Channel that is destroyed.
510 * @param local_only Should we try to send it to other peers?
511 */
512static void
513send_destroy (struct MeshChannel *ch, int local_only)
514{
515 struct GNUNET_MESH_ChannelManage msg;
516
517 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY);
518 msg.header.size = htons (sizeof (msg));
519 msg.chid = htonl (ch->gid);
520
521 /* If root is not NULL, notify.
522 * If it's NULL, check lid_root. When a local destroy comes in, root
523 * is set to NULL but lid_root is left untouched. In this case, do nothing,
524 * the client is the one who reuqested the channel to be destroyed.
525 */
526 if (NULL != ch->root)
527 GML_send_channel_destroy (ch->root, ch->lid_root);
528 else if (0 == ch->lid_root && GNUNET_NO == local_only)
529 GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO, GNUNET_NO);
530
531 if (NULL != ch->dest)
532 GML_send_channel_destroy (ch->dest, ch->lid_dest);
533 else if (0 == ch->lid_dest && GNUNET_NO == local_only)
534 GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_YES, GNUNET_NO);
535}
536
537
538/**
507 * Destroy all reliable messages queued for a channel, 539 * Destroy all reliable messages queued for a channel,
508 * during a channel destruction. 540 * during a channel destruction.
509 * Frees the reliability structure itself. 541 * Frees the reliability structure itself.
@@ -1140,36 +1172,6 @@ GMCH_send_create (struct MeshChannel *ch)
1140 1172
1141} 1173}
1142 1174
1143/**
1144 * Notify a client that the channel is no longer valid.
1145 *
1146 * @param ch Channel that is destroyed.
1147 */
1148void
1149GMCH_send_destroy (struct MeshChannel *ch)
1150{
1151 struct GNUNET_MESH_ChannelManage msg;
1152
1153 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY);
1154 msg.header.size = htons (sizeof (msg));
1155 msg.chid = htonl (ch->gid);
1156
1157 /* If root is not NULL, notify.
1158 * If it's NULL, check lid_root. When a local destroy comes in, root
1159 * is set to NULL but lid_root is left untouched. In this case, do nothing,
1160 * the client is the one who reuqested the channel to be destroyed.
1161 */
1162 if (NULL != ch->root)
1163 GML_send_channel_destroy (ch->root, ch->lid_root);
1164 else if (0 == ch->lid_root)
1165 GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO, GNUNET_NO);
1166
1167 if (NULL != ch->dest)
1168 GML_send_channel_destroy (ch->dest, ch->lid_dest);
1169 else if (0 == ch->lid_dest)
1170 GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_YES, GNUNET_NO);
1171}
1172
1173 1175
1174/** 1176/**
1175 * Send an end-to-end ACK message for the most recent in-sequence payload. 1177 * Send an end-to-end ACK message for the most recent in-sequence payload.
@@ -1462,7 +1464,7 @@ GMCH_handle_local_destroy (struct MeshChannel *ch,
1462 } 1464 }
1463 1465
1464 t = ch->t; 1466 t = ch->t;
1465 GMCH_send_destroy (ch); 1467 send_destroy (ch, GNUNET_NO);
1466 GMCH_destroy (ch); 1468 GMCH_destroy (ch);
1467 GMT_destroy_if_empty (t); 1469 GMT_destroy_if_empty (t);
1468} 1470}
@@ -1881,7 +1883,7 @@ GMCH_handle_destroy (struct MeshChannel *ch,
1881 } 1883 }
1882 1884
1883 t = ch->t; 1885 t = ch->t;
1884 GMCH_send_destroy (ch); 1886 send_destroy (ch, GNUNET_YES);
1885 GMCH_destroy (ch); 1887 GMCH_destroy (ch);
1886 GMT_destroy_if_empty (t); 1888 GMT_destroy_if_empty (t);
1887} 1889}
diff --git a/src/mesh/gnunet-service-mesh_channel.h b/src/mesh/gnunet-service-mesh_channel.h
index d48feb8a6..9d1b196b9 100644
--- a/src/mesh/gnunet-service-mesh_channel.h
+++ b/src/mesh/gnunet-service-mesh_channel.h
@@ -147,14 +147,6 @@ void
147GMCH_send_create (struct MeshChannel *ch); 147GMCH_send_create (struct MeshChannel *ch);
148 148
149/** 149/**
150 * Notify a client that the channel is no longer valid.
151 *
152 * @param ch Channel that is destroyed.
153 */
154void
155GMCH_send_destroy (struct MeshChannel *ch);
156
157/**
158 * Allow a client to send us more data, in case it was choked. 150 * Allow a client to send us more data, in case it was choked.
159 * 151 *
160 * @param ch Channel. 152 * @param ch Channel.