aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-10-28 11:21:55 +0200
committerChristian Grothoff <christian@grothoff.org>2017-10-28 11:21:55 +0200
commite429bb239daae8d0c241176252280caa94143312 (patch)
tree26bbbefcf6bd9a14f6f084f41a5c9e8bdd522212
parentb822e98f7ea722f7f0604bd9cef9aa436e7bab7d (diff)
downloadgnunet-e429bb239daae8d0c241176252280caa94143312.tar.gz
gnunet-e429bb239daae8d0c241176252280caa94143312.zip
misc social hacking with Lurchi
-rw-r--r--src/social/gnunet-service-social.c30
-rw-r--r--src/social/social_api.c132
-rw-r--r--src/social/test_social.conf2
-rw-r--r--src/util/mq.c2
-rw-r--r--src/util/service.c1
5 files changed, 117 insertions, 50 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c
index 4541a4e06..f9e70a25d 100644
--- a/src/social/gnunet-service-social.c
+++ b/src/social/gnunet-service-social.c
@@ -1935,7 +1935,7 @@ client_guest_enter (struct Client *c,
1935 struct ClientListItem *cli = GNUNET_new (struct ClientListItem); 1935 struct ClientListItem *cli = GNUNET_new (struct ClientListItem);
1936 cli->client = client; 1936 cli->client = client;
1937 GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli); 1937 GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli);
1938 return GNUNET_OK; 1938 return GNUNET_OK;
1939} 1939}
1940 1940
1941 1941
@@ -2224,7 +2224,7 @@ handle_client_place_leave (void *cls,
2224 struct Client *c = cls; 2224 struct Client *c = cls;
2225 struct GNUNET_SERVICE_Client *client = c->client; 2225 struct GNUNET_SERVICE_Client *client = c->client;
2226 struct Place *plc = c->place; 2226 struct Place *plc = c->place;
2227 2227
2228 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 2228 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
2229 "handle_client_place_leave\n"); 2229 "handle_client_place_leave\n");
2230 2230
@@ -2251,6 +2251,7 @@ handle_client_place_leave (void *cls,
2251 while (NULL != cli) 2251 while (NULL != cli)
2252 { 2252 {
2253 GNUNET_CONTAINER_DLL_remove (plc->clients_head, plc->clients_tail, cli); 2253 GNUNET_CONTAINER_DLL_remove (plc->clients_head, plc->clients_tail, cli);
2254 // protocol design failure: should *tell* clients that room is gone!
2254 GNUNET_SERVICE_client_drop (cli->client); 2255 GNUNET_SERVICE_client_drop (cli->client);
2255 next = cli->next; 2256 next = cli->next;
2256 GNUNET_free (cli); 2257 GNUNET_free (cli);
@@ -2269,8 +2270,8 @@ handle_client_place_leave (void *cls,
2269 cleanup_place (plc); 2270 cleanup_place (plc);
2270 } 2271 }
2271 } 2272 }
2272 //GNUNET_SERVICE_client_continue (client); 2273 // FIXME: can't continue+drop above, but should not drop above!
2273 //GNUNET_SERVICE_client_drop (client); 2274 // GNUNET_SERVICE_client_continue (client);
2274} 2275}
2275 2276
2276 2277
@@ -2958,15 +2959,14 @@ handle_client_psyc_message (void *cls,
2958 struct Client *c = cls; 2959 struct Client *c = cls;
2959 struct GNUNET_SERVICE_Client *client = c->client; 2960 struct GNUNET_SERVICE_Client *client = c->client;
2960 struct Place *plc = c->place; 2961 struct Place *plc = c->place;
2962 int ret;
2963
2961 if (NULL == plc) 2964 if (NULL == plc)
2962 { 2965 {
2963 GNUNET_break (0); 2966 GNUNET_break (0);
2964 GNUNET_SERVICE_client_drop (client); 2967 GNUNET_SERVICE_client_drop (client);
2965 return; 2968 return;
2966 } 2969 }
2967
2968 int ret = GNUNET_SYSERR;
2969
2970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2971 "%p Received message from client.\n", plc); 2971 "%p Received message from client.\n", plc);
2972 GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg); 2972 GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg);
@@ -2994,10 +2994,11 @@ handle_client_psyc_message (void *cls,
2994 return; 2994 return;
2995 } 2995 }
2996 2996
2997 uint16_t first_ptype = 0, last_ptype = 0; 2997 uint16_t first_ptype = 0;
2998 if (GNUNET_SYSERR 2998 uint16_t last_ptype = 0;
2999 == GNUNET_PSYC_receive_check_parts (psize, (const char *) &msg[1], 2999 if (GNUNET_SYSERR ==
3000 &first_ptype, &last_ptype)) 3000 GNUNET_PSYC_receive_check_parts (psize, (const char *) &msg[1],
3001 &first_ptype, &last_ptype))
3001 { 3002 {
3002 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3003 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3003 "%p Received invalid message part from client.\n", plc); 3004 "%p Received invalid message part from client.\n", plc);
@@ -3019,7 +3020,10 @@ handle_client_psyc_message (void *cls,
3019 c->tmit_msg = NULL; 3020 c->tmit_msg = NULL;
3020 ret = psyc_transmit_message (plc); 3021 ret = psyc_transmit_message (plc);
3021 } 3022 }
3022 3023 else
3024 {
3025 ret = GNUNET_SYSERR;
3026 }
3023 if (GNUNET_OK != ret) 3027 if (GNUNET_OK != ret)
3024 { 3028 {
3025 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3029 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -3440,7 +3444,7 @@ path_basename (const char *path)
3440 if (NULL != basename) 3444 if (NULL != basename)
3441 basename++; 3445 basename++;
3442 3446
3443 if (NULL == basename || '\0' == basename) 3447 if (NULL == basename || '\0' == *basename)
3444 return NULL; 3448 return NULL;
3445 3449
3446 return basename; 3450 return basename;
diff --git a/src/social/social_api.c b/src/social/social_api.c
index 923ab5e33..fc649fcde 100644
--- a/src/social/social_api.c
+++ b/src/social/social_api.c
@@ -1079,43 +1079,18 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc)
1079} 1079}
1080 1080
1081 1081
1082void 1082static void
1083place_disconnect (struct GNUNET_SOCIAL_Place *plc) 1083place_disconnect (struct GNUNET_SOCIAL_Place *plc)
1084{ 1084{
1085 struct GNUNET_HashCode place_pub_hash; 1085 struct GNUNET_HashCode place_pub_hash;
1086 GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); 1086
1087 GNUNET_CRYPTO_hash (&plc->pub_key,
1088 sizeof (plc->pub_key),
1089 &place_pub_hash);
1087 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1090 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1088 "place_disconnect, plc = %s\n", 1091 "place_disconnect, plc = %s\n",
1089 GNUNET_h2s (&place_pub_hash)); 1092 GNUNET_h2s (&place_pub_hash));
1090 if (NULL != plc->mq) 1093 place_cleanup (plc);
1091 {
1092 struct GNUNET_MQ_Envelope *env = GNUNET_MQ_get_last_envelope (plc->mq);
1093 if (NULL != env)
1094 {
1095 GNUNET_MQ_notify_sent (env, (GNUNET_SCHEDULER_TaskCallback) place_cleanup, plc);
1096 }
1097 else
1098 {
1099 place_cleanup (plc);
1100 }
1101 }
1102 else
1103 {
1104 place_cleanup (plc);
1105 }
1106}
1107
1108
1109void
1110place_leave (struct GNUNET_SOCIAL_Place *plc)
1111{
1112 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1113 "social_api: place_leave\n");
1114 struct GNUNET_MessageHeader *msg;
1115 struct GNUNET_MQ_Envelope *
1116 env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE);
1117
1118 GNUNET_MQ_send (plc->mq, env);
1119} 1094}
1120 1095
1121 1096
@@ -1589,7 +1564,7 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst,
1589 GNUNET_ContinuationCallback disconnect_cb, 1564 GNUNET_ContinuationCallback disconnect_cb,
1590 void *cls) 1565 void *cls)
1591{ 1566{
1592 struct GNUNET_SOCIAL_Place *plc = &hst->plc; 1567 struct GNUNET_SOCIAL_Place *plc = &hst->plc;
1593 1568
1594 plc->disconnect_cb = disconnect_cb; 1569 plc->disconnect_cb = disconnect_cb;
1595 plc->disconnect_cls = cls; 1570 plc->disconnect_cls = cls;
@@ -1598,6 +1573,32 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst,
1598 1573
1599 1574
1600/** 1575/**
1576 * Closure for #host_leave_cont.
1577 */
1578struct HostLeaveContext
1579{
1580 struct GNUNET_SOCIAL_Host *hst;
1581 GNUNET_ContinuationCallback disconnect_cb;
1582 void *disconnect_cb_cls;
1583};
1584
1585
1586/**
1587 * FIXME.
1588 */
1589static void
1590host_leave_cont (void *cls)
1591{
1592 struct HostLeaveContext *hlc = cls;
1593
1594 GNUNET_SOCIAL_host_disconnect (hlc->hst,
1595 hlc->disconnect_cb,
1596 hlc->disconnect_cb_cls);
1597 GNUNET_free (hlc);
1598}
1599
1600
1601/**
1601 * Stop hosting the home. 1602 * Stop hosting the home.
1602 * 1603 *
1603 * Sends a _notice_place_closing announcement to the home. 1604 * Sends a _notice_place_closing announcement to the home.
@@ -1620,12 +1621,25 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst,
1620 GNUNET_ContinuationCallback disconnect_cb, 1621 GNUNET_ContinuationCallback disconnect_cb,
1621 void *cls) 1622 void *cls)
1622{ 1623{
1624 struct GNUNET_MessageHeader *msg;
1625 struct GNUNET_MQ_Envelope *envelope;
1626 struct HostLeaveContext *hlc;
1627
1623 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1628 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1624 "GNUNET_SOCIAL_host_leave\n"); 1629 "GNUNET_SOCIAL_host_leave\n");
1625 GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, 1630 GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL,
1626 GNUNET_SOCIAL_ANNOUNCE_NONE); 1631 GNUNET_SOCIAL_ANNOUNCE_NONE);
1627 place_leave (&hst->plc); 1632 envelope = GNUNET_MQ_msg (msg,
1628 GNUNET_SOCIAL_host_disconnect (hst, disconnect_cb, cls); 1633 GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE);
1634 hlc = GNUNET_new (struct HostLeaveContext);
1635 hlc->hst = hst;
1636 hlc->disconnect_cb = disconnect_cb;
1637 hlc->disconnect_cb_cls = cls;
1638 GNUNET_MQ_notify_sent (envelope,
1639 &host_leave_cont,
1640 hlc);
1641 GNUNET_MQ_send (hst->plc.mq,
1642 envelope);
1629} 1643}
1630 1644
1631 1645
@@ -2057,6 +2071,35 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst,
2057 2071
2058 2072
2059/** 2073/**
2074 * Closure for #leave_done_cont.
2075 */
2076struct LeaveContext
2077{
2078 struct GNUNET_SOCIAL_Guest *gst;
2079 GNUNET_ContinuationCallback disconnect_cb;
2080 void *disconnect_cb_cls;
2081};
2082
2083
2084/**
2085 * The leave message was transmitted, now complete the
2086 * disconnection process.
2087 *
2088 * @param cls a `struct LeaveContext`
2089 */
2090static void
2091leave_done_cont (void *cls)
2092{
2093 struct LeaveContext *lc = cls;
2094
2095 GNUNET_SOCIAL_guest_disconnect (lc->gst,
2096 lc->disconnect_cb,
2097 lc->disconnect_cb_cls);
2098 GNUNET_free (lc);
2099}
2100
2101
2102/**
2060 * Leave a place temporarily or permanently. 2103 * Leave a place temporarily or permanently.
2061 * 2104 *
2062 * Notifies the owner of the place about leaving, and destroys the place handle. 2105 * Notifies the owner of the place about leaving, and destroys the place handle.
@@ -2078,10 +2121,27 @@ GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst,
2078 GNUNET_ContinuationCallback disconnect_cb, 2121 GNUNET_ContinuationCallback disconnect_cb,
2079 void *cls) 2122 void *cls)
2080{ 2123{
2124 struct GNUNET_MessageHeader *msg;
2125 struct GNUNET_MQ_Envelope *envelope;
2126 struct LeaveContext *lc;
2127
2081 GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL, 2128 GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL,
2082 GNUNET_SOCIAL_TALK_NONE); 2129 GNUNET_SOCIAL_TALK_NONE);
2083 place_leave (&gst->plc); 2130
2084 GNUNET_SOCIAL_guest_disconnect (gst, disconnect_cb, cls); 2131
2132 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2133 "social_api: place_leave\n");
2134 envelope = GNUNET_MQ_msg (msg,
2135 GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE);
2136 lc = GNUNET_new (struct LeaveContext);
2137 lc->gst = gst;
2138 lc->disconnect_cb = disconnect_cb;
2139 lc->disconnect_cb_cls = cls;
2140 GNUNET_MQ_notify_sent (envelope,
2141 &leave_done_cont,
2142 lc);
2143 GNUNET_MQ_send (gst->plc.mq,
2144 envelope);
2085} 2145}
2086 2146
2087 2147
diff --git a/src/social/test_social.conf b/src/social/test_social.conf
index d3657057a..52ed20c6b 100644
--- a/src/social/test_social.conf
+++ b/src/social/test_social.conf
@@ -1,3 +1,5 @@
1@INLINE@ ../../contrib/no_forcestart.conf
2
1[social] 3[social]
2AUTOSTART = YES 4AUTOSTART = YES
3FORCESTART = YES 5FORCESTART = YES
diff --git a/src/util/mq.c b/src/util/mq.c
index 5523b261c..c7ed5330e 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -61,7 +61,7 @@ struct GNUNET_MQ_Envelope
61 GNUNET_SCHEDULER_TaskCallback sent_cb; 61 GNUNET_SCHEDULER_TaskCallback sent_cb;
62 62
63 /** 63 /**
64 * Closure for @e send_cb 64 * Closure for @e sent_cb
65 */ 65 */
66 void *sent_cls; 66 void *sent_cls;
67 67
diff --git a/src/util/service.c b/src/util/service.c
index fcdf45a51..10dc93faf 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -2431,6 +2431,7 @@ resume_client_receive (void *cls)
2431void 2431void
2432GNUNET_SERVICE_client_continue (struct GNUNET_SERVICE_Client *c) 2432GNUNET_SERVICE_client_continue (struct GNUNET_SERVICE_Client *c)
2433{ 2433{
2434 GNUNET_assert (NULL == c->drop_task);
2434 GNUNET_assert (GNUNET_YES == c->needs_continue); 2435 GNUNET_assert (GNUNET_YES == c->needs_continue);
2435 GNUNET_assert (NULL == c->recv_task); 2436 GNUNET_assert (NULL == c->recv_task);
2436 c->needs_continue = GNUNET_NO; 2437 c->needs_continue = GNUNET_NO;