diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-09-14 16:49:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-09-14 16:49:45 +0000 |
commit | 64bae9a691d6e95ebd609495431323e596f22f9d (patch) | |
tree | 5d399a913bce7322cca1966e06f3c221fb861b79 /src/identity/identity_api.c | |
parent | 946de21c805f2684d27ea7a4d7b6ae5a6337f925 (diff) | |
download | gnunet-64bae9a691d6e95ebd609495431323e596f22f9d.tar.gz gnunet-64bae9a691d6e95ebd609495431323e596f22f9d.zip |
-avoid queuing large number of START requests
Diffstat (limited to 'src/identity/identity_api.c')
-rw-r--r-- | src/identity/identity_api.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 157fa6e4f..3323fe6fc 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -540,16 +540,20 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
540 | GNUNET_assert (NULL == h->client); | 540 | GNUNET_assert (NULL == h->client); |
541 | h->client = GNUNET_CLIENT_connect ("identity", h->cfg); | 541 | h->client = GNUNET_CLIENT_connect ("identity", h->cfg); |
542 | GNUNET_assert (NULL != h->client); | 542 | GNUNET_assert (NULL != h->client); |
543 | op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) + | 543 | if ( (NULL == h->op_head) || |
544 | sizeof (struct GNUNET_MessageHeader)); | 544 | (GNUNET_MESSAGE_TYPE_IDENTITY_START != ntohs (h->op_head->msg->type)) ) |
545 | op->h = h; | 545 | { |
546 | op->msg = (const struct GNUNET_MessageHeader *) &op[1]; | 546 | op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) + |
547 | msg.size = htons (sizeof (msg)); | 547 | sizeof (struct GNUNET_MessageHeader)); |
548 | msg.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_START); | 548 | op->h = h; |
549 | memcpy (&op[1], &msg, sizeof (msg)); | 549 | op->msg = (const struct GNUNET_MessageHeader *) &op[1]; |
550 | GNUNET_CONTAINER_DLL_insert (h->op_head, | 550 | msg.size = htons (sizeof (msg)); |
551 | h->op_tail, | 551 | msg.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_START); |
552 | op); | 552 | memcpy (&op[1], &msg, sizeof (msg)); |
553 | GNUNET_CONTAINER_DLL_insert (h->op_head, | ||
554 | h->op_tail, | ||
555 | op); | ||
556 | } | ||
553 | transmit_next (h); | 557 | transmit_next (h); |
554 | GNUNET_assert (NULL != h->th); | 558 | GNUNET_assert (NULL != h->th); |
555 | } | 559 | } |
@@ -945,8 +949,11 @@ free_ego (void *cls, | |||
945 | void | 949 | void |
946 | GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h) | 950 | GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h) |
947 | { | 951 | { |
952 | struct GNUNET_IDENTITY_Operation *op; | ||
953 | |||
948 | GNUNET_assert (NULL != h); | 954 | GNUNET_assert (NULL != h); |
949 | GNUNET_assert (h->op_head == h->op_tail); | 955 | while (NULL != (op = h->op_head)) |
956 | GNUNET_IDENTITY_cancel (op); | ||
950 | if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK) | 957 | if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK) |
951 | { | 958 | { |
952 | GNUNET_SCHEDULER_cancel (h->reconnect_task); | 959 | GNUNET_SCHEDULER_cancel (h->reconnect_task); |