aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-09-26 23:18:33 +0000
committerChristian Grothoff <christian@grothoff.org>2016-09-26 23:18:33 +0000
commit7fb1bee61c0fd70255fa57061b7422fdaebe113c (patch)
tree2d713c199d44e4e8dc08b027f76f90dcd4179390 /src/core
parent0bf8817f025818c83d31eea23203a2c99ba83f7e (diff)
downloadgnunet-7fb1bee61c0fd70255fa57061b7422fdaebe113c.tar.gz
gnunet-7fb1bee61c0fd70255fa57061b7422fdaebe113c.zip
init connect map on connect
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gnunet-service-core.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index acaa10092..2cf43f111 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -63,14 +63,14 @@ struct GSC_Client
63 * Message queue to talk to @e client. 63 * Message queue to talk to @e client.
64 */ 64 */
65 struct GNUNET_MQ_Handle *mq; 65 struct GNUNET_MQ_Handle *mq;
66 66
67 /** 67 /**
68 * Array of the types of messages this peer cares 68 * Array of the types of messages this peer cares
69 * about (with @e tcnt entries). Allocated as part 69 * about (with @e tcnt entries). Allocated as part
70 * of this client struct, do not free! 70 * of this client struct, do not free!
71 */ 71 */
72 uint16_t *types; 72 uint16_t *types;
73 73
74 /** 74 /**
75 * Map of peer identities to active transmission requests of this 75 * Map of peer identities to active transmission requests of this
76 * client to the peer (of type `struct GSC_ClientActiveRequest`). 76 * client to the peer (of type `struct GSC_ClientActiveRequest`).
@@ -156,7 +156,7 @@ type_match (uint16_t type,
156 * Check #GNUNET_MESSAGE_TYPE_CORE_INIT request. 156 * Check #GNUNET_MESSAGE_TYPE_CORE_INIT request.
157 * 157 *
158 * @param cls client that sent #GNUNET_MESSAGE_TYPE_CORE_INIT 158 * @param cls client that sent #GNUNET_MESSAGE_TYPE_CORE_INIT
159 * @param im the `struct InitMessage` 159 * @param im the `struct InitMessage`
160 * @return #GNUNET_OK if @a im is well-formed 160 * @return #GNUNET_OK if @a im is well-formed
161 */ 161 */
162static int 162static int
@@ -171,7 +171,7 @@ check_client_init (void *cls,
171 * Handle #GNUNET_MESSAGE_TYPE_CORE_INIT request. 171 * Handle #GNUNET_MESSAGE_TYPE_CORE_INIT request.
172 * 172 *
173 * @param cls client that sent #GNUNET_MESSAGE_TYPE_CORE_INIT 173 * @param cls client that sent #GNUNET_MESSAGE_TYPE_CORE_INIT
174 * @param im the `struct InitMessage` 174 * @param im the `struct InitMessage`
175 */ 175 */
176static void 176static void
177handle_client_init (void *cls, 177handle_client_init (void *cls,
@@ -190,8 +190,6 @@ handle_client_init (void *cls,
190 c->options = ntohl (im->options); 190 c->options = ntohl (im->options);
191 all_client_options |= c->options; 191 all_client_options |= c->options;
192 c->types = GNUNET_malloc (msize); 192 c->types = GNUNET_malloc (msize);
193 c->connectmap = GNUNET_CONTAINER_multipeermap_create (16,
194 GNUNET_NO);
195 GNUNET_assert (GNUNET_YES == 193 GNUNET_assert (GNUNET_YES ==
196 GNUNET_CONTAINER_multipeermap_put (c->connectmap, 194 GNUNET_CONTAINER_multipeermap_put (c->connectmap,
197 &GSC_my_identity, 195 &GSC_my_identity,
@@ -606,10 +604,12 @@ client_connect_cb (void *cls,
606 struct GNUNET_MQ_Handle *mq) 604 struct GNUNET_MQ_Handle *mq)
607{ 605{
608 struct GSC_Client *c; 606 struct GSC_Client *c;
609 607
610 c = GNUNET_new (struct GSC_Client); 608 c = GNUNET_new (struct GSC_Client);
611 c->client = client; 609 c->client = client;
612 c->mq = mq; 610 c->mq = mq;
611 c->connectmap = GNUNET_CONTAINER_multipeermap_create (16,
612 GNUNET_NO);
613 GNUNET_CONTAINER_DLL_insert (client_head, 613 GNUNET_CONTAINER_DLL_insert (client_head,
614 client_tail, 614 client_tail,
615 c); 615 c);
@@ -644,11 +644,8 @@ client_disconnect_cb (void *cls,
644 NULL); 644 NULL);
645 GNUNET_CONTAINER_multipeermap_destroy (c->requests); 645 GNUNET_CONTAINER_multipeermap_destroy (c->requests);
646 } 646 }
647 if (NULL != c->connectmap) 647 GNUNET_CONTAINER_multipeermap_destroy (c->connectmap);
648 { 648 c->connectmap = NULL;
649 GNUNET_CONTAINER_multipeermap_destroy (c->connectmap);
650 c->connectmap = NULL;
651 }
652 if (NULL != c->types) 649 if (NULL != c->types)
653 { 650 {
654 GSC_TYPEMAP_remove (c->types, 651 GSC_TYPEMAP_remove (c->types,
@@ -844,7 +841,7 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
844 sender)) ); 841 sender)) );
845 GNUNET_MQ_send (c->mq, 842 GNUNET_MQ_send (c->mq,
846 env); 843 env);
847 } 844 }
848} 845}
849 846
850 847
@@ -890,7 +887,7 @@ handle_client_monitor_peers (void *cls,
890 const struct GNUNET_MessageHeader *message) 887 const struct GNUNET_MessageHeader *message)
891{ 888{
892 struct GSC_Client *c = cls; 889 struct GSC_Client *c = cls;
893 890
894 GNUNET_SERVICE_client_continue (c->client); 891 GNUNET_SERVICE_client_continue (c->client);
895 GSC_KX_handle_client_monitor_peers (c->mq); 892 GSC_KX_handle_client_monitor_peers (c->mq);
896} 893}
@@ -957,7 +954,7 @@ GNUNET_SERVICE_MAIN
957 NULL, 954 NULL,
958 GNUNET_MQ_hd_var_size (client_init, 955 GNUNET_MQ_hd_var_size (client_init,
959 GNUNET_MESSAGE_TYPE_CORE_INIT, 956 GNUNET_MESSAGE_TYPE_CORE_INIT,
960 struct InitMessage, 957 struct InitMessage,
961 NULL), 958 NULL),
962 GNUNET_MQ_hd_fixed_size (client_monitor_peers, 959 GNUNET_MQ_hd_fixed_size (client_monitor_peers,
963 GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS, 960 GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS,