aboutsummaryrefslogtreecommitdiff
path: root/src/social
diff options
context:
space:
mode:
authorlurchi <lurchi@strangeplace.net>2017-12-30 18:27:09 +0100
committerlurchi <lurchi@strangeplace.net>2017-12-30 18:27:09 +0100
commitad24a2edfbae7aa37bc4cd74704d05a397e14d9b (patch)
tree08991307e5927b5ee18ea2e432a333204f4ffe84 /src/social
parent56c5769e15727b93864f5a257888fbc43eaae804 (diff)
downloadgnunet-ad24a2edfbae7aa37bc4cd74704d05a397e14d9b.tar.gz
gnunet-ad24a2edfbae7aa37bc4cd74704d05a397e14d9b.zip
fixing the place leave logic after protocol change
Diffstat (limited to 'src/social')
-rw-r--r--src/social/gnunet-service-social.c165
-rw-r--r--src/social/social_api.c67
2 files changed, 172 insertions, 60 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c
index 7396efef5..5b2a8ba9b 100644
--- a/src/social/gnunet-service-social.c
+++ b/src/social/gnunet-service-social.c
@@ -255,10 +255,10 @@ struct Place
255 uint8_t is_ready; 255 uint8_t is_ready;
256 256
257 /** 257 /**
258 * Is the client disconnected? 258 * Is the client disconnecting?
259 * #GNUNET_YES or #GNUNET_NO 259 * #GNUNET_YES or #GNUNET_NO
260 */ 260 */
261 uint8_t is_disconnected; 261 uint8_t is_disconnecting;
262 262
263 /** 263 /**
264 * Is this a host (#GNUNET_YES), or guest (#GNUNET_NO)? 264 * Is this a host (#GNUNET_YES), or guest (#GNUNET_NO)?
@@ -348,7 +348,7 @@ struct Guest
348 /** 348 /**
349 * Join request to be transmitted to the master on join. 349 * Join request to be transmitted to the master on join.
350 */ 350 */
351 struct GNUNET_MessageHeader *join_req; 351 struct GNUNET_MessageHeader *join_req; // FIXME: not used!
352 352
353 /** 353 /**
354 * Join decision received from PSYC. 354 * Join decision received from PSYC.
@@ -487,8 +487,6 @@ cleanup_host (struct Host *hst)
487{ 487{
488 struct Place *plc = &hst->place; 488 struct Place *plc = &hst->place;
489 489
490 if (NULL != hst->master)
491 GNUNET_PSYC_master_stop (hst->master, GNUNET_NO, NULL, NULL); // FIXME
492 GNUNET_CONTAINER_multihashmap_destroy (hst->join_reqs); 490 GNUNET_CONTAINER_multihashmap_destroy (hst->join_reqs);
493 GNUNET_CONTAINER_multihashmap_destroy (hst->relay_msgs); 491 GNUNET_CONTAINER_multihashmap_destroy (hst->relay_msgs);
494 GNUNET_CONTAINER_multihashmap_remove (hosts, &plc->pub_key_hash, plc); 492 GNUNET_CONTAINER_multihashmap_remove (hosts, &plc->pub_key_hash, plc);
@@ -505,7 +503,7 @@ cleanup_guest (struct Guest *gst)
505 struct GNUNET_CONTAINER_MultiHashMap * 503 struct GNUNET_CONTAINER_MultiHashMap *
506 plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, 504 plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests,
507 &plc->pub_key_hash); 505 &plc->pub_key_hash);
508 GNUNET_assert (NULL != plc_gst); // FIXME 506 GNUNET_assert (NULL != plc_gst);
509 GNUNET_CONTAINER_multihashmap_remove (plc_gst, &plc->ego_pub_hash, gst); 507 GNUNET_CONTAINER_multihashmap_remove (plc_gst, &plc->ego_pub_hash, gst);
510 508
511 if (0 == GNUNET_CONTAINER_multihashmap_size (plc_gst)) 509 if (0 == GNUNET_CONTAINER_multihashmap_size (plc_gst))
@@ -520,8 +518,6 @@ cleanup_guest (struct Guest *gst)
520 GNUNET_free (gst->join_req); 518 GNUNET_free (gst->join_req);
521 if (NULL != gst->relays) 519 if (NULL != gst->relays)
522 GNUNET_free (gst->relays); 520 GNUNET_free (gst->relays);
523 if (NULL != gst->slave)
524 GNUNET_PSYC_slave_part (gst->slave, GNUNET_NO, NULL, NULL); // FIXME
525 GNUNET_CONTAINER_multihashmap_remove (guests, &plc->pub_key_hash, plc); 521 GNUNET_CONTAINER_multihashmap_remove (guests, &plc->pub_key_hash, plc);
526} 522}
527 523
@@ -536,6 +532,10 @@ cleanup_place (void *cls)
536{ 532{
537 struct Place *plc = cls; 533 struct Place *plc = cls;
538 534
535 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
536 "cleaning up place %s\n",
537 GNUNET_h2s (&plc->pub_key_hash));
538
539 (GNUNET_YES == plc->is_host) 539 (GNUNET_YES == plc->is_host)
540 ? cleanup_host ((struct Host *) plc) 540 ? cleanup_host ((struct Host *) plc)
541 : cleanup_guest ((struct Guest *) plc); 541 : cleanup_guest ((struct Guest *) plc);
@@ -563,6 +563,7 @@ client_notify_disconnect (void *cls,
563 563
564 if (NULL != c->app_id) 564 if (NULL != c->app_id)
565 GNUNET_free (c->app_id); 565 GNUNET_free (c->app_id);
566
566 GNUNET_free (c); 567 GNUNET_free (c);
567 568
568 if (NULL == plc) 569 if (NULL == plc)
@@ -573,8 +574,6 @@ client_notify_disconnect (void *cls,
573 plc, (GNUNET_YES == plc->is_host) ? "host" : "guest", 574 plc, (GNUNET_YES == plc->is_host) ? "host" : "guest",
574 GNUNET_h2s (&plc->pub_key_hash)); 575 GNUNET_h2s (&plc->pub_key_hash));
575 576
576 // FIXME (due to protocol change): here we must not remove all clients,
577 // only the one we were notified about!
578 struct ClientListItem *cli = plc->clients_head; 577 struct ClientListItem *cli = plc->clients_head;
579 while (NULL != cli) 578 while (NULL != cli)
580 { 579 {
@@ -588,6 +587,11 @@ client_notify_disconnect (void *cls,
588 } 587 }
589 cli = cli->next; 588 cli = cli->next;
590 } 589 }
590 if (GNUNET_YES == plc->is_disconnecting)
591 {
592 GNUNET_PSYC_slicer_destroy (plc->slicer);
593 GNUNET_free (plc);
594 }
591} 595}
592 596
593 597
@@ -629,6 +633,9 @@ place_send_msg (const struct Place *plc,
629 "%p Sending message to clients of place.\n", plc); 633 "%p Sending message to clients of place.\n", plc);
630 while (NULL != cli) 634 while (NULL != cli)
631 { 635 {
636 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
637 "Sending message to client %p\n",
638 cli);
632 GNUNET_MQ_send_copy (GNUNET_SERVICE_client_get_mq (cli->client), 639 GNUNET_MQ_send_copy (GNUNET_SERVICE_client_get_mq (cli->client),
633 env); 640 env);
634 cli = cli->next; 641 cli = cli->next;
@@ -638,7 +645,7 @@ place_send_msg (const struct Place *plc,
638 645
639 646
640static void 647static void
641place_send_leave_ack (const struct Place *plc) 648place_send_leave_ack (struct Place *plc)
642{ 649{
643 struct GNUNET_MQ_Envelope *env; 650 struct GNUNET_MQ_Envelope *env;
644 651
@@ -756,17 +763,28 @@ psyc_slave_connected (void *cls, int result, uint64_t max_message_id)
756 struct GNUNET_MQ_Envelope *env; 763 struct GNUNET_MQ_Envelope *env;
757 struct Guest *gst = cls; 764 struct Guest *gst = cls;
758 struct Place *plc = &gst->place; 765 struct Place *plc = &gst->place;
759 766
760 plc->max_message_id = max_message_id; 767 plc->max_message_id = max_message_id;
761 plc->is_ready = GNUNET_YES; 768 plc->is_ready = GNUNET_YES;
762 env = GNUNET_MQ_msg (res, 769 env = GNUNET_MQ_msg (res,
763 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); 770 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK);
764 res->result_code = htonl (result); 771 res->result_code =
772 (result != GNUNET_SYSERR) ? htonl (GNUNET_OK) : htonl (GNUNET_SYSERR);
765 res->max_message_id = GNUNET_htonll (plc->max_message_id); 773 res->max_message_id = GNUNET_htonll (plc->max_message_id);
766 place_send_msg (plc, env); 774 place_send_msg (plc, env);
767} 775}
768 776
769 777
778static void
779slave_parted_after_join_decision (void *cls)
780{
781 struct Guest *gst = cls;
782
783 GNUNET_assert (NULL != gst->join_dcsn);
784 place_send_msg (&gst->place, GNUNET_MQ_msg_copy (&gst->join_dcsn->header));
785}
786
787
770/** 788/**
771 * Called when a PSYC slave receives a join decision. 789 * Called when a PSYC slave receives a join decision.
772 */ 790 */
@@ -777,7 +795,21 @@ psyc_recv_join_dcsn (void *cls,
777 const struct GNUNET_PSYC_Message *join_msg) 795 const struct GNUNET_PSYC_Message *join_msg)
778{ 796{
779 struct Guest *gst = cls; 797 struct Guest *gst = cls;
780 place_send_msg (&gst->place, GNUNET_MQ_msg_copy (&dcsn->header)); 798
799 gst->join_dcsn = GNUNET_malloc (dcsn->header.size);
800 GNUNET_memcpy (gst->join_dcsn,
801 dcsn,
802 dcsn->header.size);
803 if (GNUNET_NO == is_admitted)
804 {
805 GNUNET_PSYC_slave_part (gst->slave,
806 GNUNET_NO,
807 &slave_parted_after_join_decision,
808 gst);
809 gst->slave = NULL;
810 return;
811 }
812 place_send_msg (&gst->place, GNUNET_MQ_msg_copy (&gst->join_dcsn->header));
781} 813}
782 814
783 815
@@ -1102,9 +1134,6 @@ place_init (struct Place *plc)
1102static int 1134static int
1103place_add (const struct PlaceEnterRequest *ereq) 1135place_add (const struct PlaceEnterRequest *ereq)
1104{ 1136{
1105 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1106 "Adding place to hashmap:\n");
1107
1108 struct EgoPlacePublicKey ego_place_pub_key = { 1137 struct EgoPlacePublicKey ego_place_pub_key = {
1109 .ego_pub_key = ereq->ego_pub_key, 1138 .ego_pub_key = ereq->ego_pub_key,
1110 .place_pub_key = ereq->place_pub_key, 1139 .place_pub_key = ereq->place_pub_key,
@@ -1717,6 +1746,8 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1717 return GNUNET_SYSERR; 1746 return GNUNET_SYSERR;
1718 } 1747 }
1719 1748
1749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1750 "entering as guest\n");
1720 struct GNUNET_HashCode place_pub_hash; 1751 struct GNUNET_HashCode place_pub_hash;
1721 GNUNET_CRYPTO_hash (&greq->place_pub_key, sizeof (greq->place_pub_key), 1752 GNUNET_CRYPTO_hash (&greq->place_pub_key, sizeof (greq->place_pub_key),
1722 &place_pub_hash); 1753 &place_pub_hash);
@@ -1728,9 +1759,16 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1728 if (NULL != plc_gst) 1759 if (NULL != plc_gst)
1729 gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash); 1760 gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash);
1730 1761
1731 if (NULL == gst || NULL == gst->slave) 1762 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1763 "plc_gst = %p, gst = %p\n",
1764 plc_gst,
1765 gst);
1766 if (NULL == gst)
1732 { 1767 {
1733 gst = GNUNET_new (struct Guest); 1768 gst = GNUNET_new (struct Guest);
1769 }
1770 if (NULL == gst->slave)
1771 {
1734 gst->origin = greq->origin; 1772 gst->origin = greq->origin;
1735 gst->relay_count = ntohl (greq->relay_count); 1773 gst->relay_count = ntohl (greq->relay_count);
1736 1774
@@ -1803,11 +1841,12 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1803 plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); 1841 plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES);
1804 (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, 1842 (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst,
1805 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1843 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1806 } 1844 (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst,
1807 (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, 1845 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1808 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1846 (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst,
1809 (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst,
1810 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 1847 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
1848
1849 }
1811 gst->slave 1850 gst->slave
1812 = GNUNET_PSYC_slave_join (cfg, &plc->pub_key, &plc->ego_key, 1851 = GNUNET_PSYC_slave_join (cfg, &plc->pub_key, &plc->ego_key,
1813 gst->join_flags, &gst->origin, 1852 gst->join_flags, &gst->origin,
@@ -1817,6 +1856,9 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1817 &psyc_recv_join_dcsn, 1856 &psyc_recv_join_dcsn,
1818 gst, join_msg); 1857 gst, join_msg);
1819 plc->channel = GNUNET_PSYC_slave_get_channel (gst->slave); 1858 plc->channel = GNUNET_PSYC_slave_get_channel (gst->slave);
1859 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1860 "slave entered channel %p\n",
1861 plc->channel);
1820 ret = GNUNET_YES; 1862 ret = GNUNET_YES;
1821 } 1863 }
1822 1864
@@ -1830,6 +1872,8 @@ static int
1830client_guest_enter (struct Client *c, 1872client_guest_enter (struct Client *c,
1831 const struct GuestEnterRequest *greq) 1873 const struct GuestEnterRequest *greq)
1832{ 1874{
1875 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1876 "client_guest_enter\n");
1833 struct GNUNET_PSYC_CountersResultMessage *result_msg; 1877 struct GNUNET_PSYC_CountersResultMessage *result_msg;
1834 struct GNUNET_MQ_Envelope *env; 1878 struct GNUNET_MQ_Envelope *env;
1835 struct GNUNET_SERVICE_Client *client = c->client; 1879 struct GNUNET_SERVICE_Client *client = c->client;
@@ -1847,15 +1891,22 @@ client_guest_enter (struct Client *c,
1847 switch (guest_enter (greq, &gst)) 1891 switch (guest_enter (greq, &gst))
1848 { 1892 {
1849 case GNUNET_YES: 1893 case GNUNET_YES:
1894 {
1850 plc = c->place = &gst->place; 1895 plc = c->place = &gst->place;
1896 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1897 "guest entered successfully to local place %s\n",
1898 GNUNET_h2s (&plc->pub_key_hash));
1851 plc->guest = gst; 1899 plc->guest = gst;
1852 app_place_save (app_id, (const struct PlaceEnterRequest *) greq); 1900 app_place_save (app_id, (const struct PlaceEnterRequest *) greq);
1853 app_notify_place (&greq->header, client); 1901 app_notify_place (&greq->header, client);
1854 break; 1902 break;
1855 1903 }
1856 case GNUNET_NO: 1904 case GNUNET_NO:
1857 { 1905 {
1858 plc = c->place = &gst->place; 1906 plc = c->place = &gst->place;
1907 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1908 "guest re-entered successfully to local place %s\n",
1909 GNUNET_h2s (&plc->pub_key_hash));
1859 plc->guest = gst; 1910 plc->guest = gst;
1860 env = GNUNET_MQ_msg (result_msg, 1911 env = GNUNET_MQ_msg (result_msg,
1861 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); 1912 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK);
@@ -1872,12 +1923,10 @@ client_guest_enter (struct Client *c,
1872 break; 1923 break;
1873 } 1924 }
1874 case GNUNET_SYSERR: 1925 case GNUNET_SYSERR:
1926 {
1875 return GNUNET_SYSERR; 1927 return GNUNET_SYSERR;
1876 } 1928 }
1877 1929 }
1878 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1879 "%p Client connected as guest to place %s.\n",
1880 gst, GNUNET_h2s (&plc->pub_key_hash));
1881 1930
1882 struct ClientListItem *cli = GNUNET_new (struct ClientListItem); 1931 struct ClientListItem *cli = GNUNET_new (struct ClientListItem);
1883 cli->client = client; 1932 cli->client = client;
@@ -2147,6 +2196,18 @@ handle_client_app_detach (void *cls,
2147} 2196}
2148 2197
2149 2198
2199static void
2200place_leave_cb (void *cls)
2201{
2202 struct Place *plc = cls;
2203
2204 place_send_leave_ack (plc);
2205 (GNUNET_YES == plc->is_host)
2206 ? cleanup_host ((struct Host *) plc)
2207 : cleanup_guest ((struct Guest *) plc);
2208}
2209
2210
2150/** 2211/**
2151 * Handle application leave request. 2212 * Handle application leave request.
2152 */ 2213 */
@@ -2158,6 +2219,10 @@ handle_client_place_leave (void *cls,
2158 struct GNUNET_SERVICE_Client *client = c->client; 2219 struct GNUNET_SERVICE_Client *client = c->client;
2159 struct Place *plc = c->place; 2220 struct Place *plc = c->place;
2160 2221
2222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2223 "got leave request from %s for place %s",
2224 plc->is_host? "host" : "slave",
2225 GNUNET_h2s (&plc->pub_key_hash));
2161 if (NULL == plc) 2226 if (NULL == plc)
2162 { 2227 {
2163 GNUNET_break (0); 2228 GNUNET_break (0);
@@ -2165,26 +2230,27 @@ handle_client_place_leave (void *cls,
2165 return; 2230 return;
2166 } 2231 }
2167 2232
2168 if (GNUNET_YES != plc->is_disconnected) 2233 if (GNUNET_YES != plc->is_disconnecting)
2169 { 2234 {
2170 plc->is_disconnected = GNUNET_YES; 2235 plc->is_disconnecting = GNUNET_YES;
2171 if (NULL != plc->tmit_msgs_head) 2236 if (plc->is_host)
2172 { /* Send pending messages to PSYC before cleanup. */ 2237 {
2173 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2238 struct Host *host = plc->host;
2174 "not cleaning up place of client %p\n", 2239 GNUNET_assert (NULL != host);
2175 client); 2240 GNUNET_PSYC_master_stop (host->master, GNUNET_NO, &place_leave_cb, plc);
2176 psyc_transmit_message (plc);
2177 } 2241 }
2178 else 2242 else
2179 { 2243 {
2180 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2244 struct Guest *guest = plc->guest;
2181 "cleaning up place of client %p\n", 2245 GNUNET_assert (NULL != guest);
2182 client); 2246 GNUNET_PSYC_slave_part (guest->slave, GNUNET_NO, &place_leave_cb, plc);
2183 place_send_leave_ack (plc);
2184 cleanup_place (plc);
2185 c->place = NULL;
2186 } 2247 }
2187 } 2248 }
2249 else
2250 {
2251 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2252 "got leave request but place is already leaving\n");
2253 }
2188 GNUNET_SERVICE_client_continue (client); 2254 GNUNET_SERVICE_client_continue (client);
2189} 2255}
2190 2256
@@ -2244,6 +2310,9 @@ handle_client_join_decision (void *cls,
2244 ? (struct GNUNET_PSYC_Message *) &dcsn[1] 2310 ? (struct GNUNET_PSYC_Message *) &dcsn[1]
2245 : NULL; 2311 : NULL;
2246 2312
2313 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2314 "jcls.msg = %p\n",
2315 jcls.msg);
2247 struct GNUNET_HashCode slave_pub_hash; 2316 struct GNUNET_HashCode slave_pub_hash;
2248 GNUNET_CRYPTO_hash (&dcsn->slave_pub_key, sizeof (dcsn->slave_pub_key), 2317 GNUNET_CRYPTO_hash (&dcsn->slave_pub_key, sizeof (dcsn->slave_pub_key),
2249 &slave_pub_hash); 2318 &slave_pub_hash);
@@ -2276,10 +2345,6 @@ send_message_ack (struct Place *plc, struct GNUNET_SERVICE_Client *client)
2276 struct GNUNET_MQ_Envelope *env; 2345 struct GNUNET_MQ_Envelope *env;
2277 2346
2278 env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK); 2347 env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK);
2279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2280 "sending psyc message ack to client %p, mq = %p\n",
2281 client,
2282 GNUNET_SERVICE_client_get_mq (client));
2283 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 2348 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
2284 env); 2349 env);
2285} 2350}
@@ -2413,7 +2478,6 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data)
2413 { 2478 {
2414 *data_size = 0; 2479 *data_size = 0;
2415 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); 2480 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg);
2416 plc->is_disconnected = GNUNET_YES;
2417 GNUNET_SERVICE_client_drop (tmit_frag->client); 2481 GNUNET_SERVICE_client_drop (tmit_frag->client);
2418 GNUNET_SCHEDULER_add_now (&cleanup_place, plc); 2482 GNUNET_SCHEDULER_add_now (&cleanup_place, plc);
2419 return ret; 2483 return ret;
@@ -2455,11 +2519,7 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data)
2455 { 2519 {
2456 psyc_transmit_message (plc); 2520 psyc_transmit_message (plc);
2457 } 2521 }
2458 else if (GNUNET_YES == plc->is_disconnected) 2522 /* FIXME: handle partial message (when still in_transmit) */
2459 {
2460 /* FIXME: handle partial message (when still in_transmit) */
2461 cleanup_place (plc);
2462 }
2463 } 2523 }
2464 return ret; 2524 return ret;
2465} 2525}
@@ -2573,7 +2633,6 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data,
2573 *data_size = 0; 2633 *data_size = 0;
2574 ret = GNUNET_SYSERR; 2634 ret = GNUNET_SYSERR;
2575 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); 2635 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg);
2576 plc->is_disconnected = GNUNET_YES;
2577 GNUNET_SERVICE_client_drop (tmit_frag->client); 2636 GNUNET_SERVICE_client_drop (tmit_frag->client);
2578 GNUNET_SCHEDULER_add_now (&cleanup_place, plc); 2637 GNUNET_SCHEDULER_add_now (&cleanup_place, plc);
2579 } 2638 }
@@ -2890,7 +2949,7 @@ handle_client_psyc_message (void *cls,
2890 return; 2949 return;
2891 } 2950 }
2892 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2951 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2893 "%p Received message from client.\n", plc); 2952 "%p Received message of type %d from client.\n", plc, ntohs (msg->type));
2894 GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg); 2953 GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg);
2895 2954
2896 if (GNUNET_YES != plc->is_ready) 2955 if (GNUNET_YES != plc->is_ready)
diff --git a/src/social/social_api.c b/src/social/social_api.c
index db2a59674..4e305b867 100644
--- a/src/social/social_api.c
+++ b/src/social/social_api.c
@@ -1516,7 +1516,8 @@ GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *hst,
1516 enum GNUNET_SOCIAL_AnnounceFlags flags) 1516 enum GNUNET_SOCIAL_AnnounceFlags flags)
1517{ 1517{
1518 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1518 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1519 "PSYC_transmit_message for host\n"); 1519 "PSYC_transmit_message for host, method: %s\n",
1520 method_name);
1520 if (GNUNET_OK == 1521 if (GNUNET_OK ==
1521 GNUNET_PSYC_transmit_message (hst->plc.tmit, method_name, env, 1522 GNUNET_PSYC_transmit_message (hst->plc.tmit, method_name, env,
1522 NULL, notify_data, notify_data_cls, flags)) 1523 NULL, notify_data, notify_data_cls, flags))
@@ -1614,8 +1615,6 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst,
1614{ 1615{
1615 struct GNUNET_MQ_Envelope *envelope; 1616 struct GNUNET_MQ_Envelope *envelope;
1616 1617
1617 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1618 "sending _notice_place_closing\n");
1619 GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, 1618 GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL,
1620 GNUNET_SOCIAL_ANNOUNCE_NONE); 1619 GNUNET_SOCIAL_ANNOUNCE_NONE);
1621 hst->plc.disconnect_cb = disconnect_cb; 1620 hst->plc.disconnect_cb = disconnect_cb;
@@ -1912,6 +1911,64 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
1912} 1911}
1913 1912
1914 1913
1914struct ReconnectContext
1915{
1916 struct GNUNET_SOCIAL_Guest *guest;
1917 int *result;
1918 int64_t *max_message_id;
1919 GNUNET_SOCIAL_GuestEnterCallback enter_cb;
1920 void *enter_cls;
1921};
1922
1923
1924//static void
1925//guest_enter_reconnect_cb (void *cls,
1926// int result,
1927// const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
1928// uint64_t max_message_id)
1929//{
1930// struct ReconnectContext *reconnect_ctx = cls;
1931//
1932// GNUNET_assert (NULL != reconnect_ctx);
1933// reconnect_ctx->result = GNUNET_new (int);
1934// *(reconnect_ctx->result) = result;
1935// reconnect_ctx->max_message_id = GNUNET_new (int64_t);
1936// *(reconnect_ctx->max_message_id) = max_message_id;
1937//}
1938//
1939//
1940//static void
1941//guest_entry_dcsn_reconnect_cb (void *cls,
1942// int is_admitted,
1943// const struct GNUNET_PSYC_Message *entry_resp)
1944//{
1945// struct ReconnectContext *reconnect_ctx = cls;
1946// struct GNUNET_SOCIAL_Guest *gst = reconnect_ctx->guest;
1947//
1948// GNUNET_assert (NULL != reconnect_ctx);
1949// GNUNET_assert (NULL != reconnect_ctx->result);
1950// GNUNET_assert (NULL != reconnect_ctx->max_message_id);
1951// if (GNUNET_YES != is_admitted)
1952// {
1953// GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1954// "Guest was rejected after calling "
1955// "GNUNET_SOCIAL_guest_enter_reconnect ()\n");
1956// }
1957// else if (NULL != reconnect_ctx->enter_cb)
1958// {
1959// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1960// "guest reconnected!\n");
1961// reconnect_ctx->enter_cb (reconnect_ctx->enter_cls,
1962// *(reconnect_ctx->result),
1963// &gst->plc.pub_key,
1964// *(reconnect_ctx->max_message_id));
1965// }
1966// GNUNET_free (reconnect_ctx->result);
1967// GNUNET_free (reconnect_ctx->max_message_id);
1968// GNUNET_free (reconnect_ctx);
1969//}
1970
1971
1915/** 1972/**
1916 * Reconnect to an already entered place as guest. 1973 * Reconnect to an already entered place as guest.
1917 * 1974 *
@@ -1957,7 +2014,6 @@ GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn
1957 plc->ego_pub_key = gconn->plc_msg.ego_pub_key; 2014 plc->ego_pub_key = gconn->plc_msg.ego_pub_key;
1958 2015
1959 plc->op = GNUNET_OP_create (); 2016 plc->op = GNUNET_OP_create ();
1960
1961 gst->enter_cb = local_enter_cb; 2017 gst->enter_cb = local_enter_cb;
1962 gst->cb_cls = cls; 2018 gst->cb_cls = cls;
1963 2019
@@ -1993,9 +2049,6 @@ GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *gst,
1993 void *notify_data_cls, 2049 void *notify_data_cls,
1994 enum GNUNET_SOCIAL_TalkFlags flags) 2050 enum GNUNET_SOCIAL_TalkFlags flags)
1995{ 2051{
1996 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1997 "PSYC_transmit_message for guest\n");
1998
1999 struct GNUNET_SOCIAL_Place *plc = &gst->plc; 2052 struct GNUNET_SOCIAL_Place *plc = &gst->plc;
2000 GNUNET_assert (NULL != plc->tmit); 2053 GNUNET_assert (NULL != plc->tmit);
2001 2054