aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/mesh_api.c
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2011-07-27 07:28:16 +0000
committerPhilipp Tölke <toelke@in.tum.de>2011-07-27 07:28:16 +0000
commit98760f1bfe7a96e87f762c6948825f12ab9bb736 (patch)
treea4788673b0e5dfdbae804d25ffd75f22b7ac01d1 /src/mesh/mesh_api.c
parentd6b29f48d161b05ce721c613edaa9b0f1e89091d (diff)
downloadgnunet-98760f1bfe7a96e87f762c6948825f12ab9bb736.tar.gz
gnunet-98760f1bfe7a96e87f762c6948825f12ab9bb736.zip
do not allow more than one notify_transmit_ready per tunnel
Diffstat (limited to 'src/mesh/mesh_api.c')
-rw-r--r--src/mesh/mesh_api.c65
1 files changed, 40 insertions, 25 deletions
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index 57bea77e1..fc22cbeb4 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -73,6 +73,8 @@ struct GNUNET_MESH_Tunnel
73 */ 73 */
74 uint16_t application_type; 74 uint16_t application_type;
75 75
76 struct GNUNET_MESH_TransmitHandle* notify_handle;
77
76 /* The context of the receive-function. */ 78 /* The context of the receive-function. */
77 void *ctx; 79 void *ctx;
78}; 80};
@@ -611,6 +613,7 @@ core_notify(void* cls, size_t size, void* buf)
611{ 613{
612 struct notify_cls *ncls = cls; 614 struct notify_cls *ncls = cls;
613 struct GNUNET_MESH_Tunnel *tunnel = ncls->tunnel; 615 struct GNUNET_MESH_Tunnel *tunnel = ncls->tunnel;
616 tunnel->notify_handle = NULL;
614 struct tunnel_message* message = buf; 617 struct tunnel_message* message = buf;
615 void* cbuf = (void*) &message[1]; 618 void* cbuf = (void*) &message[1];
616 GNUNET_assert(NULL != ncls->notify); 619 GNUNET_assert(NULL != ncls->notify);
@@ -653,35 +656,47 @@ core_notify(void* cls, size_t size, void* buf)
653 */ 656 */
654struct GNUNET_MESH_TransmitHandle * 657struct GNUNET_MESH_TransmitHandle *
655GNUNET_MESH_notify_transmit_ready (struct 658GNUNET_MESH_notify_transmit_ready (struct
656 GNUNET_MESH_Tunnel 659 GNUNET_MESH_Tunnel
657 *tunnel, 660 *tunnel,
658 int cork, 661 int cork,
659 uint32_t priority, 662 uint32_t priority,
660 struct 663 struct
661 GNUNET_TIME_Relative 664 GNUNET_TIME_Relative
662 maxdelay, 665 maxdelay,
663 const struct GNUNET_PeerIdentity *target __attribute__((unused)), 666 const struct GNUNET_PeerIdentity *target
664 size_t 667 __attribute__ ((unused)),
665 notify_size, 668 size_t notify_size,
666 GNUNET_CONNECTION_TransmitReadyNotify 669 GNUNET_CONNECTION_TransmitReadyNotify
667 notify, void *notify_cls) 670 notify, void *notify_cls)
668{ 671{
669 struct notify_cls *cls = GNUNET_malloc(sizeof(struct notify_cls)); 672 if (NULL != tunnel->notify_handle)
673 {
674 GNUNET_break(0);
675 return NULL;
676 }
677
678 struct notify_cls *cls = GNUNET_malloc (sizeof (struct notify_cls));
670 cls->notify_cls = notify_cls; 679 cls->notify_cls = notify_cls;
671 GNUNET_assert(NULL != notify); 680 GNUNET_assert (NULL != notify);
672 cls->notify = notify; 681 cls->notify = notify;
673 cls->tunnel = tunnel; 682 cls->tunnel = tunnel;
674 GNUNET_CORE_notify_transmit_ready(tunnel->handle->core, 683
675 cork, 684 tunnel->notify_handle = (struct GNUNET_MESH_TransmitHandle *)
676 priority, 685 GNUNET_CORE_notify_transmit_ready (tunnel->handle->core, cork, priority,
677 maxdelay, 686 maxdelay, &tunnel->peer,
678 &tunnel->peer, 687 notify_size +
679 notify_size + sizeof(struct tunnel_message), 688 sizeof (struct tunnel_message),
680 &core_notify, 689 &core_notify, (void *) cls);
681 (void*)cls); 690
682 691 return tunnel->notify_handle;
683 /* aborting is not implemented yet */ 692}
684 return (struct GNUNET_MESH_TransmitHandle*) 1; 693
694void
695GNUNET_MESH_notify_transmit_ready_cancel (struct GNUNET_MESH_TransmitHandle
696 *th)
697{
698 GNUNET_CORE_notify_transmit_ready_cancel ((struct GNUNET_CORE_TransmitHandle
699 *) th);
685} 700}
686 701
687void build_hello_message(struct GNUNET_MESH_Handle* handle, 702void build_hello_message(struct GNUNET_MESH_Handle* handle,