[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37731 - in gnunet/src: multicast psyc social
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37731 - in gnunet/src: multicast psyc social |
Date: |
Thu, 18 Aug 2016 00:28:52 +0200 |
Author: tg
Date: 2016-08-18 00:28:52 +0200 (Thu, 18 Aug 2016)
New Revision: 37731
Modified:
gnunet/src/multicast/multicast_api.c
gnunet/src/multicast/test_multicast.c
gnunet/src/psyc/psyc_api.c
gnunet/src/social/social_api.c
Log:
multicast, psyc, social: wait till last message sent before disconnect
Modified: gnunet/src/multicast/multicast_api.c
===================================================================
--- gnunet/src/multicast/multicast_api.c 2016-08-17 22:28:47 UTC (rev
37730)
+++ gnunet/src/multicast/multicast_api.c 2016-08-17 22:28:52 UTC (rev
37731)
@@ -522,27 +522,51 @@
static void
group_cleanup (struct GNUNET_MULTICAST_Group *grp)
{
- GNUNET_MQ_discard (grp->connect_env);
+ if (NULL != grp->connect_env)
+ {
+ GNUNET_MQ_discard (grp->connect_env);
+ grp->connect_env = NULL;
+ }
+ if (NULL != grp->mq)
+ {
+ GNUNET_MQ_destroy (grp->mq);
+ grp->mq = NULL;
+ }
if (NULL != grp->disconnect_cb)
+ {
grp->disconnect_cb (grp->disconnect_cls);
+ grp->disconnect_cb = NULL;
+ }
+ GNUNET_free (grp);
}
static void
-origin_cleanup (void *cls)
+group_disconnect (struct GNUNET_MULTICAST_Group *grp,
+ GNUNET_ContinuationCallback cb,
+ void *cls)
{
- struct GNUNET_MULTICAST_Origin *orig = cls;
- group_cleanup (&orig->grp);
- GNUNET_free (orig);
-}
+ grp->is_disconnecting = GNUNET_YES;
+ grp->disconnect_cb = cb;
+ grp->disconnect_cls = cls;
-
-static void
-member_cleanup (void *cls)
-{
- struct GNUNET_MULTICAST_Member *mem = cls;
- group_cleanup (&mem->grp);
- GNUNET_free (mem);
+ if (NULL != grp->mq)
+ {
+ struct GNUNET_MQ_Envelope *last = GNUNET_MQ_get_last_envelope (grp->mq);
+ if (NULL != last)
+ {
+ GNUNET_MQ_notify_sent (last,
+ (GNUNET_MQ_NotifyCallback) group_cleanup, grp);
+ }
+ else
+ {
+ group_cleanup (grp);
+ }
+ }
+ else
+ {
+ group_cleanup (grp);
+ }
}
@@ -861,17 +885,7 @@
{
struct GNUNET_MULTICAST_Group *grp = &orig->grp;
- grp->is_disconnecting = GNUNET_YES;
- grp->disconnect_cb = stop_cb;
- grp->disconnect_cls = stop_cls;
-
- // FIXME: wait till queued messages are sent
- if (NULL != grp->mq)
- {
- GNUNET_MQ_destroy (grp->mq);
- grp->mq = NULL;
- }
- origin_cleanup (orig);
+ group_disconnect (grp, stop_cb, stop_cls);
}
@@ -1198,10 +1212,6 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Member parting.\n", mem);
struct GNUNET_MULTICAST_Group *grp = &mem->grp;
- grp->is_disconnecting = GNUNET_YES;
- grp->disconnect_cb = part_cb;
- grp->disconnect_cls = part_cls;
-
mem->join_dcsn_cb = NULL;
grp->join_req_cb = NULL;
grp->message_cb = NULL;
@@ -1208,13 +1218,7 @@
grp->replay_msg_cb = NULL;
grp->replay_frag_cb = NULL;
- // FIXME: wait till queued messages are sent
- if (NULL != grp->mq)
- {
- GNUNET_MQ_destroy (grp->mq);
- grp->mq = NULL;
- }
- member_cleanup (mem);
+ group_disconnect (grp, part_cb, part_cls);
}
Modified: gnunet/src/multicast/test_multicast.c
===================================================================
--- gnunet/src/multicast/test_multicast.c 2016-08-17 22:28:47 UTC (rev
37730)
+++ gnunet/src/multicast/test_multicast.c 2016-08-17 22:28:52 UTC (rev
37731)
@@ -239,7 +239,7 @@
const struct GNUNET_MessageHeader *join_msg,
struct GNUNET_MULTICAST_JoinHandle *jh)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: member_recv_join_request()\n", test);
}
@@ -247,7 +247,7 @@
static void
origin_stopped (void *cls)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: origin_stopped()\n", test);
end ();
}
@@ -267,7 +267,7 @@
static void
member_parted (void *cls)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: member_parted()\n", test);
member = NULL;
@@ -283,7 +283,7 @@
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Invalid test #%d in member_recv_join_decision()\n", test);
+ "Invalid test #%d in member_parted()\n", test);
GNUNET_assert (0);
}
}
@@ -292,7 +292,7 @@
static void
schedule_member_part (void *cls)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: schedule_member_part()\n", test);
GNUNET_MULTICAST_member_part (member, member_parted, NULL);
}
@@ -312,7 +312,7 @@
member_replay_ok ()
{
test = TEST_MEMBER_REPLAY_OK;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: member_replay_ok()\n", test);
replay_fragment_id = 1;
replay_flags = 1 | 1<<11;
@@ -325,7 +325,7 @@
member_replay_error ()
{
test = TEST_MEMBER_REPLAY_ERROR;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: member_replay_error()\n", test);
replay_fragment_id = 1234;
replay_flags = 11 | 1<<11;
@@ -342,7 +342,7 @@
uint64_t flags,
struct GNUNET_MULTICAST_ReplayHandle *rh)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: origin_recv_replay_msg()\n", test);
GNUNET_assert (0);
}
@@ -356,7 +356,7 @@
uint64_t flags,
struct GNUNET_MULTICAST_ReplayHandle *rh)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: member_recv_replay_msg()\n", test);
GNUNET_assert (0);
}
@@ -369,7 +369,7 @@
uint64_t flags,
struct GNUNET_MULTICAST_ReplayHandle *rh)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: origin_recv_replay_frag()"
" - fragment_id=%" PRIu64 " flags=%" PRIu64 "\n",
test, fragment_id, flags);
@@ -416,7 +416,7 @@
uint64_t flags,
struct GNUNET_MULTICAST_ReplayHandle *rh)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: member_recv_replay_frag()\n", test);
GNUNET_assert (0);
}
@@ -427,7 +427,7 @@
const struct GNUNET_MULTICAST_RequestHeader *req)
{
struct OriginClosure *ocls = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: origin_recv_request()\n", test);
if (++ocls->n != ocls->msgs_expected)
return;
@@ -446,7 +446,7 @@
member_to_origin ()
{
test = TEST_MEMBER_TO_ORIGIN;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: member_to_origin()\n", test);
struct TransmitClosure *tmit = &tmit_cls;
@@ -471,7 +471,7 @@
{
struct MemberClosure *mcls = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: member_recv_message() %u/%u\n",
test,
(unsigned int) (mcls->n + 1),
@@ -505,7 +505,7 @@
const struct GNUNET_MULTICAST_MessageHeader *msg)
{
struct OriginClosure *ocls = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: origin_recv_message() %u/%u\n",
test, ocls->n + 1, ocls->msgs_expected);
if (++ocls->n != ocls->msgs_expected)
@@ -562,7 +562,7 @@
const struct GNUNET_PeerIdentity *relays,
const struct GNUNET_MessageHeader *join_msg)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: member_recv_join_decision() - is_admitted: %d\n",
test, is_admitted);
@@ -597,7 +597,7 @@
const struct GNUNET_MessageHeader *join_msg,
struct GNUNET_MULTICAST_JoinHandle *jh)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test #%u: origin_recv_join_request()\n", test);
GNUNET_assert (0 == memcmp (mem_key, &member_pub_key, sizeof
(member_pub_key)));
Modified: gnunet/src/psyc/psyc_api.c
===================================================================
--- gnunet/src/psyc/psyc_api.c 2016-08-17 22:28:47 UTC (rev 37730)
+++ gnunet/src/psyc/psyc_api.c 2016-08-17 22:28:52 UTC (rev 37731)
@@ -548,33 +548,21 @@
GNUNET_MQ_discard (chn->connect_env);
chn->connect_env = NULL;
}
+ if (NULL != chn->mq)
+ {
+ GNUNET_MQ_destroy (chn->mq);
+ chn->mq = NULL;
+ }
if (NULL != chn->disconnect_cb)
{
chn->disconnect_cb (chn->disconnect_cls);
chn->disconnect_cb = NULL;
}
+ GNUNET_free (chn);
}
static void
-master_cleanup (void *cls)
-{
- struct GNUNET_PSYC_Master *mst = cls;
- channel_cleanup (&mst->chn);
- GNUNET_free (mst);
-}
-
-
-static void
-slave_cleanup (void *cls)
-{
- struct GNUNET_PSYC_Slave *slv = cls;
- channel_cleanup (&slv->chn);
- GNUNET_free (slv);
-}
-
-
-static void
channel_disconnect (struct GNUNET_PSYC_Channel *chn,
GNUNET_ContinuationCallback cb,
void *cls)
@@ -583,12 +571,23 @@
chn->disconnect_cb = cb;
chn->disconnect_cls = cls;
- // FIXME: wait till queued messages are sent
if (NULL != chn->mq)
{
- GNUNET_MQ_destroy (chn->mq);
- chn->mq = NULL;
+ struct GNUNET_MQ_Envelope *last = GNUNET_MQ_get_last_envelope (chn->mq);
+ if (NULL != last)
+ {
+ GNUNET_MQ_notify_sent (last,
+ (GNUNET_MQ_NotifyCallback) channel_cleanup, chn);
+ }
+ else
+ {
+ channel_cleanup (chn);
+ }
}
+ else
+ {
+ channel_cleanup (chn);
+ }
}
@@ -772,7 +771,6 @@
/* FIXME: send msg to service */
channel_disconnect (chn, stop_cb, stop_cls);
- master_cleanup (mst);
}
@@ -1107,7 +1105,6 @@
/* FIXME: send msg to service */
channel_disconnect (chn, part_cb, part_cls);
- slave_cleanup (slv);
}
Modified: gnunet/src/social/social_api.c
===================================================================
--- gnunet/src/social/social_api.c 2016-08-17 22:28:47 UTC (rev 37730)
+++ gnunet/src/social/social_api.c 2016-08-17 22:28:52 UTC (rev 37731)
@@ -359,7 +359,6 @@
struct ZoneAddPlaceHandle
{
- struct ZoneAddPlaceRequest *req;
GNUNET_ResultCallback result_cb;
void *result_cls;
};
@@ -1007,7 +1006,29 @@
}
+/*** CLEANUP / DISCONNECT ***/
+
+
static void
+host_cleanup (struct GNUNET_SOCIAL_Host *hst)
+{
+ if (NULL != hst->slicer)
+ {
+ GNUNET_PSYC_slicer_destroy (hst->slicer);
+ hst->slicer = NULL;
+ }
+ GNUNET_free (hst);
+}
+
+
+static void
+guest_cleanup (struct GNUNET_SOCIAL_Guest *gst)
+{
+ GNUNET_free (gst);
+}
+
+
+static void
place_cleanup (struct GNUNET_SOCIAL_Place *plc)
{
struct GNUNET_HashCode place_pub_hash;
@@ -1027,32 +1048,59 @@
GNUNET_MQ_discard (plc->connect_env);
plc->connect_env = NULL;
}
+ if (NULL != plc->mq)
+ {
+ GNUNET_MQ_destroy (plc->mq);
+ plc->mq = NULL;
+ }
if (NULL != plc->disconnect_cb)
{
plc->disconnect_cb (plc->disconnect_cls);
plc->disconnect_cb = NULL;
}
+
+ (GNUNET_YES == plc->is_host)
+ ? host_cleanup ((struct GNUNET_SOCIAL_Host *) plc)
+ : guest_cleanup ((struct GNUNET_SOCIAL_Guest *) plc);
}
-static void
-host_cleanup (struct GNUNET_SOCIAL_Host *hst)
+void
+place_disconnect (struct GNUNET_SOCIAL_Place *plc,
+ GNUNET_ContinuationCallback disconnect_cb,
+ void *disconnect_cls)
{
- place_cleanup (&hst->plc);
- if (NULL != hst->slicer)
+ plc->disconnect_cb = disconnect_cb;
+ plc->disconnect_cls = disconnect_cls;
+
+ if (NULL != plc->mq)
{
- GNUNET_PSYC_slicer_destroy (hst->slicer);
- hst->slicer = NULL;
+ struct GNUNET_MQ_Envelope *last = GNUNET_MQ_get_last_envelope (plc->mq);
+ if (NULL != last)
+ {
+ GNUNET_MQ_notify_sent (last,
+ (GNUNET_MQ_NotifyCallback) place_cleanup, plc);
+ }
+ else
+ {
+ place_cleanup (plc);
+ }
}
- GNUNET_free (hst);
+ else
+ {
+ place_cleanup (plc);
+ }
}
-static void
-guest_cleanup (struct GNUNET_SOCIAL_Guest *gst)
+void
+place_leave (struct GNUNET_SOCIAL_Place *plc)
{
- place_cleanup (&gst->plc);
- GNUNET_free (gst);
+ 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);
}
@@ -1518,34 +1566,6 @@
}
-void
-place_leave (struct GNUNET_SOCIAL_Place *plc)
-{
- 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);
-}
-
-
-void
-place_disconnect (struct GNUNET_SOCIAL_Place *plc,
- GNUNET_ContinuationCallback disconnect_cb,
- void *disconnect_cls)
-{
- plc->disconnect_cb = disconnect_cb;
- plc->disconnect_cls = disconnect_cls;
-
- // FIXME: wait till queued messages are sent
- if (NULL != plc->mq)
- {
- GNUNET_MQ_destroy (plc->mq);
- plc->mq = NULL;
- }
-}
-
-
/**
* Disconnect from a home.
*
@@ -1560,7 +1580,6 @@
void *cls)
{
place_disconnect (&hst->plc, disconnect_cb, cls);
- host_cleanup (hst);
}
@@ -2016,7 +2035,6 @@
void *cls)
{
place_disconnect (&gst->plc, disconnect_cb, cls);
- guest_cleanup (gst);
}
@@ -2363,7 +2381,6 @@
if (NULL != add_plc->result_cb)
add_plc->result_cb (add_plc->result_cls, result, err_msg, err_msg_size);
- GNUNET_free (add_plc->req);
GNUNET_free (add_plc);
}
@@ -2435,7 +2452,6 @@
GNUNET_memcpy (p, relays, relay_size);
struct ZoneAddPlaceHandle * add_plc = GNUNET_malloc (sizeof (*add_plc));
- add_plc->req = preq;
add_plc->result_cb = result_cb;
add_plc->result_cls = result_cls;
@@ -2657,6 +2673,22 @@
}
+static void
+app_cleanup (struct GNUNET_SOCIAL_App *app)
+{
+ if (NULL != app->mq)
+ {
+ GNUNET_MQ_destroy (app->mq);
+ app->mq = NULL;
+ }
+ if (NULL != app->disconnect_cb)
+ {
+ app->disconnect_cb (app->disconnect_cls);
+ app->disconnect_cb = NULL;
+ }
+ GNUNET_free (app);
+}
+
/**
* Disconnect application.
*
@@ -2672,15 +2704,26 @@
GNUNET_ContinuationCallback disconnect_cb,
void *disconnect_cls)
{
- // FIXME: wait till queued messages are sent
+ app->disconnect_cb = disconnect_cb;
+ app->disconnect_cls = disconnect_cls;
+
if (NULL != app->mq)
{
- GNUNET_MQ_destroy (app->mq);
- app->mq = NULL;
+ struct GNUNET_MQ_Envelope *last = GNUNET_MQ_get_last_envelope (app->mq);
+ if (NULL != last)
+ {
+ GNUNET_MQ_notify_sent (last,
+ (GNUNET_MQ_NotifyCallback) app_cleanup, app);
+ }
+ else
+ {
+ app_cleanup (app);
+ }
}
-
- if (NULL != disconnect_cb)
- disconnect_cb (disconnect_cls);
+ else
+ {
+ app_cleanup (app);
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37731 - in gnunet/src: multicast psyc social,
gnunet <=