diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-01-22 15:52:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-01-22 15:52:40 +0000 |
commit | 48436941449d867ef9a32ddf29439c5017d37775 (patch) | |
tree | a34b1230ba7e4d2e9deea743dcfdb283f7f7b605 /src/core | |
parent | 87487477c67697355c79d2fe079d23a5b31c7ab6 (diff) | |
download | gnunet-48436941449d867ef9a32ddf29439c5017d37775.tar.gz gnunet-48436941449d867ef9a32ddf29439c5017d37775.zip |
stuff
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/core_api.c | 66 | ||||
-rw-r--r-- | src/core/gnunet-service-core.c | 233 |
2 files changed, 56 insertions, 243 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index e7e958bd7..a23313499 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -87,9 +87,14 @@ struct GNUNET_CORE_Handle | |||
87 | const struct GNUNET_CORE_MessageHandler *handlers; | 87 | const struct GNUNET_CORE_MessageHandler *handlers; |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Our connection to the service. | 90 | * Our connection to the service for notifications. |
91 | */ | 91 | */ |
92 | struct GNUNET_CLIENT_Connection *client; | 92 | struct GNUNET_CLIENT_Connection *client_notifications; |
93 | |||
94 | /** | ||
95 | * Our connection to the service for normal requests. | ||
96 | */ | ||
97 | struct GNUNET_CLIENT_Connection *client_requests; | ||
93 | 98 | ||
94 | /** | 99 | /** |
95 | * Handle for our current transmission request. | 100 | * Handle for our current transmission request. |
@@ -263,10 +268,10 @@ static size_t transmit_start (void *cls, size_t size, void *buf); | |||
263 | static void | 268 | static void |
264 | reconnect (struct GNUNET_CORE_Handle *h) | 269 | reconnect (struct GNUNET_CORE_Handle *h) |
265 | { | 270 | { |
266 | GNUNET_CLIENT_disconnect (h->client); | 271 | GNUNET_CLIENT_disconnect (h->client_notifications); |
267 | h->currently_down = GNUNET_YES; | 272 | h->currently_down = GNUNET_YES; |
268 | h->client = GNUNET_CLIENT_connect (h->sched, "core", h->cfg); | 273 | h->client_notifications = GNUNET_CLIENT_connect (h->sched, "core", h->cfg); |
269 | h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, | 274 | h->th = GNUNET_CLIENT_notify_transmit_ready (h->client_notifications, |
270 | sizeof (struct InitMessage) + | 275 | sizeof (struct InitMessage) + |
271 | sizeof (uint16_t) * h->hcnt, | 276 | sizeof (uint16_t) * h->hcnt, |
272 | GNUNET_TIME_UNIT_SECONDS, | 277 | GNUNET_TIME_UNIT_SECONDS, |
@@ -346,6 +351,7 @@ static void | |||
346 | trigger_next_request (struct GNUNET_CORE_Handle *h) | 351 | trigger_next_request (struct GNUNET_CORE_Handle *h) |
347 | { | 352 | { |
348 | struct GNUNET_CORE_TransmitHandle *th; | 353 | struct GNUNET_CORE_TransmitHandle *th; |
354 | |||
349 | if (h->currently_down) | 355 | if (h->currently_down) |
350 | return; /* connection temporarily down */ | 356 | return; /* connection temporarily down */ |
351 | if (NULL == (th = h->pending_head)) | 357 | if (NULL == (th = h->pending_head)) |
@@ -356,7 +362,7 @@ trigger_next_request (struct GNUNET_CORE_Handle *h) | |||
356 | GNUNET_SCHEDULER_cancel (h->sched, th->timeout_task); | 362 | GNUNET_SCHEDULER_cancel (h->sched, th->timeout_task); |
357 | th->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 363 | th->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
358 | } | 364 | } |
359 | h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, | 365 | h->th = GNUNET_CLIENT_notify_transmit_ready (h->client_requests, |
360 | th->msize, | 366 | th->msize, |
361 | GNUNET_TIME_absolute_get_remaining | 367 | GNUNET_TIME_absolute_get_remaining |
362 | (th->timeout), | 368 | (th->timeout), |
@@ -367,20 +373,19 @@ trigger_next_request (struct GNUNET_CORE_Handle *h) | |||
367 | 373 | ||
368 | 374 | ||
369 | /** | 375 | /** |
370 | * Handler for most messages received from the core. | 376 | * Handler for notification messages received from the core. |
371 | * | 377 | * |
372 | * @param cls our "struct GNUNET_CORE_Handle" | 378 | * @param cls our "struct GNUNET_CORE_Handle" |
373 | * @param msg the message received from the core service | 379 | * @param msg the message received from the core service |
374 | */ | 380 | */ |
375 | static void | 381 | static void |
376 | main_handler (void *cls, const struct GNUNET_MessageHeader *msg) | 382 | main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) |
377 | { | 383 | { |
378 | struct GNUNET_CORE_Handle *h = cls; | 384 | struct GNUNET_CORE_Handle *h = cls; |
379 | unsigned int hpos; | 385 | unsigned int hpos; |
380 | const struct ConnectNotifyMessage *cnm; | 386 | const struct ConnectNotifyMessage *cnm; |
381 | const struct DisconnectNotifyMessage *dnm; | 387 | const struct DisconnectNotifyMessage *dnm; |
382 | const struct NotifyTrafficMessage *ntm; | 388 | const struct NotifyTrafficMessage *ntm; |
383 | const struct ConfigurationInfoMessage *cim; | ||
384 | const struct GNUNET_MessageHeader *em; | 389 | const struct GNUNET_MessageHeader *em; |
385 | uint16_t msize; | 390 | uint16_t msize; |
386 | uint16_t et; | 391 | uint16_t et; |
@@ -524,38 +529,15 @@ main_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
524 | GNUNET_TIME_relative_ntoh (ntm->latency), | 529 | GNUNET_TIME_relative_ntoh (ntm->latency), |
525 | ntohl (ntm->distance)); | 530 | ntohl (ntm->distance)); |
526 | break; | 531 | break; |
527 | case GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO: | ||
528 | if (msize != sizeof (struct ConfigurationInfoMessage)) | ||
529 | { | ||
530 | GNUNET_break (0); | ||
531 | break; | ||
532 | } | ||
533 | if (NULL == h->submitted) | ||
534 | break; | ||
535 | cim = (const struct ConfigurationInfoMessage *) msg; | ||
536 | |||
537 | /* process configuration data */ | ||
538 | if (h->submitted->info != NULL) | ||
539 | h->submitted->info (h->submitted->info_cls, | ||
540 | &h->submitted->peer, | ||
541 | ntohl (cim->bpm_in), | ||
542 | ntohl (cim->bpm_out), | ||
543 | (int) ntohl (cim->reserved_amount), | ||
544 | cim->preference); | ||
545 | /* done, clean up! */ | ||
546 | GNUNET_CORE_notify_transmit_ready_cancel (h->submitted); // HUH? | ||
547 | trigger_next_request (h); | ||
548 | break; | ||
549 | default: | 532 | default: |
550 | GNUNET_break (0); | 533 | GNUNET_break (0); |
551 | break; | 534 | break; |
552 | } | 535 | } |
553 | GNUNET_CLIENT_receive (h->client, | 536 | GNUNET_CLIENT_receive (h->client_notifications, |
554 | &main_handler, h, GNUNET_TIME_UNIT_FOREVER_REL); | 537 | &main_notify_handler, h, GNUNET_TIME_UNIT_FOREVER_REL); |
555 | } | 538 | } |
556 | 539 | ||
557 | 540 | ||
558 | |||
559 | /** | 541 | /** |
560 | * Function called when we are ready to transmit our | 542 | * Function called when we are ready to transmit our |
561 | * "START" message (or when this operation timed out). | 543 | * "START" message (or when this operation timed out). |
@@ -606,8 +588,8 @@ init_reply_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
606 | #endif | 588 | #endif |
607 | h->currently_down = GNUNET_NO; | 589 | h->currently_down = GNUNET_NO; |
608 | trigger_next_request (h); | 590 | trigger_next_request (h); |
609 | GNUNET_CLIENT_receive (h->client, | 591 | GNUNET_CLIENT_receive (h->client_notifications, |
610 | &main_handler, h, GNUNET_TIME_UNIT_FOREVER_REL); | 592 | &main_notify_handler, h, GNUNET_TIME_UNIT_FOREVER_REL); |
611 | if (NULL != (init = h->init)) | 593 | if (NULL != (init = h->init)) |
612 | { | 594 | { |
613 | /* mark so we don't call init on reconnect */ | 595 | /* mark so we don't call init on reconnect */ |
@@ -710,7 +692,7 @@ transmit_start (void *cls, size_t size, void *buf) | |||
710 | ts = (uint16_t *) & init[1]; | 692 | ts = (uint16_t *) & init[1]; |
711 | for (hpos = 0; hpos < h->hcnt; hpos++) | 693 | for (hpos = 0; hpos < h->hcnt; hpos++) |
712 | ts[hpos] = htons (h->handlers[hpos].type); | 694 | ts[hpos] = htons (h->handlers[hpos].type); |
713 | GNUNET_CLIENT_receive (h->client, | 695 | GNUNET_CLIENT_receive (h->client_notifications, |
714 | &init_reply_handler, | 696 | &init_reply_handler, |
715 | h, | 697 | h, |
716 | GNUNET_TIME_absolute_get_remaining | 698 | GNUNET_TIME_absolute_get_remaining |
@@ -774,8 +756,8 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
774 | h->inbound_hdr_only = inbound_hdr_only; | 756 | h->inbound_hdr_only = inbound_hdr_only; |
775 | h->outbound_hdr_only = outbound_hdr_only; | 757 | h->outbound_hdr_only = outbound_hdr_only; |
776 | h->handlers = handlers; | 758 | h->handlers = handlers; |
777 | h->client = GNUNET_CLIENT_connect (sched, "core", cfg); | 759 | h->client_notifications = GNUNET_CLIENT_connect (sched, "core", cfg); |
778 | if (h->client == NULL) | 760 | if (h->client_notifications == NULL) |
779 | { | 761 | { |
780 | GNUNET_free (h); | 762 | GNUNET_free (h); |
781 | return NULL; | 763 | return NULL; |
@@ -793,7 +775,7 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
793 | timeout.value); | 775 | timeout.value); |
794 | #endif | 776 | #endif |
795 | h->th = | 777 | h->th = |
796 | GNUNET_CLIENT_notify_transmit_ready (h->client, | 778 | GNUNET_CLIENT_notify_transmit_ready (h->client_notifications, |
797 | sizeof (struct InitMessage) + | 779 | sizeof (struct InitMessage) + |
798 | sizeof (uint16_t) * h->hcnt, timeout, | 780 | sizeof (uint16_t) * h->hcnt, timeout, |
799 | GNUNET_YES, | 781 | GNUNET_YES, |
@@ -816,7 +798,9 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle) | |||
816 | GNUNET_CORE_notify_transmit_ready_cancel (handle->solicit_transmit_req); | 798 | GNUNET_CORE_notify_transmit_ready_cancel (handle->solicit_transmit_req); |
817 | if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) | 799 | if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) |
818 | GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task); | 800 | GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task); |
819 | GNUNET_CLIENT_disconnect (handle->client); | 801 | GNUNET_CLIENT_disconnect (handle->client_notifications); |
802 | if (handle->client_requests != NULL) | ||
803 | GNUNET_CLIENT_disconnect (handle->client_requests); | ||
820 | GNUNET_free_non_null (handle->solicit_buffer); | 804 | GNUNET_free_non_null (handle->solicit_buffer); |
821 | GNUNET_free (handle); | 805 | GNUNET_free (handle); |
822 | } | 806 | } |
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 915217ea1..842197fb1 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -539,31 +539,6 @@ struct Neighbour | |||
539 | 539 | ||
540 | 540 | ||
541 | /** | 541 | /** |
542 | * Events are messages for clients. The struct | ||
543 | * itself is followed by the actual message. | ||
544 | */ | ||
545 | struct Event | ||
546 | { | ||
547 | /** | ||
548 | * This is a linked list. | ||
549 | */ | ||
550 | struct Event *next; | ||
551 | |||
552 | /** | ||
553 | * Size of the message. | ||
554 | */ | ||
555 | size_t size; | ||
556 | |||
557 | /** | ||
558 | * Could this event be dropped if this queue | ||
559 | * is getting too large? (NOT YET USED!) | ||
560 | */ | ||
561 | int can_drop; | ||
562 | |||
563 | }; | ||
564 | |||
565 | |||
566 | /** | ||
567 | * Data structure for each client connected to the core service. | 542 | * Data structure for each client connected to the core service. |
568 | */ | 543 | */ |
569 | struct Client | 544 | struct Client |
@@ -579,23 +554,6 @@ struct Client | |||
579 | struct GNUNET_SERVER_Client *client_handle; | 554 | struct GNUNET_SERVER_Client *client_handle; |
580 | 555 | ||
581 | /** | 556 | /** |
582 | * Linked list of messages we still need to deliver to | ||
583 | * this client. | ||
584 | */ | ||
585 | struct Event *event_head; | ||
586 | |||
587 | /** | ||
588 | * Tail of the linked list of events. | ||
589 | */ | ||
590 | struct Event *event_tail; | ||
591 | |||
592 | /** | ||
593 | * Current transmit handle, NULL if no transmission request | ||
594 | * is pending. | ||
595 | */ | ||
596 | struct GNUNET_CONNECTION_TransmitHandle *th; | ||
597 | |||
598 | /** | ||
599 | * Array of the types of messages this peer cares | 557 | * Array of the types of messages this peer cares |
600 | * about (with "tcnt" entries). Allocated as part | 558 | * about (with "tcnt" entries). Allocated as part |
601 | * of this client struct, do not free! | 559 | * of this client struct, do not free! |
@@ -658,6 +616,11 @@ static struct GNUNET_TRANSPORT_Handle *transport; | |||
658 | static struct Client *clients; | 616 | static struct Client *clients; |
659 | 617 | ||
660 | /** | 618 | /** |
619 | * Context for notifications we need to send to our clients. | ||
620 | */ | ||
621 | static struct GNUNET_SERVER_NotificationContext *notifier; | ||
622 | |||
623 | /** | ||
661 | * We keep neighbours in a linked list (for now). | 624 | * We keep neighbours in a linked list (for now). |
662 | */ | 625 | */ |
663 | static struct Neighbour *neighbours; | 626 | static struct Neighbour *neighbours; |
@@ -762,110 +725,6 @@ find_neighbour (const struct GNUNET_PeerIdentity *peer) | |||
762 | 725 | ||
763 | 726 | ||
764 | /** | 727 | /** |
765 | * Find the entry for the given client. | ||
766 | * | ||
767 | * @param client handle for the client | ||
768 | * @return NULL if we are not connected, otherwise the | ||
769 | * client's struct. | ||
770 | */ | ||
771 | static struct Client * | ||
772 | find_client (const struct GNUNET_SERVER_Client *client) | ||
773 | { | ||
774 | struct Client *ret; | ||
775 | |||
776 | ret = clients; | ||
777 | while ((ret != NULL) && (client != ret->client_handle)) | ||
778 | ret = ret->next; | ||
779 | return ret; | ||
780 | } | ||
781 | |||
782 | |||
783 | /** | ||
784 | * If necessary, initiate a request with the server to | ||
785 | * transmit messages from the queue of the given client. | ||
786 | * @param client who to transfer messages to | ||
787 | */ | ||
788 | static void request_transmit (struct Client *client); | ||
789 | |||
790 | |||
791 | /** | ||
792 | * Client is ready to receive data, provide it. | ||
793 | * | ||
794 | * @param cls closure | ||
795 | * @param size number of bytes available in buf | ||
796 | * @param buf where the callee should write the message | ||
797 | * @return number of bytes written to buf | ||
798 | */ | ||
799 | static size_t | ||
800 | do_client_transmit (void *cls, size_t size, void *buf) | ||
801 | { | ||
802 | struct Client *client = cls; | ||
803 | struct Event *e; | ||
804 | char *tgt; | ||
805 | size_t ret; | ||
806 | |||
807 | client->th = NULL; | ||
808 | #if DEBUG_CORE_CLIENT | ||
809 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
810 | "Client ready to receive %u bytes.\n", size); | ||
811 | #endif | ||
812 | if (buf == NULL) | ||
813 | { | ||
814 | #if DEBUG_CORE | ||
815 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
816 | "Failed to transmit data to client (disconnect)?\n"); | ||
817 | #endif | ||
818 | return 0; /* we'll surely get a disconnect soon... */ | ||
819 | } | ||
820 | tgt = buf; | ||
821 | ret = 0; | ||
822 | while ((NULL != (e = client->event_head)) && (e->size <= size)) | ||
823 | { | ||
824 | memcpy (&tgt[ret], &e[1], e->size); | ||
825 | size -= e->size; | ||
826 | ret += e->size; | ||
827 | client->event_head = e->next; | ||
828 | GNUNET_free (e); | ||
829 | } | ||
830 | GNUNET_assert (ret > 0); | ||
831 | if (client->event_head == NULL) | ||
832 | client->event_tail = NULL; | ||
833 | #if DEBUG_CORE_CLIENT | ||
834 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
835 | "Transmitting %u bytes to client\n", ret); | ||
836 | #endif | ||
837 | request_transmit (client); | ||
838 | return ret; | ||
839 | } | ||
840 | |||
841 | |||
842 | /** | ||
843 | * If necessary, initiate a request with the server to | ||
844 | * transmit messages from the queue of the given client. | ||
845 | * @param client who to transfer messages to | ||
846 | */ | ||
847 | static void | ||
848 | request_transmit (struct Client *client) | ||
849 | { | ||
850 | |||
851 | if (NULL != client->th) | ||
852 | return; /* already pending */ | ||
853 | if (NULL == client->event_head) | ||
854 | return; /* no more events pending */ | ||
855 | #if DEBUG_CORE_CLIENT | ||
856 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
857 | "Asking server to transmit %u bytes to client\n", | ||
858 | client->event_head->size); | ||
859 | #endif | ||
860 | client->th | ||
861 | = GNUNET_SERVER_notify_transmit_ready (client->client_handle, | ||
862 | client->event_head->size, | ||
863 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
864 | &do_client_transmit, client); | ||
865 | } | ||
866 | |||
867 | |||
868 | /** | ||
869 | * Send a message to one of our clients. | 728 | * Send a message to one of our clients. |
870 | * | 729 | * |
871 | * @param client target for the message | 730 | * @param client target for the message |
@@ -875,51 +734,28 @@ request_transmit (struct Client *client) | |||
875 | */ | 734 | */ |
876 | static void | 735 | static void |
877 | send_to_client (struct Client *client, | 736 | send_to_client (struct Client *client, |
878 | const struct GNUNET_MessageHeader *msg, int can_drop) | 737 | const struct GNUNET_MessageHeader *msg, |
738 | int can_drop) | ||
879 | { | 739 | { |
880 | struct Event *e; | ||
881 | unsigned int queue_size; | ||
882 | uint16_t msize; | ||
883 | |||
884 | #if DEBUG_CORE_CLIENT | 740 | #if DEBUG_CORE_CLIENT |
885 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 741 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
886 | "Preparing to send message of type %u to client.\n", | 742 | "Preparing to send message of type %u to client.\n", |
887 | ntohs (msg->type)); | 743 | ntohs (msg->type)); |
888 | #endif | 744 | #endif |
889 | queue_size = 0; | 745 | GNUNET_SERVER_notification_context_unicast (notifier, |
890 | e = client->event_head; | 746 | client->client_handle, |
891 | while (e != NULL) | 747 | msg, |
892 | { | 748 | can_drop); |
893 | queue_size++; | ||
894 | e = e->next; | ||
895 | } | ||
896 | if ( (queue_size >= MAX_CLIENT_QUEUE_SIZE) && | ||
897 | (can_drop == GNUNET_YES) ) | ||
898 | { | ||
899 | #if DEBUG_CORE | ||
900 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
901 | "Too many messages in queue for the client, dropping the new message.\n"); | ||
902 | #endif | ||
903 | return; | ||
904 | } | ||
905 | |||
906 | msize = ntohs (msg->size); | ||
907 | e = GNUNET_malloc (sizeof (struct Event) + msize); | ||
908 | /* append */ | ||
909 | if (client->event_tail != NULL) | ||
910 | client->event_tail->next = e; | ||
911 | else | ||
912 | client->event_head = e; | ||
913 | client->event_tail = e; | ||
914 | e->can_drop = can_drop; | ||
915 | e->size = msize; | ||
916 | memcpy (&e[1], msg, msize); | ||
917 | request_transmit (client); | ||
918 | } | 749 | } |
919 | 750 | ||
920 | 751 | ||
921 | /** | 752 | /** |
922 | * Send a message to all of our current clients. | 753 | * Send a message to all of our current clients that have |
754 | * the right options set. | ||
755 | * | ||
756 | * @param msg message to multicast | ||
757 | * @param can_drop can this message be discarded if the queue is too long | ||
758 | * @param options mask to use | ||
923 | */ | 759 | */ |
924 | static void | 760 | static void |
925 | send_to_all_clients (const struct GNUNET_MessageHeader *msg, | 761 | send_to_all_clients (const struct GNUNET_MessageHeader *msg, |
@@ -978,6 +814,7 @@ handle_client_init (void *cls, | |||
978 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 814 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
979 | return; | 815 | return; |
980 | } | 816 | } |
817 | GNUNET_SERVER_notification_context_add (notifier, client); | ||
981 | im = (const struct InitMessage *) message; | 818 | im = (const struct InitMessage *) message; |
982 | types = (const uint16_t *) &im[1]; | 819 | types = (const uint16_t *) &im[1]; |
983 | msize -= sizeof (struct InitMessage); | 820 | msize -= sizeof (struct InitMessage); |
@@ -1017,7 +854,6 @@ handle_client_init (void *cls, | |||
1017 | send_to_client (c, &cnm.header, GNUNET_NO); | 854 | send_to_client (c, &cnm.header, GNUNET_NO); |
1018 | n = n->next; | 855 | n = n->next; |
1019 | } | 856 | } |
1020 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1021 | } | 857 | } |
1022 | 858 | ||
1023 | 859 | ||
@@ -1032,7 +868,6 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
1032 | { | 868 | { |
1033 | struct Client *pos; | 869 | struct Client *pos; |
1034 | struct Client *prev; | 870 | struct Client *prev; |
1035 | struct Event *e; | ||
1036 | 871 | ||
1037 | if (client == NULL) | 872 | if (client == NULL) |
1038 | return; | 873 | return; |
@@ -1050,13 +885,6 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
1050 | clients = pos->next; | 885 | clients = pos->next; |
1051 | else | 886 | else |
1052 | prev->next = pos->next; | 887 | prev->next = pos->next; |
1053 | if (pos->th != NULL) | ||
1054 | GNUNET_CONNECTION_notify_transmit_ready_cancel (pos->th); | ||
1055 | while (NULL != (e = pos->event_head)) | ||
1056 | { | ||
1057 | pos->event_head = e->next; | ||
1058 | GNUNET_free (e); | ||
1059 | } | ||
1060 | GNUNET_free (pos); | 888 | GNUNET_free (pos); |
1061 | return; | 889 | return; |
1062 | } | 890 | } |
@@ -1072,15 +900,15 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
1072 | */ | 900 | */ |
1073 | static void | 901 | static void |
1074 | handle_client_request_info (void *cls, | 902 | handle_client_request_info (void *cls, |
1075 | struct GNUNET_SERVER_Client *client, | 903 | struct GNUNET_SERVER_Client *client, |
1076 | const struct GNUNET_MessageHeader *message) | 904 | const struct GNUNET_MessageHeader *message) |
1077 | { | 905 | { |
1078 | const struct RequestInfoMessage *rcm; | 906 | const struct RequestInfoMessage *rcm; |
1079 | struct Neighbour *n; | 907 | struct Neighbour *n; |
1080 | struct ConfigurationInfoMessage cim; | 908 | struct ConfigurationInfoMessage cim; |
1081 | struct Client *c; | ||
1082 | int reserv; | 909 | int reserv; |
1083 | unsigned long long old_preference; | 910 | unsigned long long old_preference; |
911 | struct GNUNET_SERVER_TransmitContext *tc; | ||
1084 | 912 | ||
1085 | #if DEBUG_CORE_CLIENT | 913 | #if DEBUG_CORE_CLIENT |
1086 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 914 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1128,17 +956,15 @@ handle_client_request_info (void *cls, | |||
1128 | cim.header.size = htons (sizeof (struct ConfigurationInfoMessage)); | 956 | cim.header.size = htons (sizeof (struct ConfigurationInfoMessage)); |
1129 | cim.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO); | 957 | cim.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO); |
1130 | cim.peer = rcm->peer; | 958 | cim.peer = rcm->peer; |
1131 | c = find_client (client); | 959 | |
1132 | if (c == NULL) | ||
1133 | { | ||
1134 | GNUNET_break (0); | ||
1135 | return; | ||
1136 | } | ||
1137 | #if DEBUG_CORE_CLIENT | 960 | #if DEBUG_CORE_CLIENT |
1138 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 961 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1139 | "Sending `%s' message to client.\n", "CONFIGURATION_INFO"); | 962 | "Sending `%s' message to client.\n", "CONFIGURATION_INFO"); |
1140 | #endif | 963 | #endif |
1141 | send_to_client (c, &cim.header, GNUNET_NO); | 964 | tc = GNUNET_SERVER_transmit_context_create (client); |
965 | GNUNET_SERVER_transmit_context_append_message (tc, &cim.header); | ||
966 | GNUNET_SERVER_transmit_context_run (tc, | ||
967 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
1142 | } | 968 | } |
1143 | 969 | ||
1144 | 970 | ||
@@ -3252,6 +3078,8 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3252 | neighbour_count--; | 3078 | neighbour_count--; |
3253 | free_neighbour (n); | 3079 | free_neighbour (n); |
3254 | } | 3080 | } |
3081 | GNUNET_SERVER_notification_context_destroy (notifier); | ||
3082 | notifier = NULL; | ||
3255 | while (NULL != (c = clients)) | 3083 | while (NULL != (c = clients)) |
3256 | handle_client_disconnect (NULL, c->client_handle); | 3084 | handle_client_disconnect (NULL, c->client_handle); |
3257 | if (my_private_key != NULL) | 3085 | if (my_private_key != NULL) |
@@ -3281,7 +3109,7 @@ run (void *cls, | |||
3281 | char *keyfile; | 3109 | char *keyfile; |
3282 | 3110 | ||
3283 | sched = s; | 3111 | sched = s; |
3284 | cfg = c; | 3112 | cfg = c; |
3285 | /* parse configuration */ | 3113 | /* parse configuration */ |
3286 | if ( | 3114 | if ( |
3287 | (GNUNET_OK != | 3115 | (GNUNET_OK != |
@@ -3330,6 +3158,7 @@ run (void *cls, | |||
3330 | sizeof (my_public_key), &my_identity.hashPubKey); | 3158 | sizeof (my_public_key), &my_identity.hashPubKey); |
3331 | /* setup notification */ | 3159 | /* setup notification */ |
3332 | server = serv; | 3160 | server = serv; |
3161 | notifier = GNUNET_SERVER_notification_context_create (server, 0); | ||
3333 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); | 3162 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); |
3334 | /* setup transport connection */ | 3163 | /* setup transport connection */ |
3335 | transport = GNUNET_TRANSPORT_connect (sched, | 3164 | transport = GNUNET_TRANSPORT_connect (sched, |