diff options
author | lurchi <lurchi@strangeplace.net> | 2017-11-18 11:08:32 +0100 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2017-11-18 11:08:32 +0100 |
commit | 51a27f583432d57949e3f9ea4c5f3813e9589e42 (patch) | |
tree | 88c5351646174cc1c896dd1c7cb1c6e63537b93d /src/social | |
parent | 6599b4d49d58831ec38bab64478266ebfd9c59fe (diff) | |
download | gnunet-51a27f583432d57949e3f9ea4c5f3813e9589e42.tar.gz gnunet-51a27f583432d57949e3f9ea4c5f3813e9589e42.zip |
use comfort functions of MQ API
Diffstat (limited to 'src/social')
-rw-r--r-- | src/social/gnunet-service-social.c | 36 | ||||
-rw-r--r-- | src/social/social_api.c | 18 |
2 files changed, 38 insertions, 16 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index 3e527cbaf..3f6999269 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -635,6 +635,22 @@ place_send_msg (const struct Place *plc, | |||
635 | } | 635 | } |
636 | 636 | ||
637 | 637 | ||
638 | static void | ||
639 | place_send_leave_ack (const struct Place *plc) | ||
640 | { | ||
641 | struct GNUNET_MQ_Envelope *env; | ||
642 | |||
643 | for (struct ClientListItem *cli = plc->clients_head; | ||
644 | NULL != cli; | ||
645 | cli = cli->next) | ||
646 | { | ||
647 | env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK); | ||
648 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cli->client), | ||
649 | env); | ||
650 | } | ||
651 | } | ||
652 | |||
653 | |||
638 | /** | 654 | /** |
639 | * Send a result code back to the client. | 655 | * Send a result code back to the client. |
640 | * | 656 | * |
@@ -2139,7 +2155,6 @@ handle_client_place_leave (void *cls, | |||
2139 | struct Client *c = cls; | 2155 | struct Client *c = cls; |
2140 | struct GNUNET_SERVICE_Client *client = c->client; | 2156 | struct GNUNET_SERVICE_Client *client = c->client; |
2141 | struct Place *plc = c->place; | 2157 | struct Place *plc = c->place; |
2142 | struct GNUNET_MQ_Envelope *env; | ||
2143 | 2158 | ||
2144 | if (NULL == plc) | 2159 | if (NULL == plc) |
2145 | { | 2160 | { |
@@ -2148,24 +2163,22 @@ handle_client_place_leave (void *cls, | |||
2148 | return; | 2163 | return; |
2149 | } | 2164 | } |
2150 | 2165 | ||
2151 | for (struct ClientListItem *cli = plc->clients_head; | ||
2152 | NULL != cli; | ||
2153 | cli = cli->next) | ||
2154 | { | ||
2155 | env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK); | ||
2156 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cli->client), | ||
2157 | env); | ||
2158 | } | ||
2159 | |||
2160 | if (GNUNET_YES != plc->is_disconnected) | 2166 | if (GNUNET_YES != plc->is_disconnected) |
2161 | { | 2167 | { |
2162 | plc->is_disconnected = GNUNET_YES; | 2168 | plc->is_disconnected = GNUNET_YES; |
2163 | if (NULL != plc->tmit_msgs_head) | 2169 | if (NULL != plc->tmit_msgs_head) |
2164 | { /* Send pending messages to PSYC before cleanup. */ | 2170 | { /* Send pending messages to PSYC before cleanup. */ |
2171 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2172 | "not cleaning up place of client %p\n", | ||
2173 | client); | ||
2165 | psyc_transmit_message (plc); | 2174 | psyc_transmit_message (plc); |
2166 | } | 2175 | } |
2167 | else | 2176 | else |
2168 | { | 2177 | { |
2178 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2179 | "cleaning up place of client %p\n", | ||
2180 | client); | ||
2181 | place_send_leave_ack (plc); | ||
2169 | cleanup_place (plc); | 2182 | cleanup_place (plc); |
2170 | c->place = NULL; | 2183 | c->place = NULL; |
2171 | } | 2184 | } |
@@ -2867,6 +2880,9 @@ handle_client_psyc_message (void *cls, | |||
2867 | 2880 | ||
2868 | if (NULL == plc) | 2881 | if (NULL == plc) |
2869 | { | 2882 | { |
2883 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2884 | "received PSYC message for non-existing client %p\n", | ||
2885 | client); | ||
2870 | GNUNET_break (0); | 2886 | GNUNET_break (0); |
2871 | GNUNET_SERVICE_client_drop (client); | 2887 | GNUNET_SERVICE_client_drop (client); |
2872 | return; | 2888 | return; |
diff --git a/src/social/social_api.c b/src/social/social_api.c index 73587598b..f37c52e2c 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c | |||
@@ -398,6 +398,9 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc) | |||
398 | { | 398 | { |
399 | struct GNUNET_HashCode place_pub_hash; | 399 | struct GNUNET_HashCode place_pub_hash; |
400 | 400 | ||
401 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
402 | "place_cleanup\n"); | ||
403 | |||
401 | GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); | 404 | GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); |
402 | if (NULL != plc->tmit) | 405 | if (NULL != plc->tmit) |
403 | { | 406 | { |
@@ -1511,6 +1514,8 @@ GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *hst, | |||
1511 | void *notify_data_cls, | 1514 | void *notify_data_cls, |
1512 | enum GNUNET_SOCIAL_AnnounceFlags flags) | 1515 | enum GNUNET_SOCIAL_AnnounceFlags flags) |
1513 | { | 1516 | { |
1517 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1518 | "PSYC_transmit_message for host\n"); | ||
1514 | if (GNUNET_OK == | 1519 | if (GNUNET_OK == |
1515 | GNUNET_PSYC_transmit_message (hst->plc.tmit, method_name, env, | 1520 | GNUNET_PSYC_transmit_message (hst->plc.tmit, method_name, env, |
1516 | NULL, notify_data, notify_data_cls, flags)) | 1521 | NULL, notify_data, notify_data_cls, flags)) |
@@ -1606,15 +1611,15 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, | |||
1606 | GNUNET_ContinuationCallback disconnect_cb, | 1611 | GNUNET_ContinuationCallback disconnect_cb, |
1607 | void *cls) | 1612 | void *cls) |
1608 | { | 1613 | { |
1609 | struct GNUNET_MessageHeader *msg; | ||
1610 | struct GNUNET_MQ_Envelope *envelope; | 1614 | struct GNUNET_MQ_Envelope *envelope; |
1611 | 1615 | ||
1616 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1617 | "sending _notice_place_closing\n"); | ||
1612 | GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, | 1618 | GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, |
1613 | GNUNET_SOCIAL_ANNOUNCE_NONE); | 1619 | GNUNET_SOCIAL_ANNOUNCE_NONE); |
1614 | hst->plc.disconnect_cb = disconnect_cb; | 1620 | hst->plc.disconnect_cb = disconnect_cb; |
1615 | hst->plc.disconnect_cls = cls; | 1621 | hst->plc.disconnect_cls = cls; |
1616 | envelope = GNUNET_MQ_msg (msg, | 1622 | envelope = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); |
1617 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); | ||
1618 | GNUNET_MQ_send (hst->plc.mq, | 1623 | GNUNET_MQ_send (hst->plc.mq, |
1619 | envelope); | 1624 | envelope); |
1620 | } | 1625 | } |
@@ -1987,6 +1992,9 @@ GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *gst, | |||
1987 | void *notify_data_cls, | 1992 | void *notify_data_cls, |
1988 | enum GNUNET_SOCIAL_TalkFlags flags) | 1993 | enum GNUNET_SOCIAL_TalkFlags flags) |
1989 | { | 1994 | { |
1995 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1996 | "PSYC_transmit_message for guest\n"); | ||
1997 | |||
1990 | struct GNUNET_SOCIAL_Place *plc = &gst->plc; | 1998 | struct GNUNET_SOCIAL_Place *plc = &gst->plc; |
1991 | GNUNET_assert (NULL != plc->tmit); | 1999 | GNUNET_assert (NULL != plc->tmit); |
1992 | 2000 | ||
@@ -2068,15 +2076,13 @@ GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, | |||
2068 | GNUNET_ContinuationCallback disconnect_cb, | 2076 | GNUNET_ContinuationCallback disconnect_cb, |
2069 | void *cls) | 2077 | void *cls) |
2070 | { | 2078 | { |
2071 | struct GNUNET_MessageHeader *msg; | ||
2072 | struct GNUNET_MQ_Envelope *envelope; | 2079 | struct GNUNET_MQ_Envelope *envelope; |
2073 | 2080 | ||
2074 | GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL, | 2081 | GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL, |
2075 | GNUNET_SOCIAL_TALK_NONE); | 2082 | GNUNET_SOCIAL_TALK_NONE); |
2076 | gst->plc.disconnect_cb = disconnect_cb; | 2083 | gst->plc.disconnect_cb = disconnect_cb; |
2077 | gst->plc.disconnect_cls = cls; | 2084 | gst->plc.disconnect_cls = cls; |
2078 | envelope = GNUNET_MQ_msg (msg, | 2085 | envelope = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); |
2079 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); | ||
2080 | GNUNET_MQ_send (gst->plc.mq, | 2086 | GNUNET_MQ_send (gst->plc.mq, |
2081 | envelope); | 2087 | envelope); |
2082 | } | 2088 | } |