[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 09/64: misc social hacking with Lurchi
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 09/64: misc social hacking with Lurchi |
Date: |
Sat, 30 Dec 2017 20:57:54 +0100 |
This is an automated email from the git hooks/post-receive script.
lurchi pushed a commit to branch master
in repository gnunet.
commit e429bb239daae8d0c241176252280caa94143312
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Oct 28 11:21:55 2017 +0200
misc social hacking with Lurchi
---
src/social/gnunet-service-social.c | 30 +++++----
src/social/social_api.c | 132 +++++++++++++++++++++++++++----------
src/social/test_social.conf | 2 +
src/util/mq.c | 2 +-
src/util/service.c | 1 +
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,
struct ClientListItem *cli = GNUNET_new (struct ClientListItem);
cli->client = client;
GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli);
- return GNUNET_OK;
+ return GNUNET_OK;
}
@@ -2224,7 +2224,7 @@ handle_client_place_leave (void *cls,
struct Client *c = cls;
struct GNUNET_SERVICE_Client *client = c->client;
struct Place *plc = c->place;
-
+
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
"handle_client_place_leave\n");
@@ -2251,6 +2251,7 @@ handle_client_place_leave (void *cls,
while (NULL != cli)
{
GNUNET_CONTAINER_DLL_remove (plc->clients_head, plc->clients_tail, cli);
+ // protocol design failure: should *tell* clients that room is gone!
GNUNET_SERVICE_client_drop (cli->client);
next = cli->next;
GNUNET_free (cli);
@@ -2269,8 +2270,8 @@ handle_client_place_leave (void *cls,
cleanup_place (plc);
}
}
- //GNUNET_SERVICE_client_continue (client);
- //GNUNET_SERVICE_client_drop (client);
+ // FIXME: can't continue+drop above, but should not drop above!
+ // GNUNET_SERVICE_client_continue (client);
}
@@ -2958,15 +2959,14 @@ handle_client_psyc_message (void *cls,
struct Client *c = cls;
struct GNUNET_SERVICE_Client *client = c->client;
struct Place *plc = c->place;
+ int ret;
+
if (NULL == plc)
{
GNUNET_break (0);
GNUNET_SERVICE_client_drop (client);
return;
}
-
- int ret = GNUNET_SYSERR;
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%p Received message from client.\n", plc);
GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg);
@@ -2994,10 +2994,11 @@ handle_client_psyc_message (void *cls,
return;
}
- uint16_t first_ptype = 0, last_ptype = 0;
- if (GNUNET_SYSERR
- == GNUNET_PSYC_receive_check_parts (psize, (const char *) &msg[1],
- &first_ptype, &last_ptype))
+ uint16_t first_ptype = 0;
+ uint16_t last_ptype = 0;
+ if (GNUNET_SYSERR ==
+ GNUNET_PSYC_receive_check_parts (psize, (const char *) &msg[1],
+ &first_ptype, &last_ptype))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%p Received invalid message part from client.\n", plc);
@@ -3019,7 +3020,10 @@ handle_client_psyc_message (void *cls,
c->tmit_msg = NULL;
ret = psyc_transmit_message (plc);
}
-
+ else
+ {
+ ret = GNUNET_SYSERR;
+ }
if (GNUNET_OK != ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -3440,7 +3444,7 @@ path_basename (const char *path)
if (NULL != basename)
basename++;
- if (NULL == basename || '\0' == basename)
+ if (NULL == basename || '\0' == *basename)
return NULL;
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)
}
-void
+static void
place_disconnect (struct GNUNET_SOCIAL_Place *plc)
{
struct GNUNET_HashCode place_pub_hash;
- GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash);
+
+ GNUNET_CRYPTO_hash (&plc->pub_key,
+ sizeof (plc->pub_key),
+ &place_pub_hash);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"place_disconnect, plc = %s\n",
GNUNET_h2s (&place_pub_hash));
- if (NULL != plc->mq)
- {
- struct GNUNET_MQ_Envelope *env = GNUNET_MQ_get_last_envelope (plc->mq);
- if (NULL != env)
- {
- GNUNET_MQ_notify_sent (env, (GNUNET_SCHEDULER_TaskCallback)
place_cleanup, plc);
- }
- else
- {
- place_cleanup (plc);
- }
- }
- else
- {
- place_cleanup (plc);
- }
-}
-
-
-void
-place_leave (struct GNUNET_SOCIAL_Place *plc)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "social_api: place_leave\n");
- struct GNUNET_MessageHeader *msg;
- struct GNUNET_MQ_Envelope *
- env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE);
-
- GNUNET_MQ_send (plc->mq, env);
+ place_cleanup (plc);
}
@@ -1589,7 +1564,7 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host
*hst,
GNUNET_ContinuationCallback disconnect_cb,
void *cls)
{
- struct GNUNET_SOCIAL_Place *plc = &hst->plc;
+ struct GNUNET_SOCIAL_Place *plc = &hst->plc;
plc->disconnect_cb = disconnect_cb;
plc->disconnect_cls = cls;
@@ -1598,6 +1573,32 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host
*hst,
/**
+ * Closure for #host_leave_cont.
+ */
+struct HostLeaveContext
+{
+ struct GNUNET_SOCIAL_Host *hst;
+ GNUNET_ContinuationCallback disconnect_cb;
+ void *disconnect_cb_cls;
+};
+
+
+/**
+ * FIXME.
+ */
+static void
+host_leave_cont (void *cls)
+{
+ struct HostLeaveContext *hlc = cls;
+
+ GNUNET_SOCIAL_host_disconnect (hlc->hst,
+ hlc->disconnect_cb,
+ hlc->disconnect_cb_cls);
+ GNUNET_free (hlc);
+}
+
+
+/**
* Stop hosting the home.
*
* Sends a _notice_place_closing announcement to the home.
@@ -1620,12 +1621,25 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host
*hst,
GNUNET_ContinuationCallback disconnect_cb,
void *cls)
{
+ struct GNUNET_MessageHeader *msg;
+ struct GNUNET_MQ_Envelope *envelope;
+ struct HostLeaveContext *hlc;
+
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"GNUNET_SOCIAL_host_leave\n");
GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL,
GNUNET_SOCIAL_ANNOUNCE_NONE);
- place_leave (&hst->plc);
- GNUNET_SOCIAL_host_disconnect (hst, disconnect_cb, cls);
+ envelope = GNUNET_MQ_msg (msg,
+ GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE);
+ hlc = GNUNET_new (struct HostLeaveContext);
+ hlc->hst = hst;
+ hlc->disconnect_cb = disconnect_cb;
+ hlc->disconnect_cb_cls = cls;
+ GNUNET_MQ_notify_sent (envelope,
+ &host_leave_cont,
+ hlc);
+ GNUNET_MQ_send (hst->plc.mq,
+ envelope);
}
@@ -2057,6 +2071,35 @@ GNUNET_SOCIAL_guest_disconnect (struct
GNUNET_SOCIAL_Guest *gst,
/**
+ * Closure for #leave_done_cont.
+ */
+struct LeaveContext
+{
+ struct GNUNET_SOCIAL_Guest *gst;
+ GNUNET_ContinuationCallback disconnect_cb;
+ void *disconnect_cb_cls;
+};
+
+
+/**
+ * The leave message was transmitted, now complete the
+ * disconnection process.
+ *
+ * @param cls a `struct LeaveContext`
+ */
+static void
+leave_done_cont (void *cls)
+{
+ struct LeaveContext *lc = cls;
+
+ GNUNET_SOCIAL_guest_disconnect (lc->gst,
+ lc->disconnect_cb,
+ lc->disconnect_cb_cls);
+ GNUNET_free (lc);
+}
+
+
+/**
* Leave a place temporarily or permanently.
*
* 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,
GNUNET_ContinuationCallback disconnect_cb,
void *cls)
{
+ struct GNUNET_MessageHeader *msg;
+ struct GNUNET_MQ_Envelope *envelope;
+ struct LeaveContext *lc;
+
GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL,
GNUNET_SOCIAL_TALK_NONE);
- place_leave (&gst->plc);
- GNUNET_SOCIAL_guest_disconnect (gst, disconnect_cb, cls);
+
+
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "social_api: place_leave\n");
+ envelope = GNUNET_MQ_msg (msg,
+ GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE);
+ lc = GNUNET_new (struct LeaveContext);
+ lc->gst = gst;
+ lc->disconnect_cb = disconnect_cb;
+ lc->disconnect_cb_cls = cls;
+ GNUNET_MQ_notify_sent (envelope,
+ &leave_done_cont,
+ lc);
+ GNUNET_MQ_send (gst->plc.mq,
+ envelope);
}
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 @@
address@hidden@ ../../contrib/no_forcestart.conf
+
[social]
AUTOSTART = YES
FORCESTART = 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
GNUNET_SCHEDULER_TaskCallback sent_cb;
/**
- * Closure for @e send_cb
+ * Closure for @e sent_cb
*/
void *sent_cls;
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)
void
GNUNET_SERVICE_client_continue (struct GNUNET_SERVICE_Client *c)
{
+ GNUNET_assert (NULL == c->drop_task);
GNUNET_assert (GNUNET_YES == c->needs_continue);
GNUNET_assert (NULL == c->recv_task);
c->needs_continue = GNUNET_NO;
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] branch master updated (d01f1bd83 -> 5c8feda7f), gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 02/64: start social service before running the test (not sure if needed), gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 06/64: Merge branch 'fix_social' of ssh://gnunet.org/gnunet into fix_social, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 07/64: added mq logging, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 01/64: trying to fix test_social and social service with a lot of debug outputs, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 05/64: we were on the wood way, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 03/64: don't call GNUNET_SERVICE_client_continue twice; maybe fix bug resulting from destroying MQ too early, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 04/64: -we no enter to place, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 13/64: clarify use of client_drop, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 17/64: logging, cosmetic fixes, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 09/64: misc social hacking with Lurchi,
gnunet <=
- [GNUnet-SVN] [gnunet] 18/64: minor style fix, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 10/64: added logging, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 14/64: handle service disconnect without crashing if reconnect fails, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 15/64: better logging of message processing errors in mq handling, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 08/64: added logging, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 16/64: do handle CTRL-C properly in test_social, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 12/64: fix wrong condition, do only drop if it has not been dropped, instead of causing double-drop, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 11/64: Merge branch 'fix_social' of gnunet.org:gnunet into fix_social, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 20/64: Fix tcp on exit crash -- could have sworn I fixed this one before, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 21/64: Merge branch 'fix_social' of gnunet.org:gnunet into fix_social, gnunet, 2017/12/30