diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-08-26 11:52:11 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-08-26 11:52:11 +0000 |
commit | f70fb3b412c14d85a0acc08dfde14dc7c720b76a (patch) | |
tree | c844890fc247b61be61d49f27376ab3287889d8a /src/transport/gnunet-service-transport_clients.c | |
parent | 07a8a7388c5e4bf6aa92f2e70d8c808ceb28174c (diff) | |
download | gnunet-f70fb3b412c14d85a0acc08dfde14dc7c720b76a.tar.gz gnunet-f70fb3b412c14d85a0acc08dfde14dc7c720b76a.zip |
fixed assertion in clients_handle_start():390
it is not possible to compare GNUNET_SERVER_Clients in lookup_client by comparing memory addresses since memory blocks are reused by server_lib
-> added unique id for each GNUNET_SERVER_Client
Diffstat (limited to 'src/transport/gnunet-service-transport_clients.c')
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 05ccbe60b..975cb03f6 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -109,6 +109,10 @@ struct TransportClient | |||
109 | */ | 109 | */ |
110 | unsigned int message_count; | 110 | unsigned int message_count; |
111 | 111 | ||
112 | /** | ||
113 | * GNUNET_SERVER_Client's unique id | ||
114 | */ | ||
115 | uint64_t server_client_id; | ||
112 | }; | 116 | }; |
113 | 117 | ||
114 | 118 | ||
@@ -122,7 +126,6 @@ static struct TransportClient *clients_head; | |||
122 | */ | 126 | */ |
123 | static struct TransportClient *clients_tail; | 127 | static struct TransportClient *clients_tail; |
124 | 128 | ||
125 | |||
126 | /** | 129 | /** |
127 | * Find the internal handle associated with the given client handle | 130 | * Find the internal handle associated with the given client handle |
128 | * | 131 | * |
@@ -137,7 +140,7 @@ lookup_client (struct GNUNET_SERVER_Client *client) | |||
137 | tc = clients_head; | 140 | tc = clients_head; |
138 | while (tc != NULL) | 141 | while (tc != NULL) |
139 | { | 142 | { |
140 | if (tc->client == client) | 143 | if (tc->server_client_id == GNUNET_SERVER_client_get_id (client)) |
141 | return tc; | 144 | return tc; |
142 | tc = tc->next; | 145 | tc = tc->next; |
143 | } | 146 | } |
@@ -156,8 +159,12 @@ setup_client (struct GNUNET_SERVER_Client *client) | |||
156 | { | 159 | { |
157 | struct TransportClient *tc; | 160 | struct TransportClient *tc; |
158 | 161 | ||
162 | GNUNET_assert (lookup_client (client) == NULL); | ||
163 | |||
159 | tc = GNUNET_malloc (sizeof (struct TransportClient)); | 164 | tc = GNUNET_malloc (sizeof (struct TransportClient)); |
160 | tc->client = client; | 165 | tc->client = client; |
166 | tc->server_client_id = GNUNET_SERVER_client_get_id (client); | ||
167 | |||
161 | GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc); | 168 | GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc); |
162 | return tc; | 169 | return tc; |
163 | } | 170 | } |
@@ -202,8 +209,8 @@ transmit_to_client_callback (void *cls, size_t size, void *buf) | |||
202 | break; | 209 | break; |
203 | #if DEBUG_TRANSPORT | 210 | #if DEBUG_TRANSPORT |
204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 211 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
205 | "Transmitting message of type %u to client.\n", | 212 | "Transmitting message of type %u to client %X.\n", |
206 | ntohs (msg->type)); | 213 | ntohs (msg->type), tc); |
207 | #endif | 214 | #endif |
208 | GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, tc->message_queue_tail, | 215 | GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, tc->message_queue_tail, |
209 | q); | 216 | q); |
@@ -289,7 +296,7 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client) | |||
289 | return; | 296 | return; |
290 | #if DEBUG_TRANSPORT | 297 | #if DEBUG_TRANSPORT |
291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 298 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
292 | "Client disconnected, cleaning up.\n"); | 299 | "Client %X disconnected, cleaning up.\n", tc); |
293 | #endif | 300 | #endif |
294 | while (NULL != (mqe = tc->message_queue_head)) | 301 | while (NULL != (mqe = tc->message_queue_head)) |
295 | { | 302 | { |
@@ -361,9 +368,25 @@ clients_handle_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
361 | struct TransportClient *tc; | 368 | struct TransportClient *tc; |
362 | 369 | ||
363 | tc = lookup_client (client); | 370 | tc = lookup_client (client); |
371 | |||
372 | #if DEBUG_TRANSPORT | ||
373 | if (tc != NULL) | ||
374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | ||
375 | "Client %X sent START\n", tc); | ||
376 | else | ||
377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | ||
378 | "Client %X sent START\n", tc); | ||
379 | #endif | ||
364 | if (tc != NULL) | 380 | if (tc != NULL) |
365 | { | 381 | { |
366 | /* got 'start' twice from the same client, not allowed */ | 382 | /* got 'start' twice from the same client, not allowed */ |
383 | #if DEBUG_TRANSPORT | ||
384 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | ||
385 | "TransportClient %X ServerClient %X id %llu sent multiple START messages\n", | ||
386 | tc, | ||
387 | tc->client, | ||
388 | tc->server_client_id); | ||
389 | #endif | ||
367 | GNUNET_break (0); | 390 | GNUNET_break (0); |
368 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 391 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
369 | return; | 392 | return; |
@@ -383,6 +406,7 @@ clients_handle_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
383 | return; | 406 | return; |
384 | } | 407 | } |
385 | tc = setup_client (client); | 408 | tc = setup_client (client); |
409 | |||
386 | unicast (tc, GST_hello_get (), GNUNET_NO); | 410 | unicast (tc, GST_hello_get (), GNUNET_NO); |
387 | GST_neighbours_iterate (¬ify_client_about_neighbour, tc); | 411 | GST_neighbours_iterate (¬ify_client_about_neighbour, tc); |
388 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 412 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
@@ -495,7 +519,8 @@ clients_handle_send (void *cls, struct GNUNET_SERVER_Client *client, | |||
495 | /* not connected, not allowed to send; can happen due to asynchronous operations */ | 519 | /* not connected, not allowed to send; can happen due to asynchronous operations */ |
496 | #if DEBUG_TRANSPORT | 520 | #if DEBUG_TRANSPORT |
497 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
498 | "Could not send message to peer `%s': not connected\n", GNUNET_i2s (&obm->peer)); | 522 | "Could not send message to peer `%s': not connected\n", |
523 | GNUNET_i2s (&obm->peer)); | ||
499 | #endif | 524 | #endif |
500 | GNUNET_STATISTICS_update (GST_stats, | 525 | GNUNET_STATISTICS_update (GST_stats, |
501 | gettext_noop | 526 | gettext_noop |