diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-02-24 19:06:37 +0100 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-02-24 19:06:37 +0100 |
commit | 46111957db87028c369ea4792b9c533a9dd09a33 (patch) | |
tree | ceb6b5bec9d440fa81a7f05d4561874ba7fb0d06 /src | |
parent | 52516482b8c9e67cadedff1da77313fd79abf4d1 (diff) | |
download | gnunet-46111957db87028c369ea4792b9c533a9dd09a33.tar.gz gnunet-46111957db87028c369ea4792b9c533a9dd09a33.zip |
-sending messages working
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-tng.c | 111 | ||||
-rw-r--r-- | src/transport/transport-testing2.c | 9 | ||||
-rw-r--r-- | src/transport/transport_api2_communication.c | 2 |
3 files changed, 73 insertions, 49 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 8357947dd..f57d08395 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -3551,6 +3551,8 @@ free_queue (struct Queue *queue) | |||
3551 | struct PendingAcknowledgement *pa; | 3551 | struct PendingAcknowledgement *pa; |
3552 | struct VirtualLink *vl; | 3552 | struct VirtualLink *vl; |
3553 | 3553 | ||
3554 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3555 | "Cleaning up queue %u\n", queue->qid); | ||
3554 | if (NULL != queue->transmit_task) | 3556 | if (NULL != queue->transmit_task) |
3555 | { | 3557 | { |
3556 | GNUNET_SCHEDULER_cancel (queue->transmit_task); | 3558 | GNUNET_SCHEDULER_cancel (queue->transmit_task); |
@@ -4161,7 +4163,7 @@ queue_send_msg (struct Queue *queue, | |||
4161 | struct GNUNET_TRANSPORT_SendMessageTo *smt; | 4163 | struct GNUNET_TRANSPORT_SendMessageTo *smt; |
4162 | struct GNUNET_MQ_Envelope *env; | 4164 | struct GNUNET_MQ_Envelope *env; |
4163 | 4165 | ||
4164 | //queue->idle = GNUNET_NO; | 4166 | // queue->idle = GNUNET_NO; |
4165 | GNUNET_log ( | 4167 | GNUNET_log ( |
4166 | GNUNET_ERROR_TYPE_DEBUG, | 4168 | GNUNET_ERROR_TYPE_DEBUG, |
4167 | "Queueing %u bytes of payload for transmission <%llu> on queue %llu to %s\n", | 4169 | "Queueing %u bytes of payload for transmission <%llu> on queue %llu to %s\n", |
@@ -9592,57 +9594,71 @@ handle_add_queue_message (void *cls, | |||
9592 | GNUNET_SERVICE_client_drop (tc->client); | 9594 | GNUNET_SERVICE_client_drop (tc->client); |
9593 | return; | 9595 | return; |
9594 | } | 9596 | } |
9595 | neighbour = lookup_neighbour (&aqm->receiver); | 9597 | /* This may simply be a queue update */ |
9596 | if (NULL == neighbour) | 9598 | for (queue = tc->details.communicator.queue_head; |
9599 | NULL != queue; | ||
9600 | queue = queue->next_client) | ||
9597 | { | 9601 | { |
9598 | neighbour = GNUNET_new (struct Neighbour); | 9602 | if (queue->qid != aqm->qid) |
9599 | neighbour->pid = aqm->receiver; | 9603 | continue; |
9600 | GNUNET_assert (GNUNET_OK == | 9604 | neighbour = queue->neighbour; |
9601 | GNUNET_CONTAINER_multipeermap_put ( | 9605 | break; |
9602 | neighbours, | 9606 | } |
9603 | &neighbour->pid, | 9607 | if (NULL == queue) |
9604 | neighbour, | 9608 | { |
9605 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 9609 | neighbour = lookup_neighbour (&aqm->receiver); |
9606 | neighbour->get = | 9610 | if (NULL == neighbour) |
9607 | GNUNET_PEERSTORE_iterate (peerstore, | 9611 | { |
9608 | "transport", | 9612 | neighbour = GNUNET_new (struct Neighbour); |
9609 | &neighbour->pid, | 9613 | neighbour->pid = aqm->receiver; |
9610 | GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME, | 9614 | GNUNET_assert (GNUNET_OK == |
9611 | &neighbour_dv_monotime_cb, | 9615 | GNUNET_CONTAINER_multipeermap_put ( |
9612 | neighbour); | 9616 | neighbours, |
9617 | &neighbour->pid, | ||
9618 | neighbour, | ||
9619 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
9620 | neighbour->get = | ||
9621 | GNUNET_PEERSTORE_iterate (peerstore, | ||
9622 | "transport", | ||
9623 | &neighbour->pid, | ||
9624 | GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME, | ||
9625 | &neighbour_dv_monotime_cb, | ||
9626 | neighbour); | ||
9627 | } | ||
9628 | addr_len = ntohs (aqm->header.size) - sizeof(*aqm); | ||
9629 | addr = (const char *) &aqm[1]; | ||
9630 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
9631 | "New queue %s to %s available with QID %llu\n", | ||
9632 | addr, | ||
9633 | GNUNET_i2s (&aqm->receiver), | ||
9634 | (unsigned long long) aqm->qid); | ||
9635 | queue = GNUNET_malloc (sizeof(struct Queue) + addr_len); | ||
9636 | queue->tc = tc; | ||
9637 | queue->address = (const char *) &queue[1]; | ||
9638 | queue->pd.aged_rtt = GNUNET_TIME_UNIT_FOREVER_REL; | ||
9639 | queue->qid = aqm->qid; | ||
9640 | queue->neighbour = neighbour; | ||
9641 | memcpy (&queue[1], addr, addr_len); | ||
9642 | /* notify monitors about new queue */ | ||
9643 | { | ||
9644 | struct MonitorEvent me = { .rtt = queue->pd.aged_rtt, .cs = queue->cs }; | ||
9645 | |||
9646 | notify_monitors (&neighbour->pid, queue->address, queue->nt, &me); | ||
9647 | } | ||
9648 | GNUNET_CONTAINER_MDLL_insert (neighbour, | ||
9649 | neighbour->queue_head, | ||
9650 | neighbour->queue_tail, | ||
9651 | queue); | ||
9652 | GNUNET_CONTAINER_MDLL_insert (client, | ||
9653 | tc->details.communicator.queue_head, | ||
9654 | tc->details.communicator.queue_tail, | ||
9655 | queue); | ||
9656 | |||
9613 | } | 9657 | } |
9614 | addr_len = ntohs (aqm->header.size) - sizeof(*aqm); | ||
9615 | addr = (const char *) &aqm[1]; | ||
9616 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
9617 | "New queue %s to %s available with QID %llu\n", | ||
9618 | addr, | ||
9619 | GNUNET_i2s (&aqm->receiver), | ||
9620 | (unsigned long long) aqm->qid); | ||
9621 | queue = GNUNET_malloc (sizeof(struct Queue) + addr_len); | ||
9622 | queue->tc = tc; | ||
9623 | queue->address = (const char *) &queue[1]; | ||
9624 | queue->pd.aged_rtt = GNUNET_TIME_UNIT_FOREVER_REL; | ||
9625 | queue->qid = aqm->qid; | ||
9626 | queue->mtu = ntohl (aqm->mtu); | 9658 | queue->mtu = ntohl (aqm->mtu); |
9627 | queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt); | 9659 | queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt); |
9628 | queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs); | 9660 | queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs); |
9629 | queue->neighbour = neighbour; | ||
9630 | queue->idle = GNUNET_YES; | 9661 | queue->idle = GNUNET_YES; |
9631 | memcpy (&queue[1], addr, addr_len); | ||
9632 | /* notify monitors about new queue */ | ||
9633 | { | ||
9634 | struct MonitorEvent me = { .rtt = queue->pd.aged_rtt, .cs = queue->cs }; | ||
9635 | |||
9636 | notify_monitors (&neighbour->pid, queue->address, queue->nt, &me); | ||
9637 | } | ||
9638 | GNUNET_CONTAINER_MDLL_insert (neighbour, | ||
9639 | neighbour->queue_head, | ||
9640 | neighbour->queue_tail, | ||
9641 | queue); | ||
9642 | GNUNET_CONTAINER_MDLL_insert (client, | ||
9643 | tc->details.communicator.queue_head, | ||
9644 | tc->details.communicator.queue_tail, | ||
9645 | queue); | ||
9646 | /* check if valdiations are waiting for the queue */ | 9662 | /* check if valdiations are waiting for the queue */ |
9647 | (void) | 9663 | (void) |
9648 | GNUNET_CONTAINER_multipeermap_get_multiple (validation_map, | 9664 | GNUNET_CONTAINER_multipeermap_get_multiple (validation_map, |
@@ -10043,7 +10059,8 @@ do_shutdown (void *cls) | |||
10043 | 10059 | ||
10044 | (void) cls; | 10060 | (void) cls; |
10045 | 10061 | ||
10046 | GNUNET_CONTAINER_multipeermap_iterate (neighbours, &free_neighbour_cb, NULL); | 10062 | //GNUNET_CONTAINER_multipeermap_iterate (neighbours, |
10063 | //&free_neighbour_cb, NULL); | ||
10047 | if (NULL != peerstore) | 10064 | if (NULL != peerstore) |
10048 | { | 10065 | { |
10049 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO); | 10066 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO); |
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index ee0c4494e..d553a3961 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -337,6 +337,7 @@ hello_iter_cb (void *cb_cls, | |||
337 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cb_cls; | 337 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cb_cls; |
338 | if ((NULL == record) && (NULL == emsg)) | 338 | if ((NULL == record) && (NULL == emsg)) |
339 | { | 339 | { |
340 | p->pic = NULL; | ||
340 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration End\n"); | 341 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration End\n"); |
341 | return; | 342 | return; |
342 | } | 343 | } |
@@ -347,6 +348,7 @@ hello_iter_cb (void *cb_cls, | |||
347 | p->hello[p->hello_size-1] = '\0'; | 348 | p->hello[p->hello_size-1] = '\0'; |
348 | 349 | ||
349 | GNUNET_PEERSTORE_iterate_cancel (p->pic); | 350 | GNUNET_PEERSTORE_iterate_cancel (p->pic); |
351 | p->pic = NULL; | ||
350 | if (NULL != p->start_cb) | 352 | if (NULL != p->start_cb) |
351 | { | 353 | { |
352 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 354 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -658,7 +660,7 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct | |||
658 | } | 660 | } |
659 | if (NULL != p->pic) | 661 | if (NULL != p->pic) |
660 | { | 662 | { |
661 | GNUNET_PEERSTORE_iterate_cancel (p->pic); | 663 | //GNUNET_PEERSTORE_iterate_cancel (p->pic); |
662 | p->pic = NULL; | 664 | p->pic = NULL; |
663 | } | 665 | } |
664 | if (NULL != p->th) | 666 | if (NULL != p->th) |
@@ -684,6 +686,11 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct | |||
684 | GNUNET_ATS_connectivity_done (p->ats); | 686 | GNUNET_ATS_connectivity_done (p->ats); |
685 | p->ats = NULL; | 687 | p->ats = NULL; |
686 | } | 688 | } |
689 | if (NULL != p->ah) | ||
690 | { | ||
691 | GNUNET_TRANSPORT_application_done (p->ah); | ||
692 | p->ah = NULL; | ||
693 | } | ||
687 | if (NULL != p->ph) | 694 | if (NULL != p->ph) |
688 | { | 695 | { |
689 | GNUNET_PEERSTORE_disconnect (p->ph, GNUNET_NO); | 696 | GNUNET_PEERSTORE_disconnect (p->ph, GNUNET_NO); |
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c index b048ad851..3d9da08e4 100644 --- a/src/transport/transport_api2_communication.c +++ b/src/transport/transport_api2_communication.c | |||
@@ -677,7 +677,7 @@ handle_send_msg (void *cls, const struct GNUNET_TRANSPORT_SendMessageTo *smt) | |||
677 | struct GNUNET_TRANSPORT_QueueHandle *qh; | 677 | struct GNUNET_TRANSPORT_QueueHandle *qh; |
678 | 678 | ||
679 | for (qh = ch->queue_head; NULL != qh; qh = qh->next) | 679 | for (qh = ch->queue_head; NULL != qh; qh = qh->next) |
680 | if ((qh->queue_id == smt->qid) && | 680 | if ((qh->queue_id == ntohl (smt->qid)) && |
681 | (0 == memcmp (&qh->peer, | 681 | (0 == memcmp (&qh->peer, |
682 | &smt->receiver, | 682 | &smt->receiver, |
683 | sizeof(struct GNUNET_PeerIdentity)))) | 683 | sizeof(struct GNUNET_PeerIdentity)))) |