aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/cadet_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-23 23:17:38 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-23 23:17:38 +0100
commit3ceefffec0e038099c3fabfea70d0f9202e298d2 (patch)
tree058292889daceef41f0a0a01b5c62651c5742978 /src/cadet/cadet_api.c
parent5c1ac597f1d1f532136dcf678d7eb5575224aa6b (diff)
downloadgnunet-3ceefffec0e038099c3fabfea70d0f9202e298d2.tar.gz
gnunet-3ceefffec0e038099c3fabfea70d0f9202e298d2.zip
avoid cmp pointers, cmp ccn instead, as client may literally be the same
Diffstat (limited to 'src/cadet/cadet_api.c')
-rw-r--r--src/cadet/cadet_api.c68
1 files changed, 30 insertions, 38 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index de10d5809..53a954810 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -558,8 +558,9 @@ request_data (void *cls)
558 size_t osize; 558 size_t osize;
559 559
560 LOG (GNUNET_ERROR_TYPE_DEBUG, 560 LOG (GNUNET_ERROR_TYPE_DEBUG,
561 "Requesting Data: %u bytes\n", 561 "Requesting Data: %u bytes (allow send is %u)\n",
562 th->size); 562 th->size,
563 th->channel->allow_send);
563 564
564 GNUNET_assert (0 < th->channel->allow_send); 565 GNUNET_assert (0 < th->channel->allow_send);
565 th->channel->allow_send--; 566 th->channel->allow_send--;
@@ -727,41 +728,34 @@ handle_local_data (void *cls,
727 unsigned int i; 728 unsigned int i;
728 uint16_t type; 729 uint16_t type;
729 730
730 LOG (GNUNET_ERROR_TYPE_DEBUG,
731 "Got a data message!\n");
732 ch = retrieve_channel (h, 731 ch = retrieve_channel (h,
733 message->ccn); 732 message->ccn);
734 GNUNET_assert (NULL != ch); 733 GNUNET_assert (NULL != ch);
735 734
736 payload = (struct GNUNET_MessageHeader *) &message[1]; 735 payload = (struct GNUNET_MessageHeader *) &message[1];
737 LOG (GNUNET_ERROR_TYPE_DEBUG, " %s data on channel %s [%X]\n", 736 type = ntohs (payload->type);
737 LOG (GNUNET_ERROR_TYPE_DEBUG,
738 "Got a %s data on channel %s [%X] of type %s\n",
738 GC_f2s (ntohl (ch->ccn.channel_of_client) >= 739 GC_f2s (ntohl (ch->ccn.channel_of_client) >=
739 GNUNET_CADET_LOCAL_CHANNEL_ID_CLI), 740 GNUNET_CADET_LOCAL_CHANNEL_ID_CLI),
740 GNUNET_i2s (GNUNET_PEER_resolve2 (ch->peer)), 741 GNUNET_i2s (GNUNET_PEER_resolve2 (ch->peer)),
741 ntohl (message->ccn.channel_of_client)); 742 ntohl (message->ccn.channel_of_client),
743 GC_m2s (type));
742 744
743 type = ntohs (payload->type);
744 LOG (GNUNET_ERROR_TYPE_DEBUG, " payload type %s\n", GC_m2s (type));
745 for (i = 0; i < h->n_handlers; i++) 745 for (i = 0; i < h->n_handlers; i++)
746 { 746 {
747 handler = &h->message_handlers[i]; 747 handler = &h->message_handlers[i];
748 LOG (GNUNET_ERROR_TYPE_DEBUG, " checking handler for type %u\n",
749 handler->type);
750 if (handler->type == type) 748 if (handler->type == type)
751 { 749 {
752 if (GNUNET_OK != 750 if (GNUNET_OK !=
753 handler->callback (h->cls, ch, &ch->ctx, payload)) 751 handler->callback (h->cls, ch, &ch->ctx, payload))
754 { 752 {
755 LOG (GNUNET_ERROR_TYPE_DEBUG, "callback caused disconnection\n");
756 GNUNET_CADET_channel_destroy (ch);
757 break;
758 }
759 else
760 {
761 LOG (GNUNET_ERROR_TYPE_DEBUG, 753 LOG (GNUNET_ERROR_TYPE_DEBUG,
762 "callback completed successfully\n"); 754 "callback caused disconnection\n");
755 GNUNET_CADET_channel_destroy (ch);
763 break; 756 break;
764 } 757 }
758 break;
765 } 759 }
766 } 760 }
767} 761}
@@ -792,12 +786,11 @@ handle_local_ack (void *cls,
792 ntohl (ccn.channel_of_client)); 786 ntohl (ccn.channel_of_client));
793 return; 787 return;
794 } 788 }
795 LOG (GNUNET_ERROR_TYPE_DEBUG,
796 "Got an ACK on channel %X!\n",
797 ntohl (ch->ccn.channel_of_client));
798 ch->allow_send++; 789 ch->allow_send++;
799 LOG (GNUNET_ERROR_TYPE_DEBUG, 790 LOG (GNUNET_ERROR_TYPE_DEBUG,
800 "Checking for pending data\n"); 791 "Got an ACK on channel %X, allow send now %u!\n",
792 ntohl (ch->ccn.channel_of_client),
793 ch->allow_send);
801 for (th = h->th_head; NULL != th; th = th->next) 794 for (th = h->th_head; NULL != th; th = th->next)
802 { 795 {
803 if ( (th->channel == ch) && 796 if ( (th->channel == ch) &&
@@ -1269,8 +1262,7 @@ handle_get_tunnel (void *cls,
1269 * original state. 1262 * original state.
1270 * 1263 *
1271 * @param h handle to the cadet 1264 * @param h handle to the cadet
1272 * 1265 * @return #GNUNET_YES in case of success, #GNUNET_NO otherwise (service down...)
1273 * @return GNUNET_YES in case of sucess, GNUNET_NO otherwise (service down...)
1274 */ 1266 */
1275static int 1267static int
1276do_reconnect (struct GNUNET_CADET_Handle *h) 1268do_reconnect (struct GNUNET_CADET_Handle *h)
@@ -1701,17 +1693,17 @@ GNUNET_CADET_notify_transmit_ready (struct GNUNET_CADET_Channel *channel,
1701 struct GNUNET_CADET_TransmitHandle *th; 1693 struct GNUNET_CADET_TransmitHandle *th;
1702 1694
1703 GNUNET_assert (NULL != channel); 1695 GNUNET_assert (NULL != channel);
1704 GNUNET_assert (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE >= notify_size);
1705 LOG (GNUNET_ERROR_TYPE_DEBUG, "CADET NOTIFY TRANSMIT READY\n");
1706 LOG (GNUNET_ERROR_TYPE_DEBUG, " on channel %X\n", channel->ccn);
1707 LOG (GNUNET_ERROR_TYPE_DEBUG, " allow_send %d\n", channel->allow_send);
1708 if (ntohl (channel->ccn.channel_of_client) >=
1709 GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
1710 LOG (GNUNET_ERROR_TYPE_DEBUG, " to origin\n");
1711 else
1712 LOG (GNUNET_ERROR_TYPE_DEBUG, " to destination\n");
1713 LOG (GNUNET_ERROR_TYPE_DEBUG, " payload size %u\n", notify_size);
1714 GNUNET_assert (NULL != notify); 1696 GNUNET_assert (NULL != notify);
1697 GNUNET_assert (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE >= notify_size);
1698 LOG (GNUNET_ERROR_TYPE_DEBUG,
1699 "CADET NOTIFY TRANSMIT READY on channel %X allow_send is %u to %s with %u bytes\n",
1700 channel->ccn,
1701 channel->allow_send,
1702 (ntohl (channel->ccn.channel_of_client) >=
1703 GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
1704 ? "origin"
1705 : "destination",
1706 (unsigned int) notify_size);
1715 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != maxdelay.rel_value_us) 1707 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != maxdelay.rel_value_us)
1716 { 1708 {
1717 LOG (GNUNET_ERROR_TYPE_WARNING, 1709 LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -1721,15 +1713,15 @@ GNUNET_CADET_notify_transmit_ready (struct GNUNET_CADET_Channel *channel,
1721 th = GNUNET_new (struct GNUNET_CADET_TransmitHandle); 1713 th = GNUNET_new (struct GNUNET_CADET_TransmitHandle);
1722 th->channel = channel; 1714 th->channel = channel;
1723 th->size = notify_size; 1715 th->size = notify_size;
1724 LOG (GNUNET_ERROR_TYPE_DEBUG, " total size %u\n", th->size);
1725 th->notify = notify; 1716 th->notify = notify;
1726 th->notify_cls = notify_cls; 1717 th->notify_cls = notify_cls;
1727 if (0 != channel->allow_send) 1718 if (0 != channel->allow_send)
1728 th->request_data_task = GNUNET_SCHEDULER_add_now (&request_data, th); 1719 th->request_data_task
1720 = GNUNET_SCHEDULER_add_now (&request_data,
1721 th);
1729 else 1722 else
1730 add_to_queue (channel->cadet, th); 1723 add_to_queue (channel->cadet,
1731 1724 th);
1732 LOG (GNUNET_ERROR_TYPE_DEBUG, "CADET NOTIFY TRANSMIT READY END\n");
1733 return th; 1725 return th;
1734} 1726}
1735 1727