diff options
author | lurchi <lurchi@strangeplace.net> | 2017-11-08 19:19:29 +0100 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2017-11-08 19:19:29 +0100 |
commit | c9e414861225f5ac84971845015a67c6bd959153 (patch) | |
tree | c18de76be18dc4c66c0f39c3430d1dad8aaf284a /src/social | |
parent | 7c1ce9a71e362727509f013900a50ba5879ca8b2 (diff) | |
download | gnunet-c9e414861225f5ac84971845015a67c6bd959153.tar.gz gnunet-c9e414861225f5ac84971845015a67c6bd959153.zip |
protocol change: add ack message for guests/hosts leaving a place
Diffstat (limited to 'src/social')
-rw-r--r-- | src/social/gnunet-service-social.c | 9 | ||||
-rw-r--r-- | src/social/social_api.c | 168 |
2 files changed, 104 insertions, 73 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index 04bbba192..609cdab06 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -2227,6 +2227,8 @@ handle_client_place_leave (void *cls, | |||
2227 | struct Client *c = cls; | 2227 | struct Client *c = cls; |
2228 | struct GNUNET_SERVICE_Client *client = c->client; | 2228 | struct GNUNET_SERVICE_Client *client = c->client; |
2229 | struct Place *plc = c->place; | 2229 | struct Place *plc = c->place; |
2230 | struct GNUNET_MQ_Envelope *env; | ||
2231 | struct GNUNET_MessageHeader *ack_msg; | ||
2230 | 2232 | ||
2231 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 2233 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
2232 | "handle_client_place_leave\n"); | 2234 | "handle_client_place_leave\n"); |
@@ -2255,9 +2257,10 @@ handle_client_place_leave (void *cls, | |||
2255 | NULL != cli; | 2257 | NULL != cli; |
2256 | cli = cli->next) | 2258 | cli = cli->next) |
2257 | { | 2259 | { |
2258 | // protocol design failure: should *tell* clients that room is gone! | 2260 | env = GNUNET_MQ_msg (ack_msg, |
2259 | if (client != cli->client) | 2261 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK); |
2260 | GNUNET_SERVICE_client_drop (cli->client); | 2262 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cli->client), |
2263 | env); | ||
2261 | } | 2264 | } |
2262 | 2265 | ||
2263 | if (GNUNET_YES != plc->is_disconnected) | 2266 | if (GNUNET_YES != plc->is_disconnected) |
diff --git a/src/social/social_api.c b/src/social/social_api.c index 1db8e501a..c89e79453 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c | |||
@@ -371,6 +371,83 @@ struct ZoneAddNymHandle | |||
371 | }; | 371 | }; |
372 | 372 | ||
373 | 373 | ||
374 | /*** CLEANUP / DISCONNECT ***/ | ||
375 | |||
376 | |||
377 | static void | ||
378 | host_cleanup (struct GNUNET_SOCIAL_Host *hst) | ||
379 | { | ||
380 | if (NULL != hst->slicer) | ||
381 | { | ||
382 | GNUNET_PSYC_slicer_destroy (hst->slicer); | ||
383 | hst->slicer = NULL; | ||
384 | } | ||
385 | GNUNET_free (hst); | ||
386 | } | ||
387 | |||
388 | |||
389 | static void | ||
390 | guest_cleanup (struct GNUNET_SOCIAL_Guest *gst) | ||
391 | { | ||
392 | GNUNET_free (gst); | ||
393 | } | ||
394 | |||
395 | |||
396 | static void | ||
397 | place_cleanup (struct GNUNET_SOCIAL_Place *plc) | ||
398 | { | ||
399 | struct GNUNET_HashCode place_pub_hash; | ||
400 | |||
401 | GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); | ||
402 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
403 | "%s place cleanup: %s\n", | ||
404 | GNUNET_YES == plc->is_host ? "host" : "guest", | ||
405 | GNUNET_h2s (&place_pub_hash)); | ||
406 | |||
407 | if (NULL != plc->tmit) | ||
408 | { | ||
409 | GNUNET_PSYC_transmit_destroy (plc->tmit); | ||
410 | plc->tmit = NULL; | ||
411 | } | ||
412 | if (NULL != plc->connect_env) | ||
413 | { | ||
414 | GNUNET_MQ_discard (plc->connect_env); | ||
415 | plc->connect_env = NULL; | ||
416 | } | ||
417 | if (NULL != plc->mq) | ||
418 | { | ||
419 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
420 | "destroying MQ (place_cleanup)\n"); | ||
421 | GNUNET_MQ_destroy (plc->mq); | ||
422 | plc->mq = NULL; | ||
423 | } | ||
424 | if (NULL != plc->disconnect_cb) | ||
425 | { | ||
426 | plc->disconnect_cb (plc->disconnect_cls); | ||
427 | plc->disconnect_cb = NULL; | ||
428 | } | ||
429 | |||
430 | (GNUNET_YES == plc->is_host) | ||
431 | ? host_cleanup ((struct GNUNET_SOCIAL_Host *) plc) | ||
432 | : guest_cleanup ((struct GNUNET_SOCIAL_Guest *) plc); | ||
433 | } | ||
434 | |||
435 | |||
436 | static void | ||
437 | place_disconnect (struct GNUNET_SOCIAL_Place *plc) | ||
438 | { | ||
439 | struct GNUNET_HashCode place_pub_hash; | ||
440 | |||
441 | GNUNET_CRYPTO_hash (&plc->pub_key, | ||
442 | sizeof (plc->pub_key), | ||
443 | &place_pub_hash); | ||
444 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
445 | "place_disconnect, plc = %s\n", | ||
446 | GNUNET_h2s (&place_pub_hash)); | ||
447 | place_cleanup (plc); | ||
448 | } | ||
449 | |||
450 | |||
374 | /*** NYM ***/ | 451 | /*** NYM ***/ |
375 | 452 | ||
376 | static struct GNUNET_SOCIAL_Nym * | 453 | static struct GNUNET_SOCIAL_Nym * |
@@ -1018,80 +1095,23 @@ handle_app_place_end (void *cls, | |||
1018 | } | 1095 | } |
1019 | 1096 | ||
1020 | 1097 | ||
1021 | /*** CLEANUP / DISCONNECT ***/ | 1098 | /** |
1022 | 1099 | * Handle an acknowledgement that a guest or host left a place. | |
1023 | 1100 | * | |
1024 | static void | 1101 | * @param cls a `struct GNUNET_SOCIAL_Place` |
1025 | host_cleanup (struct GNUNET_SOCIAL_Host *hst) | 1102 | * @param msg the message from the service |
1026 | { | 1103 | */ |
1027 | if (NULL != hst->slicer) | ||
1028 | { | ||
1029 | GNUNET_PSYC_slicer_destroy (hst->slicer); | ||
1030 | hst->slicer = NULL; | ||
1031 | } | ||
1032 | GNUNET_free (hst); | ||
1033 | } | ||
1034 | |||
1035 | |||
1036 | static void | ||
1037 | guest_cleanup (struct GNUNET_SOCIAL_Guest *gst) | ||
1038 | { | ||
1039 | GNUNET_free (gst); | ||
1040 | } | ||
1041 | |||
1042 | |||
1043 | static void | ||
1044 | place_cleanup (struct GNUNET_SOCIAL_Place *plc) | ||
1045 | { | ||
1046 | struct GNUNET_HashCode place_pub_hash; | ||
1047 | |||
1048 | GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); | ||
1049 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1050 | "%s place cleanup: %s\n", | ||
1051 | GNUNET_YES == plc->is_host ? "host" : "guest", | ||
1052 | GNUNET_h2s (&place_pub_hash)); | ||
1053 | |||
1054 | if (NULL != plc->tmit) | ||
1055 | { | ||
1056 | GNUNET_PSYC_transmit_destroy (plc->tmit); | ||
1057 | plc->tmit = NULL; | ||
1058 | } | ||
1059 | if (NULL != plc->connect_env) | ||
1060 | { | ||
1061 | GNUNET_MQ_discard (plc->connect_env); | ||
1062 | plc->connect_env = NULL; | ||
1063 | } | ||
1064 | if (NULL != plc->mq) | ||
1065 | { | ||
1066 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1067 | "destroying MQ (place_cleanup)\n"); | ||
1068 | GNUNET_MQ_destroy (plc->mq); | ||
1069 | plc->mq = NULL; | ||
1070 | } | ||
1071 | if (NULL != plc->disconnect_cb) | ||
1072 | { | ||
1073 | plc->disconnect_cb (plc->disconnect_cls); | ||
1074 | plc->disconnect_cb = NULL; | ||
1075 | } | ||
1076 | |||
1077 | (GNUNET_YES == plc->is_host) | ||
1078 | ? host_cleanup ((struct GNUNET_SOCIAL_Host *) plc) | ||
1079 | : guest_cleanup ((struct GNUNET_SOCIAL_Guest *) plc); | ||
1080 | } | ||
1081 | |||
1082 | |||
1083 | static void | 1104 | static void |
1084 | place_disconnect (struct GNUNET_SOCIAL_Place *plc) | 1105 | handle_place_leave_ack (void *cls, |
1106 | const struct GNUNET_MessageHeader *msg) | ||
1085 | { | 1107 | { |
1086 | struct GNUNET_HashCode place_pub_hash; | 1108 | struct GNUNET_SOCIAL_Place *plc = cls; |
1087 | 1109 | ||
1088 | GNUNET_CRYPTO_hash (&plc->pub_key, | ||
1089 | sizeof (plc->pub_key), | ||
1090 | &place_pub_hash); | ||
1091 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1110 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1092 | "place_disconnect, plc = %s\n", | 1111 | "%s left place %p\n", |
1093 | GNUNET_h2s (&place_pub_hash)); | 1112 | plc->is_host ? "host" : "guest", |
1094 | place_cleanup (plc); | 1113 | plc); |
1114 | place_disconnect (plc); | ||
1095 | } | 1115 | } |
1096 | 1116 | ||
1097 | 1117 | ||
@@ -1153,6 +1173,10 @@ host_connect (struct GNUNET_SOCIAL_Host *hst) | |||
1153 | GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK, | 1173 | GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK, |
1154 | struct HostEnterAck, | 1174 | struct HostEnterAck, |
1155 | hst), | 1175 | hst), |
1176 | GNUNET_MQ_hd_fixed_size (place_leave_ack, | ||
1177 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK, | ||
1178 | struct GNUNET_MessageHeader, | ||
1179 | plc), | ||
1156 | GNUNET_MQ_hd_var_size (host_enter_request, | 1180 | GNUNET_MQ_hd_var_size (host_enter_request, |
1157 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, | 1181 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, |
1158 | struct GNUNET_PSYC_JoinRequestMessage, | 1182 | struct GNUNET_PSYC_JoinRequestMessage, |
@@ -1702,6 +1726,10 @@ guest_connect (struct GNUNET_SOCIAL_Guest *gst) | |||
1702 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK, | 1726 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK, |
1703 | struct GNUNET_PSYC_CountersResultMessage, | 1727 | struct GNUNET_PSYC_CountersResultMessage, |
1704 | gst), | 1728 | gst), |
1729 | GNUNET_MQ_hd_fixed_size (place_leave_ack, | ||
1730 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK, | ||
1731 | struct GNUNET_MessageHeader, | ||
1732 | plc), | ||
1705 | GNUNET_MQ_hd_var_size (guest_enter_decision, | 1733 | GNUNET_MQ_hd_var_size (guest_enter_decision, |
1706 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, | 1734 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, |
1707 | struct GNUNET_PSYC_JoinDecisionMessage, | 1735 | struct GNUNET_PSYC_JoinDecisionMessage, |