diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-06-17 15:02:17 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-06-17 15:02:17 +0000 |
commit | 78e016de05856066aed6acf5cdc601145c236f3b (patch) | |
tree | 0407b5f8e6ead1748089b082eaef7296c3521aaf /src/util/server_nc.c | |
parent | 4bd4079a7f05cdc99d3f36500f6501a6ffdfd6f4 (diff) | |
download | gnunet-78e016de05856066aed6acf5cdc601145c236f3b.tar.gz gnunet-78e016de05856066aed6acf5cdc601145c236f3b.zip |
cleanup
Diffstat (limited to 'src/util/server_nc.c')
-rw-r--r-- | src/util/server_nc.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/util/server_nc.c b/src/util/server_nc.c index 8dc92e44d..66c691239 100644 --- a/src/util/server_nc.c +++ b/src/util/server_nc.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_common.h" | 29 | #include "gnunet_common.h" |
30 | #include "gnunet_connection_lib.h" | 30 | #include "gnunet_connection_lib.h" |
31 | #include "gnunet_container_lib.h" | ||
31 | #include "gnunet_scheduler_lib.h" | 32 | #include "gnunet_scheduler_lib.h" |
32 | #include "gnunet_server_lib.h" | 33 | #include "gnunet_server_lib.h" |
33 | #include "gnunet_time_lib.h" | 34 | #include "gnunet_time_lib.h" |
@@ -42,11 +43,16 @@ struct PendingMessageList | |||
42 | { | 43 | { |
43 | 44 | ||
44 | /** | 45 | /** |
45 | * This is a linked list. | 46 | * This is a doubly-linked list. |
46 | */ | 47 | */ |
47 | struct PendingMessageList *next; | 48 | struct PendingMessageList *next; |
48 | 49 | ||
49 | /** | 50 | /** |
51 | * This is a doubly-linked list. | ||
52 | */ | ||
53 | struct PendingMessageList *prev; | ||
54 | |||
55 | /** | ||
50 | * Message to transmit (allocated at the end of this | 56 | * Message to transmit (allocated at the end of this |
51 | * struct, do not free) | 57 | * struct, do not free) |
52 | */ | 58 | */ |
@@ -175,7 +181,9 @@ handle_client_disconnect (void *cls, | |||
175 | prev->next = pos->next; | 181 | prev->next = pos->next; |
176 | while (NULL != (pml = pos->pending_head)) | 182 | while (NULL != (pml = pos->pending_head)) |
177 | { | 183 | { |
178 | pos->pending_head = pml->next; | 184 | GNUNET_CONTAINER_DLL_remove (pos->pending_head, |
185 | pos->pending_tail, | ||
186 | pml); | ||
179 | GNUNET_free (pml); | 187 | GNUNET_free (pml); |
180 | } | 188 | } |
181 | GNUNET_SERVER_client_drop (client); | 189 | GNUNET_SERVER_client_drop (client); |
@@ -231,7 +239,9 @@ GNUNET_SERVER_notification_context_destroy (struct GNUNET_SERVER_NotificationCon | |||
231 | GNUNET_SERVER_receive_done (pos->client, GNUNET_NO); | 239 | GNUNET_SERVER_receive_done (pos->client, GNUNET_NO); |
232 | while (NULL != (pml = pos->pending_head)) | 240 | while (NULL != (pml = pos->pending_head)) |
233 | { | 241 | { |
234 | pos->pending_head = pml->next; | 242 | GNUNET_CONTAINER_DLL_remove (pos->pending_head, |
243 | pos->pending_tail, | ||
244 | pml); | ||
235 | GNUNET_free (pml); | 245 | GNUNET_free (pml); |
236 | } | 246 | } |
237 | GNUNET_free (pos); | 247 | GNUNET_free (pos); |
@@ -297,15 +307,14 @@ transmit_message (void *cls, | |||
297 | return 0; | 307 | return 0; |
298 | } | 308 | } |
299 | ret = 0; | 309 | ret = 0; |
300 | while (cl->pending_head != NULL) | 310 | while (NULL != (pml = cl->pending_head) ) |
301 | { | 311 | { |
302 | pml = cl->pending_head; | ||
303 | msize = ntohs (pml->msg->size); | 312 | msize = ntohs (pml->msg->size); |
304 | if (size < msize) | 313 | if (size < msize) |
305 | break; | 314 | break; |
306 | cl->pending_head = pml->next; | 315 | GNUNET_CONTAINER_DLL_remove (cl->pending_head, |
307 | if (pml->next == NULL) | 316 | cl->pending_tail, |
308 | cl->pending_tail = NULL; | 317 | pml); |
309 | #if DEBUG_SERVER_NC | 318 | #if DEBUG_SERVER_NC |
310 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 319 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
311 | "Copying message of type %u and size %u from pending queue to transmission buffer\n", | 320 | "Copying message of type %u and size %u from pending queue to transmission buffer\n", |
@@ -318,7 +327,7 @@ transmit_message (void *cls, | |||
318 | GNUNET_free (pml); | 327 | GNUNET_free (pml); |
319 | cl->num_pending--; | 328 | cl->num_pending--; |
320 | } | 329 | } |
321 | if (cl->pending_head != NULL) | 330 | if (pml != NULL) |
322 | { | 331 | { |
323 | #if DEBUG_SERVER_NC | 332 | #if DEBUG_SERVER_NC |
324 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 333 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -326,7 +335,7 @@ transmit_message (void *cls, | |||
326 | cl->num_pending); | 335 | cl->num_pending); |
327 | #endif | 336 | #endif |
328 | cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client, | 337 | cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client, |
329 | ntohs (cl->pending_head->msg->size), | 338 | ntohs (pml->msg->size), |
330 | GNUNET_TIME_UNIT_FOREVER_REL, | 339 | GNUNET_TIME_UNIT_FOREVER_REL, |
331 | &transmit_message, | 340 | &transmit_message, |
332 | cl); | 341 | cl); |
@@ -383,11 +392,9 @@ do_unicast (struct GNUNET_SERVER_NotificationContext *nc, | |||
383 | #endif | 392 | #endif |
384 | memcpy (&pml[1], msg, size); | 393 | memcpy (&pml[1], msg, size); |
385 | /* append */ | 394 | /* append */ |
386 | if (client->pending_tail != NULL) | 395 | GNUNET_CONTAINER_DLL_insert_tail (client->pending_head, |
387 | client->pending_tail->next = pml; | 396 | client->pending_tail, |
388 | else | 397 | pml); |
389 | client->pending_head = pml; | ||
390 | client->pending_tail = pml; | ||
391 | if (client->th == NULL) | 398 | if (client->th == NULL) |
392 | client->th = GNUNET_SERVER_notify_transmit_ready (client->client, | 399 | client->th = GNUNET_SERVER_notify_transmit_ready (client->client, |
393 | ntohs (client->pending_head->msg->size), | 400 | ntohs (client->pending_head->msg->size), |