diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-09-28 22:09:27 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-09-28 22:09:27 +0000 |
commit | 22af28fc22725c597831367fa3742070dfa449a8 (patch) | |
tree | eb08cb2dd97fe816b703c54a01452785112b0f4e /src/core/gnunet-service-core.c | |
parent | bca283abc269e0794226b82d16b762ed68718a91 (diff) | |
download | gnunet-22af28fc22725c597831367fa3742070dfa449a8.tar.gz gnunet-22af28fc22725c597831367fa3742070dfa449a8.zip |
-cleaning up implementation of typemap signalling
Diffstat (limited to 'src/core/gnunet-service-core.c')
-rw-r--r-- | src/core/gnunet-service-core.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 3964f4066..b0d7b24ba 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -89,6 +89,12 @@ struct GSC_Client | |||
89 | uint32_t options; | 89 | uint32_t options; |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Have we gotten the #GNUNET_MESSAGE_TYPE_CORE_INIT message | ||
93 | * from this client already? | ||
94 | */ | ||
95 | int got_init; | ||
96 | |||
97 | /** | ||
92 | * Number of types of incoming messages this client | 98 | * Number of types of incoming messages this client |
93 | * specifically cares about. Size of the @e types array. | 99 | * specifically cares about. Size of the @e types array. |
94 | */ | 100 | */ |
@@ -140,7 +146,7 @@ type_match (uint16_t type, | |||
140 | struct GSC_Client *c) | 146 | struct GSC_Client *c) |
141 | { | 147 | { |
142 | if ( (0 == c->tcnt) && | 148 | if ( (0 == c->tcnt) && |
143 | (0 != (c->options & ~GNUNET_CORE_OPTION_INIT)) ) | 149 | (0 != c->options) ) |
144 | return GNUNET_YES; /* peer without handlers and inbound/outbond | 150 | return GNUNET_YES; /* peer without handlers and inbound/outbond |
145 | callbacks matches ALL */ | 151 | callbacks matches ALL */ |
146 | if (NULL == c->types) | 152 | if (NULL == c->types) |
@@ -188,6 +194,7 @@ handle_client_init (void *cls, | |||
188 | types = (const uint16_t *) &im[1]; | 194 | types = (const uint16_t *) &im[1]; |
189 | c->tcnt = msize / sizeof (uint16_t); | 195 | c->tcnt = msize / sizeof (uint16_t); |
190 | c->options = ntohl (im->options); | 196 | c->options = ntohl (im->options); |
197 | c->got_init = GNUNET_YES; | ||
191 | all_client_options |= c->options; | 198 | all_client_options |= c->options; |
192 | c->types = GNUNET_malloc (msize); | 199 | c->types = GNUNET_malloc (msize); |
193 | GNUNET_assert (GNUNET_YES == | 200 | GNUNET_assert (GNUNET_YES == |
@@ -681,22 +688,21 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client, | |||
681 | int old_match; | 688 | int old_match; |
682 | int new_match; | 689 | int new_match; |
683 | 690 | ||
691 | if (GNUNET_YES != client->got_init) | ||
692 | return; | ||
684 | old_match = GSC_TYPEMAP_test_match (tmap_old, | 693 | old_match = GSC_TYPEMAP_test_match (tmap_old, |
685 | client->types, | 694 | client->types, |
686 | client->tcnt); | 695 | client->tcnt); |
687 | new_match = GSC_TYPEMAP_test_match (tmap_new, | 696 | new_match = GSC_TYPEMAP_test_match (tmap_new, |
688 | client->types, | 697 | client->types, |
689 | client->tcnt); | 698 | client->tcnt); |
690 | if ( (old_match == new_match) && | 699 | if (old_match == new_match) |
691 | (GNUNET_CORE_OPTION_INIT != (client->options & GNUNET_CORE_OPTION_INIT)) ) | ||
692 | { | 700 | { |
693 | GNUNET_assert (old_match == | 701 | GNUNET_assert (old_match == |
694 | GNUNET_CONTAINER_multipeermap_contains (client->connectmap, | 702 | GNUNET_CONTAINER_multipeermap_contains (client->connectmap, |
695 | neighbour)); | 703 | neighbour)); |
696 | return; /* no change */ | 704 | return; /* no change */ |
697 | } | 705 | } |
698 | if (old_match == new_match) | ||
699 | return; /* no change, but the client simply didn't INIT yet */ | ||
700 | if (GNUNET_NO == old_match) | 706 | if (GNUNET_NO == old_match) |
701 | { | 707 | { |
702 | struct ConnectNotifyMessage *cnm; | 708 | struct ConnectNotifyMessage *cnm; |
@@ -789,7 +795,7 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender, | |||
789 | GNUNET_break (0); | 795 | GNUNET_break (0); |
790 | return; | 796 | return; |
791 | } | 797 | } |
792 | if (! ( (0 != (all_client_options & options & ~GNUNET_CORE_OPTION_INIT)) || | 798 | if (! ( (0 != (all_client_options & options)) || |
793 | (0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) )) | 799 | (0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) )) |
794 | return; /* no client cares about this message notification */ | 800 | return; /* no client cares about this message notification */ |
795 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 801 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -808,7 +814,7 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender, | |||
808 | 814 | ||
809 | tm = type_match (ntohs (msg->type), | 815 | tm = type_match (ntohs (msg->type), |
810 | c); | 816 | c); |
811 | if (! ( (0 != (c->options & options & ~GNUNET_CORE_OPTION_INIT)) || | 817 | if (! ( (0 != (c->options & options)) || |
812 | ( (0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) && | 818 | ( (0 != (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) && |
813 | (GNUNET_YES == tm) ) ) ) | 819 | (GNUNET_YES == tm) ) ) ) |
814 | continue; /* neither options nor type match permit the message */ | 820 | continue; /* neither options nor type match permit the message */ |