aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-12-12 18:47:47 +0000
committerBart Polot <bart@net.in.tum.de>2013-12-12 18:47:47 +0000
commitac9368b0c7b0a94a3114f4469d01cc2b3f3d06bb (patch)
tree57fc600571f993feb865cb8596c256aa7f7e3699 /src
parent95b1e48893a606baa3b6dd78eee8c2dc1bb25400 (diff)
downloadgnunet-ac9368b0c7b0a94a3114f4469d01cc2b3f3d06bb.tar.gz
gnunet-ac9368b0c7b0a94a3114f4469d01cc2b3f3d06bb.zip
- return NULL when continuation is NULL, avoid channel:860 break
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c
index 020765584..a44fecab7 100644
--- a/src/mesh/gnunet-service-mesh_tunnel.c
+++ b/src/mesh/gnunet-service-mesh_tunnel.c
@@ -656,7 +656,7 @@ unqueue_data (struct MeshTunnelDelayed *tq)
656static struct MeshTunnelDelayed * 656static struct MeshTunnelDelayed *
657queue_data (struct MeshTunnel3 *t, const struct GNUNET_MessageHeader *msg) 657queue_data (struct MeshTunnel3 *t, const struct GNUNET_MessageHeader *msg)
658{ 658{
659 struct MeshTunnelDelayed *tq; 659 struct MeshTunnelDelayed *tqd;
660 uint16_t size = ntohs (msg->size); 660 uint16_t size = ntohs (msg->size);
661 661
662 LOG (GNUNET_ERROR_TYPE_DEBUG, "queue data on Tunnel %s\n", GMT_2s (t)); 662 LOG (GNUNET_ERROR_TYPE_DEBUG, "queue data on Tunnel %s\n", GMT_2s (t));
@@ -667,12 +667,12 @@ queue_data (struct MeshTunnel3 *t, const struct GNUNET_MessageHeader *msg)
667 return NULL; 667 return NULL;
668 } 668 }
669 669
670 tq = GNUNET_malloc (sizeof (struct MeshTunnelDelayed) + size); 670 tqd = GNUNET_malloc (sizeof (struct MeshTunnelDelayed) + size);
671 671
672 tq->t = t; 672 tqd->t = t;
673 memcpy (&tq[1], msg, size); 673 memcpy (&tqd[1], msg, size);
674 GNUNET_CONTAINER_DLL_insert_tail (t->tq_head, t->tq_tail, tq); 674 GNUNET_CONTAINER_DLL_insert_tail (t->tq_head, t->tq_tail, tqd);
675 return tq; 675 return tqd;
676} 676}
677 677
678 678
@@ -711,10 +711,17 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
711 711
712 if (GNUNET_NO == is_ready (t)) 712 if (GNUNET_NO == is_ready (t))
713 { 713 {
714 struct MeshTunnelDelayed *tqd;
715 /* A non null existing_q indicates sending of queued data.
716 * Should only happen after tunnel becomes ready.
717 */
714 GNUNET_assert (NULL == existing_q); 718 GNUNET_assert (NULL == existing_q);
719 tqd = queue_data (t, message);
720 if (NULL == cont)
721 return NULL;
715 tq = GNUNET_new (struct MeshTunnel3Queue); 722 tq = GNUNET_new (struct MeshTunnel3Queue);
716 tq->tqd = queue_data (t, message); 723 tq->tqd = tqd;
717 tq->tqd->tq = tq; 724 tqd->tq = tq;
718 tq->cont = cont; 725 tq->cont = cont;
719 tq->cont_cls = cont_cls; 726 tq->cont_cls = cont_cls;
720 return tq; 727 return tq;
@@ -814,8 +821,10 @@ send_queued_data (struct MeshTunnel3 *t)
814 next = tqd->next; 821 next = tqd->next;
815 room--; 822 room--;
816 send_prebuilt_message ((struct GNUNET_MessageHeader *) &tqd[1], 823 send_prebuilt_message ((struct GNUNET_MessageHeader *) &tqd[1],
817 tqd->t, GNUNET_YES, 824 tqd->t, GNUNET_YES,
818 tqd->tq->cont, tqd->tq->cont_cls, tqd->tq); 825 NULL != tqd->tq ? tqd->tq->cont : NULL,
826 NULL != tqd->tq ? tqd->tq->cont_cls : NULL,
827 tqd->tq);
819 unqueue_data (tqd); 828 unqueue_data (tqd);
820 } 829 }
821 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT_send_queued_data end\n", GMP_2s (t->peer)); 830 LOG (GNUNET_ERROR_TYPE_DEBUG, "GMT_send_queued_data end\n", GMP_2s (t->peer));