aboutsummaryrefslogtreecommitdiff
path: root/src/cadet
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-10-15 00:55:51 +0000
committerBart Polot <bart@net.in.tum.de>2014-10-15 00:55:51 +0000
commit98e80df6a13b647258fedbb5f20658a582e255bf (patch)
tree3c0987fda32b539251d530d7378d334c473d7967 /src/cadet
parentf2d150bbffa2d8b965a5a17b95a2afdbed822e33 (diff)
downloadgnunet-98e80df6a13b647258fedbb5f20658a582e255bf.tar.gz
gnunet-98e80df6a13b647258fedbb5f20658a582e255bf.zip
- only try to pop messages if there are any, otherwise directly destory the connection
Diffstat (limited to 'src/cadet')
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index 147bf1e8e..2cf6d2dd9 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -1812,7 +1812,7 @@ GCC_handle_broken (void* cls,
1812 struct GNUNET_CADET_ConnectionBroken *msg; 1812 struct GNUNET_CADET_ConnectionBroken *msg;
1813 struct CadetConnection *c; 1813 struct CadetConnection *c;
1814 struct CadetTunnel *t; 1814 struct CadetTunnel *t;
1815 int destroyed; 1815 int pending;
1816 int fwd; 1816 int fwd;
1817 1817
1818 msg = (struct GNUNET_CADET_ConnectionBroken *) message; 1818 msg = (struct GNUNET_CADET_ConnectionBroken *) message;
@@ -1848,24 +1848,37 @@ GCC_handle_broken (void* cls,
1848 endpoint = GCP_get_short (c->path->peers[c->path->length - 1]); 1848 endpoint = GCP_get_short (c->path->peers[c->path->length - 1]);
1849 path_invalidate (c->path); 1849 path_invalidate (c->path);
1850 GCP_notify_broken_link (endpoint, &msg->peer1, &msg->peer2); 1850 GCP_notify_broken_link (endpoint, &msg->peer1, &msg->peer2);
1851
1851 c->state = CADET_CONNECTION_BROKEN; 1852 c->state = CADET_CONNECTION_BROKEN;
1852 GCT_remove_connection (t, c); 1853 GCT_remove_connection (t, c);
1853 c->t = NULL; 1854 c->t = NULL;
1854 destroyed = GNUNET_NO;
1855 1855
1856 /* GCP_connection_pop could destroy the connection! */ 1856 pending = c->pending_messages;
1857 while (NULL != (out_msg = GCP_connection_pop (neighbor, c, &destroyed))) 1857 if (0 < pending)
1858 { 1858 {
1859 GCT_resend_message (out_msg, t); 1859 int destroyed;
1860
1861 destroyed = GNUNET_NO;
1862
1863 /* GCP_connection_pop could destroy the connection! */
1864 while (NULL != (out_msg = GCP_connection_pop (neighbor, c, &destroyed)))
1865 {
1866 GCT_resend_message (out_msg, t);
1867 }
1868
1869 /* All pending messages should have been popped,
1870 * and the connection destroyed by the continuation,
1871 * except if the queue was empty. */
1872 if (GNUNET_YES != destroyed)
1873 {
1874 GNUNET_break (0);
1875 GCC_debug (c, GNUNET_ERROR_TYPE_ERROR);
1876 GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);
1877 GCC_destroy (c);
1878 }
1860 } 1879 }
1861 /* All pending messages should have been popped, 1880 else
1862 * and the connection destroyed by the continuation.
1863 */
1864 if (GNUNET_YES != destroyed)
1865 { 1881 {
1866 GNUNET_break (0);
1867 GCC_debug (c, GNUNET_ERROR_TYPE_ERROR);
1868 GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);
1869 GCC_destroy (c); 1882 GCC_destroy (c);
1870 } 1883 }
1871 } 1884 }