aboutsummaryrefslogtreecommitdiff
path: root/src/social
diff options
context:
space:
mode:
authorlurchi <lurchi@strangeplace.net>2017-12-30 20:46:59 +0100
committerlurchi <lurchi@strangeplace.net>2017-12-30 20:46:59 +0100
commit5c8feda7faa01365a1fb6983595ceb65dfe4fb11 (patch)
tree3521d1131a2f3d063455a58c86c42af3c7551077 /src/social
parentd01f1bd83384cbdb74fa963526d31270bf58c805 (diff)
parent8412625bb5191040389610364167c768bb55efb4 (diff)
downloadgnunet-5c8feda7faa01365a1fb6983595ceb65dfe4fb11.tar.gz
gnunet-5c8feda7faa01365a1fb6983595ceb65dfe4fb11.zip
Merge branch 'fix_social'
Diffstat (limited to 'src/social')
-rw-r--r--src/social/gnunet-service-social.c774
-rw-r--r--src/social/gnunet-social.c26
-rw-r--r--src/social/social_api.c292
-rw-r--r--src/social/test_social.c268
-rw-r--r--src/social/test_social.conf19
5 files changed, 781 insertions, 598 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c
index dee68fdb8..5b2a8ba9b 100644
--- a/src/social/gnunet-service-social.c
+++ b/src/social/gnunet-service-social.c
@@ -96,7 +96,7 @@ static struct GNUNET_CONTAINER_MultiHashMap *apps_places;
96 * Application subscriptions per place. 96 * Application subscriptions per place.
97 * H(place_pub_key) -> H(app_id) 97 * H(place_pub_key) -> H(app_id)
98 */ 98 */
99static struct GNUNET_CONTAINER_MultiHashMap *places_apps; 99//static struct GNUNET_CONTAINER_MultiHashMap *places_apps;
100 100
101/** 101/**
102 * Connected applications. 102 * Connected applications.
@@ -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
@@ -537,8 +533,8 @@ cleanup_place (void *cls)
537 struct Place *plc = cls; 533 struct Place *plc = cls;
538 534
539 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 535 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
540 "%p Cleaning up place %s\n", 536 "cleaning up place %s\n",
541 plc, GNUNET_h2s (&plc->pub_key_hash)); 537 GNUNET_h2s (&plc->pub_key_hash));
542 538
543 (GNUNET_YES == plc->is_host) 539 (GNUNET_YES == plc->is_host)
544 ? cleanup_host ((struct Host *) plc) 540 ? cleanup_host ((struct Host *) plc)
@@ -583,12 +579,19 @@ client_notify_disconnect (void *cls,
583 { 579 {
584 if (cli->client == client) 580 if (cli->client == client)
585 { 581 {
586 GNUNET_CONTAINER_DLL_remove (plc->clients_head, plc->clients_tail, cli); 582 GNUNET_CONTAINER_DLL_remove (plc->clients_head,
583 plc->clients_tail,
584 cli);
587 GNUNET_free (cli); 585 GNUNET_free (cli);
588 break; 586 break;
589 } 587 }
590 cli = cli->next; 588 cli = cli->next;
591 } 589 }
590 if (GNUNET_YES == plc->is_disconnecting)
591 {
592 GNUNET_PSYC_slicer_destroy (plc->slicer);
593 GNUNET_free (plc);
594 }
592} 595}
593 596
594 597
@@ -605,46 +608,55 @@ client_notify_connect (void *cls,
605 struct GNUNET_SERVICE_Client *client, 608 struct GNUNET_SERVICE_Client *client,
606 struct GNUNET_MQ_Handle *mq) 609 struct GNUNET_MQ_Handle *mq)
607{ 610{
608 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client connected: %p\n", client); 611 struct Client *c = GNUNET_new (struct Client);
609 612
610 struct Client *c = GNUNET_malloc (sizeof (*c)); 613 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
614 "Client %p connected with queue %p\n",
615 client,
616 mq);
611 c->client = client; 617 c->client = client;
612
613 return c; 618 return c;
614} 619}
615 620
616 621
617/** 622/**
618 * Send message to a client. 623 * Send message to all clients connected to a place and
619 */ 624 * takes care of freeing @env.
620static inline void
621client_send_msg (struct GNUNET_SERVICE_Client *client,
622 const struct GNUNET_MessageHeader *msg)
623{
624 struct GNUNET_MQ_Envelope *
625 env = GNUNET_MQ_msg_copy (msg);
626
627 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
628 env);
629}
630
631
632/**
633 * Send message to all clients connected to a place.
634 */ 625 */
635static void 626static void
636place_send_msg (const struct Place *plc, 627place_send_msg (const struct Place *plc,
637 const struct GNUNET_MessageHeader *msg) 628 struct GNUNET_MQ_Envelope *env)
638{ 629{
630 struct ClientListItem *cli = plc->clients_head;
631
639 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 632 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
640 "%p Sending message to clients of place.\n", plc); 633 "%p Sending message to clients of place.\n", plc);
641
642 struct ClientListItem *cli = plc->clients_head;
643 while (NULL != cli) 634 while (NULL != cli)
644 { 635 {
645 client_send_msg (cli->client, msg); 636 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
637 "Sending message to client %p\n",
638 cli);
639 GNUNET_MQ_send_copy (GNUNET_SERVICE_client_get_mq (cli->client),
640 env);
646 cli = cli->next; 641 cli = cli->next;
647 } 642 }
643 GNUNET_MQ_discard (env);
644}
645
646
647static void
648place_send_leave_ack (struct Place *plc)
649{
650 struct GNUNET_MQ_Envelope *env;
651
652 for (struct ClientListItem *cli = plc->clients_head;
653 NULL != cli;
654 cli = cli->next)
655 {
656 env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK);
657 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cli->client),
658 env);
659 }
648} 660}
649 661
650 662
@@ -666,23 +678,21 @@ static void
666client_send_result (struct GNUNET_SERVICE_Client *client, uint64_t op_id, 678client_send_result (struct GNUNET_SERVICE_Client *client, uint64_t op_id,
667 int64_t result_code, const void *data, uint16_t data_size) 679 int64_t result_code, const void *data, uint16_t data_size)
668{ 680{
681 struct GNUNET_MQ_Envelope *env;
669 struct GNUNET_OperationResultMessage *res; 682 struct GNUNET_OperationResultMessage *res;
670 683
671 res = GNUNET_malloc (sizeof (*res) + data_size); 684 env = GNUNET_MQ_msg_extra (res,
672 res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE); 685 data_size,
673 res->header.size = htons (sizeof (*res) + data_size); 686 GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE);
674 res->result_code = GNUNET_htonll (result_code); 687 res->result_code = GNUNET_htonll (result_code);
675 res->op_id = op_id; 688 res->op_id = op_id;
676 if (0 < data_size) 689 if (0 < data_size)
677 GNUNET_memcpy (&res[1], data, data_size); 690 GNUNET_memcpy (&res[1], data, data_size);
678
679 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 691 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
680 "%p Sending result to client for operation #%" PRIu64 ": " 692 "%p Sending result to client for operation #%" PRIu64 ": "
681 "%" PRId64 " (size: %u)\n", 693 "%" PRId64 " (size: %u)\n",
682 client, GNUNET_ntohll (op_id), result_code, data_size); 694 client, GNUNET_ntohll (op_id), result_code, data_size);
683 695 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
684 client_send_msg (client, &res->header);
685 GNUNET_free (res);
686} 696}
687 697
688 698
@@ -690,19 +700,21 @@ static void
690client_send_host_enter_ack (struct GNUNET_SERVICE_Client *client, 700client_send_host_enter_ack (struct GNUNET_SERVICE_Client *client,
691 struct Host *hst, uint32_t result) 701 struct Host *hst, uint32_t result)
692{ 702{
703 struct GNUNET_MQ_Envelope *env;
704 struct HostEnterAck *hack;
693 struct Place *plc = &hst->place; 705 struct Place *plc = &hst->place;
694 706
695 struct HostEnterAck hack; 707 env = GNUNET_MQ_msg (hack,
696 hack.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); 708 GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK);
697 hack.header.size = htons (sizeof (hack)); 709 hack->result_code = htonl (result);
698 hack.result_code = htonl (result); 710 hack->max_message_id = GNUNET_htonll (plc->max_message_id);
699 hack.max_message_id = GNUNET_htonll (plc->max_message_id); 711 hack->place_pub_key = plc->pub_key;
700 hack.place_pub_key = plc->pub_key;
701 712
702 if (NULL != client) 713 if (NULL != client)
703 client_send_msg (client, &hack.header); 714 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
715 env);
704 else 716 else
705 place_send_msg (plc, &hack.header); 717 place_send_msg (plc, env);
706} 718}
707 719
708 720
@@ -736,7 +748,8 @@ psyc_recv_join_request (void *cls,
736 GNUNET_CRYPTO_hash (slave_key, sizeof (*slave_key), &slave_key_hash); 748 GNUNET_CRYPTO_hash (slave_key, sizeof (*slave_key), &slave_key_hash);
737 GNUNET_CONTAINER_multihashmap_put (hst->join_reqs, &slave_key_hash, jh, 749 GNUNET_CONTAINER_multihashmap_put (hst->join_reqs, &slave_key_hash, jh,
738 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 750 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
739 place_send_msg (&hst->place, &req->header); 751 place_send_msg (&hst->place,
752 GNUNET_MQ_msg_copy (&req->header));
740} 753}
741 754
742 755
@@ -746,18 +759,29 @@ psyc_recv_join_request (void *cls,
746static void 759static void
747psyc_slave_connected (void *cls, int result, uint64_t max_message_id) 760psyc_slave_connected (void *cls, int result, uint64_t max_message_id)
748{ 761{
762 struct GNUNET_PSYC_CountersResultMessage *res;
763 struct GNUNET_MQ_Envelope *env;
749 struct Guest *gst = cls; 764 struct Guest *gst = cls;
750 struct Place *plc = &gst->place; 765 struct Place *plc = &gst->place;
766
751 plc->max_message_id = max_message_id; 767 plc->max_message_id = max_message_id;
752 plc->is_ready = GNUNET_YES; 768 plc->is_ready = GNUNET_YES;
769 env = GNUNET_MQ_msg (res,
770 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK);
771 res->result_code =
772 (result != GNUNET_SYSERR) ? htonl (GNUNET_OK) : htonl (GNUNET_SYSERR);
773 res->max_message_id = GNUNET_htonll (plc->max_message_id);
774 place_send_msg (plc, env);
775}
753 776
754 struct GNUNET_PSYC_CountersResultMessage res;
755 res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK);
756 res.header.size = htons (sizeof (res));
757 res.result_code = htonl (result);
758 res.max_message_id = GNUNET_htonll (plc->max_message_id);
759 777
760 place_send_msg (plc, &res.header); 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));
761} 785}
762 786
763 787
@@ -771,7 +795,21 @@ psyc_recv_join_dcsn (void *cls,
771 const struct GNUNET_PSYC_Message *join_msg) 795 const struct GNUNET_PSYC_Message *join_msg)
772{ 796{
773 struct Guest *gst = cls; 797 struct Guest *gst = cls;
774 place_send_msg (&gst->place, &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));
775} 813}
776 814
777 815
@@ -792,7 +830,7 @@ psyc_recv_message (void *cls,
792 830
793 GNUNET_PSYC_slicer_message (plc->slicer, msg); 831 GNUNET_PSYC_slicer_message (plc->slicer, msg);
794 832
795 place_send_msg (plc, &msg->header); 833 place_send_msg (plc, GNUNET_MQ_msg_copy (&msg->header));
796} 834}
797 835
798 836
@@ -1096,9 +1134,6 @@ place_init (struct Place *plc)
1096static int 1134static int
1097place_add (const struct PlaceEnterRequest *ereq) 1135place_add (const struct PlaceEnterRequest *ereq)
1098{ 1136{
1099 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1100 "Adding place to hashmap:\n");
1101
1102 struct EgoPlacePublicKey ego_place_pub_key = { 1137 struct EgoPlacePublicKey ego_place_pub_key = {
1103 .ego_pub_key = ereq->ego_pub_key, 1138 .ego_pub_key = ereq->ego_pub_key,
1104 .place_pub_key = ereq->place_pub_key, 1139 .place_pub_key = ereq->place_pub_key,
@@ -1173,7 +1208,9 @@ app_place_add (const char *app_id,
1173 return GNUNET_NO; 1208 return GNUNET_NO;
1174 1209
1175 if (GNUNET_SYSERR == place_add (ereq)) 1210 if (GNUNET_SYSERR == place_add (ereq))
1211 {
1176 return GNUNET_SYSERR; 1212 return GNUNET_SYSERR;
1213 }
1177 1214
1178 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (app_places, &ego_place_pub_hash, NULL, 1215 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (app_places, &ego_place_pub_hash, NULL,
1179 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) 1216 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
@@ -1181,32 +1218,6 @@ app_place_add (const char *app_id,
1181 GNUNET_break (0); 1218 GNUNET_break (0);
1182 return GNUNET_SYSERR; 1219 return GNUNET_SYSERR;
1183 } 1220 }
1184
1185 struct GNUNET_HashCode place_pub_hash;
1186 GNUNET_CRYPTO_hash (&ereq->place_pub_key, sizeof (ereq->place_pub_key), &place_pub_hash);
1187
1188 struct GNUNET_CONTAINER_MultiHashMap *
1189 place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash);
1190 if (NULL == place_apps)
1191 {
1192 place_apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
1193 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (places_apps, &place_pub_hash, place_apps,
1194 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
1195 {
1196 GNUNET_break (0);
1197 }
1198 }
1199
1200 size_t app_id_size = strlen (app_id) + 1;
1201 void *app_id_value = GNUNET_malloc (app_id_size);
1202 GNUNET_memcpy (app_id_value, app_id, app_id_size);
1203
1204 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (place_apps, &app_id_hash, app_id_value,
1205 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
1206 {
1207 GNUNET_break (0);
1208 }
1209
1210 return GNUNET_OK; 1221 return GNUNET_OK;
1211} 1222}
1212 1223
@@ -1223,7 +1234,10 @@ static int
1223app_place_save (const char *app_id, 1234app_place_save (const char *app_id,
1224 const struct PlaceEnterRequest *ereq) 1235 const struct PlaceEnterRequest *ereq)
1225{ 1236{
1226 app_place_add (app_id, ereq); 1237 if (GNUNET_SYSERR == app_place_add (app_id, ereq))
1238 {
1239 GNUNET_assert (0);
1240 }
1227 1241
1228 if (NULL == dir_places) 1242 if (NULL == dir_places)
1229 return GNUNET_SYSERR; 1243 return GNUNET_SYSERR;
@@ -1304,18 +1318,6 @@ app_place_remove (const char *app_id,
1304 if (NULL != app_places) 1318 if (NULL != app_places)
1305 GNUNET_CONTAINER_multihashmap_remove (app_places, &place_pub_hash, NULL); 1319 GNUNET_CONTAINER_multihashmap_remove (app_places, &place_pub_hash, NULL);
1306 1320
1307 struct GNUNET_CONTAINER_MultiHashMap *
1308 place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash);
1309 if (NULL != place_apps)
1310 {
1311 void *app_id_value = GNUNET_CONTAINER_multihashmap_get (place_apps, &app_id_hash);
1312 if (NULL != app_id_value)
1313 {
1314 GNUNET_CONTAINER_multihashmap_remove (place_apps, &app_id_hash, app_id_value);
1315 GNUNET_free (app_id_value);
1316 }
1317 }
1318
1319 int ret = GNUNET_OK; 1321 int ret = GNUNET_OK;
1320 1322
1321 if (0 != unlink (app_place_filename)) 1323 if (0 != unlink (app_place_filename))
@@ -1407,6 +1409,124 @@ msg_proc_parse (const struct MsgProcRequest *mpreq,
1407} 1409}
1408 1410
1409 1411
1412void
1413app_notify_place (const struct GNUNET_MessageHeader *msg,
1414 struct GNUNET_SERVICE_Client *client)
1415{
1416 struct AppPlaceMessage *amsg;
1417 struct GNUNET_MQ_Envelope *env;
1418 uint16_t msg_size = ntohs (msg->size);
1419
1420 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1421 "%p Sending place notification of type %u to client.\n",
1422 client, ntohs (msg->type));
1423 switch (ntohs (msg->type))
1424 {
1425 case GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER:
1426 {
1427 struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg;
1428 if (msg_size < sizeof (struct HostEnterRequest))
1429 return;
1430 env = GNUNET_MQ_msg (amsg,
1431 GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE);
1432 // FIXME: also notify about not entered places
1433 amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED;
1434 amsg->is_host = GNUNET_YES;
1435 amsg->ego_pub_key = hreq->ego_pub_key;
1436 amsg->place_pub_key = hreq->place_pub_key;
1437 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1438 env);
1439 break;
1440 }
1441 case GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER:
1442 {
1443 if (msg_size < sizeof (struct GuestEnterRequest))
1444 return;
1445 struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg;
1446 env = GNUNET_MQ_msg (amsg,
1447 GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE);
1448 // FIXME: also notify about not entered places
1449 amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED;
1450 amsg->is_host = GNUNET_NO;
1451 amsg->ego_pub_key = greq->ego_pub_key;
1452 amsg->place_pub_key = greq->place_pub_key;
1453 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1454 env);
1455 break;
1456 }
1457 default:
1458 return;
1459 }
1460}
1461
1462
1463void
1464app_notify_place_end (struct GNUNET_SERVICE_Client *client)
1465{
1466 struct GNUNET_MQ_Envelope *env;
1467
1468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1469 "%p Sending end of place list notification to client\n",
1470 client);
1471 env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END);
1472 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1473 env);
1474}
1475
1476
1477void
1478app_notify_ego (struct Ego *ego, struct GNUNET_SERVICE_Client *client)
1479{
1480 struct AppEgoMessage *emsg;
1481 struct GNUNET_MQ_Envelope *env;
1482 size_t name_size = strlen (ego->name) + 1;
1483
1484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1485 "%p Sending ego notification to client: %s\n",
1486 client, ego->name);
1487 env = GNUNET_MQ_msg_extra (emsg,
1488 name_size,
1489 GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO);
1490 GNUNET_CRYPTO_ecdsa_key_get_public (&ego->key, &emsg->ego_pub_key);
1491 GNUNET_memcpy (&emsg[1], ego->name, name_size);
1492 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1493 env);
1494}
1495
1496
1497void
1498app_notify_ego_end (struct GNUNET_SERVICE_Client *client)
1499{
1500 struct GNUNET_MQ_Envelope *env;
1501
1502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1503 "%p Sending end of ego list notification to client\n",
1504 client);
1505 env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END);
1506 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1507 env);
1508}
1509
1510
1511int
1512app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value)
1513{
1514 struct GNUNET_MessageHeader *
1515 msg = GNUNET_CONTAINER_multihashmap_get (places, key);
1516 if (NULL != msg)
1517 app_notify_place (msg, cls);
1518 return GNUNET_YES;
1519}
1520
1521
1522int
1523ego_entry (void *cls, const struct GNUNET_HashCode *key, void *value)
1524{
1525 app_notify_ego (value, cls);
1526 return GNUNET_YES;
1527}
1528
1529
1410static int 1530static int
1411check_client_msg_proc_set (void *cls, 1531check_client_msg_proc_set (void *cls,
1412 const struct MsgProcRequest *mpreq) 1532 const struct MsgProcRequest *mpreq)
@@ -1518,9 +1638,8 @@ static void
1518handle_client_host_enter (void *cls, 1638handle_client_host_enter (void *cls,
1519 const struct HostEnterRequest *hr) 1639 const struct HostEnterRequest *hr)
1520{ 1640{
1521 struct Client *c = cls; 1641 struct Client *c = cls;
1522 struct GNUNET_SERVICE_Client *client = c->client; 1642 struct GNUNET_SERVICE_Client *client = c->client;
1523
1524 struct HostEnterRequest * 1643 struct HostEnterRequest *
1525 hreq = (struct HostEnterRequest *) GNUNET_copy_message (&hr->header); 1644 hreq = (struct HostEnterRequest *) GNUNET_copy_message (&hr->header);
1526 1645
@@ -1578,7 +1697,7 @@ handle_client_host_enter (void *cls,
1578 if (ret != GNUNET_SYSERR) 1697 if (ret != GNUNET_SYSERR)
1579 { 1698 {
1580 1699
1581 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1700 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1582 "%p Client connected as host to place %s.\n", 1701 "%p Client connected as host to place %s.\n",
1583 hst, GNUNET_h2s (&plc->pub_key_hash)); 1702 hst, GNUNET_h2s (&plc->pub_key_hash));
1584 1703
@@ -1586,6 +1705,7 @@ handle_client_host_enter (void *cls,
1586 cli->client = client; 1705 cli->client = client;
1587 GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli); 1706 GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli);
1588 c->place = plc; 1707 c->place = plc;
1708 app_notify_place (&hreq->header, client);
1589 } 1709 }
1590 1710
1591 GNUNET_CRYPTO_eddsa_key_clear (&hreq->place_key); 1711 GNUNET_CRYPTO_eddsa_key_clear (&hreq->place_key);
@@ -1622,8 +1742,12 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1622 struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash); 1742 struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash);
1623 1743
1624 if (NULL == ego) 1744 if (NULL == ego)
1745 {
1625 return GNUNET_SYSERR; 1746 return GNUNET_SYSERR;
1747 }
1626 1748
1749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1750 "entering as guest\n");
1627 struct GNUNET_HashCode place_pub_hash; 1751 struct GNUNET_HashCode place_pub_hash;
1628 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),
1629 &place_pub_hash); 1753 &place_pub_hash);
@@ -1635,9 +1759,16 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1635 if (NULL != plc_gst) 1759 if (NULL != plc_gst)
1636 gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash); 1760 gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash);
1637 1761
1638 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)
1639 { 1767 {
1640 gst = GNUNET_new (struct Guest); 1768 gst = GNUNET_new (struct Guest);
1769 }
1770 if (NULL == gst->slave)
1771 {
1641 gst->origin = greq->origin; 1772 gst->origin = greq->origin;
1642 gst->relay_count = ntohl (greq->relay_count); 1773 gst->relay_count = ntohl (greq->relay_count);
1643 1774
@@ -1710,11 +1841,12 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1710 plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); 1841 plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES);
1711 (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,
1712 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1843 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1713 } 1844 (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst,
1714 (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, 1845 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1715 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1846 (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst,
1716 (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst,
1717 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 1847 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
1848
1849 }
1718 gst->slave 1850 gst->slave
1719 = GNUNET_PSYC_slave_join (cfg, &plc->pub_key, &plc->ego_key, 1851 = GNUNET_PSYC_slave_join (cfg, &plc->pub_key, &plc->ego_key,
1720 gst->join_flags, &gst->origin, 1852 gst->join_flags, &gst->origin,
@@ -1724,6 +1856,9 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1724 &psyc_recv_join_dcsn, 1856 &psyc_recv_join_dcsn,
1725 gst, join_msg); 1857 gst, join_msg);
1726 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);
1727 ret = GNUNET_YES; 1862 ret = GNUNET_YES;
1728 } 1863 }
1729 1864
@@ -1734,78 +1869,96 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1734 1869
1735 1870
1736static int 1871static int
1737check_client_guest_enter (void *cls, 1872client_guest_enter (struct Client *c,
1738 const struct GuestEnterRequest *greq) 1873 const struct GuestEnterRequest *greq)
1739{
1740 return GNUNET_OK;
1741}
1742
1743
1744/**
1745 * Handle a connecting client entering a place as guest.
1746 */
1747static void
1748handle_client_guest_enter (void *cls,
1749 const struct GuestEnterRequest *greq)
1750{ 1874{
1751 struct Client *c = cls; 1875 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1876 "client_guest_enter\n");
1877 struct GNUNET_PSYC_CountersResultMessage *result_msg;
1878 struct GNUNET_MQ_Envelope *env;
1752 struct GNUNET_SERVICE_Client *client = c->client; 1879 struct GNUNET_SERVICE_Client *client = c->client;
1753
1754 uint16_t remaining = ntohs (greq->header.size) - sizeof (*greq); 1880 uint16_t remaining = ntohs (greq->header.size) - sizeof (*greq);
1755 const char *app_id = NULL; 1881 const char *app_id = NULL;
1756 uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &greq[1], 1882 uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &greq[1],
1757 remaining, 1, &app_id); 1883 remaining, 1, &app_id);
1758 if (0 == offset)
1759 {
1760 GNUNET_break (0);
1761 GNUNET_SERVICE_client_drop (client);
1762 return;
1763 }
1764
1765 struct Guest *gst = NULL; 1884 struct Guest *gst = NULL;
1766 struct Place *plc = NULL; 1885 struct Place *plc = NULL;
1767 1886
1887 if (0 == offset)
1888 {
1889 return GNUNET_SYSERR;
1890 }
1768 switch (guest_enter (greq, &gst)) 1891 switch (guest_enter (greq, &gst))
1769 { 1892 {
1770 case GNUNET_YES: 1893 case GNUNET_YES:
1894 {
1771 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));
1772 plc->guest = gst; 1899 plc->guest = gst;
1773 app_place_save (app_id, (const struct PlaceEnterRequest *) greq); 1900 app_place_save (app_id, (const struct PlaceEnterRequest *) greq);
1901 app_notify_place (&greq->header, client);
1774 break; 1902 break;
1775 1903 }
1776 case GNUNET_NO: 1904 case GNUNET_NO:
1777 { 1905 {
1778 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));
1779 plc->guest = gst; 1910 plc->guest = gst;
1780 1911 env = GNUNET_MQ_msg (result_msg,
1781 struct GNUNET_PSYC_CountersResultMessage res; 1912 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK);
1782 res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); 1913 result_msg->result_code = htonl (GNUNET_OK);
1783 res.header.size = htons (sizeof (res)); 1914 result_msg->max_message_id = GNUNET_htonll (plc->max_message_id);
1784 res.result_code = htonl (GNUNET_OK); 1915 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1785 res.max_message_id = GNUNET_htonll (plc->max_message_id); 1916 env);
1786
1787 client_send_msg (client, &res.header);
1788 if (NULL != gst->join_dcsn) 1917 if (NULL != gst->join_dcsn)
1789 client_send_msg (client, &gst->join_dcsn->header); 1918 {
1790 1919 env = GNUNET_MQ_msg_copy (&gst->join_dcsn->header);
1920 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1921 env);
1922 }
1791 break; 1923 break;
1792 } 1924 }
1793 case GNUNET_SYSERR: 1925 case GNUNET_SYSERR:
1794 GNUNET_break (0); 1926 {
1795 GNUNET_SERVICE_client_drop (client); 1927 return GNUNET_SYSERR;
1796 return; 1928 }
1797 } 1929 }
1798
1799 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1800 "%p Client connected as guest to place %s.\n",
1801 gst, GNUNET_h2s (&plc->pub_key_hash));
1802 1930
1803 struct ClientListItem *cli = GNUNET_new (struct ClientListItem); 1931 struct ClientListItem *cli = GNUNET_new (struct ClientListItem);
1804 cli->client = client; 1932 cli->client = client;
1805 GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli); 1933 GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli);
1934 return GNUNET_OK;
1935}
1806 1936
1807 c->place = plc; 1937
1808 GNUNET_SERVICE_client_continue (client); 1938static int
1939check_client_guest_enter (void *cls,
1940 const struct GuestEnterRequest *greq)
1941{
1942 return GNUNET_OK;
1943}
1944
1945
1946/**
1947 * Handle a connecting client entering a place as guest.
1948 */
1949static void
1950handle_client_guest_enter (void *cls,
1951 const struct GuestEnterRequest *greq)
1952{
1953 struct Client *c = cls;
1954
1955 if (GNUNET_SYSERR == client_guest_enter (c, greq))
1956 {
1957 GNUNET_break (0);
1958 GNUNET_SERVICE_client_drop (c->client);
1959 return;
1960 }
1961 GNUNET_SERVICE_client_continue (c->client);
1809} 1962}
1810 1963
1811 1964
@@ -1830,7 +1983,7 @@ gns_result_guest_enter (void *cls, uint32_t rd_count,
1830{ 1983{
1831 struct GuestEnterByNameClosure *gcls = cls; 1984 struct GuestEnterByNameClosure *gcls = cls;
1832 struct Client *c = gcls->client; 1985 struct Client *c = gcls->client;
1833 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1986 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1834 "%p GNS result: %u records.\n", 1987 "%p GNS result: %u records.\n",
1835 c, rd_count); 1988 c, rd_count);
1836 1989
@@ -1882,7 +2035,7 @@ gns_result_guest_enter (void *cls, uint32_t rd_count,
1882 p += relay_size; 2035 p += relay_size;
1883 GNUNET_memcpy (p, gcls->join_msg, join_msg_size); 2036 GNUNET_memcpy (p, gcls->join_msg, join_msg_size);
1884 2037
1885 handle_client_guest_enter (c, greq); 2038 client_guest_enter (c, greq);
1886 2039
1887 GNUNET_free (gcls->app_id); 2040 GNUNET_free (gcls->app_id);
1888 if (NULL != gcls->password) 2041 if (NULL != gcls->password)
@@ -1960,118 +2113,7 @@ handle_client_guest_enter_by_name (void *cls,
1960 GNUNET_GNSRECORD_TYPE_PLACE, 2113 GNUNET_GNSRECORD_TYPE_PLACE,
1961 GNUNET_GNS_LO_DEFAULT, 2114 GNUNET_GNS_LO_DEFAULT,
1962 &gns_result_guest_enter, gcls); 2115 &gns_result_guest_enter, gcls);
1963} 2116 GNUNET_SERVICE_client_continue (client);
1964
1965
1966void
1967app_notify_place (struct GNUNET_MessageHeader *msg,
1968 struct GNUNET_SERVICE_Client *client)
1969{
1970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1971 "%p Sending place notification of type %u to client.\n",
1972 client, ntohs (msg->type));
1973
1974 uint16_t msg_size = ntohs (msg->size);
1975 struct AppPlaceMessage amsg;
1976 amsg.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE);
1977 amsg.header.size = htons (sizeof (amsg));
1978 // FIXME: also notify about not entered places
1979 amsg.place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED;
1980
1981 switch (ntohs (msg->type))
1982 {
1983 case GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER:
1984 if (msg_size < sizeof (struct HostEnterRequest))
1985 return;
1986 struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg;
1987 amsg.is_host = GNUNET_YES;
1988 amsg.ego_pub_key = hreq->ego_pub_key;
1989 amsg.place_pub_key = hreq->place_pub_key;
1990 break;
1991
1992 case GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER:
1993 if (msg_size < sizeof (struct GuestEnterRequest))
1994 return;
1995 struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg;
1996 amsg.is_host = GNUNET_NO;
1997 amsg.ego_pub_key = greq->ego_pub_key;
1998 amsg.place_pub_key = greq->place_pub_key;
1999 break;
2000
2001 default:
2002 return;
2003 }
2004
2005 client_send_msg (client, &amsg.header);
2006}
2007
2008
2009void
2010app_notify_place_end (struct GNUNET_SERVICE_Client *client)
2011{
2012 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2013 "%p Sending end of place list notification to client\n",
2014 client);
2015
2016 struct GNUNET_MessageHeader msg;
2017 msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END);
2018 msg.size = htons (sizeof (msg));
2019
2020 client_send_msg (client, &msg);
2021}
2022
2023
2024void
2025app_notify_ego (struct Ego *ego, struct GNUNET_SERVICE_Client *client)
2026{
2027 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2028 "%p Sending ego notification to client: %s\n",
2029 client, ego->name);
2030
2031 size_t name_size = strlen (ego->name) + 1;
2032 struct AppEgoMessage *emsg = GNUNET_malloc (sizeof (*emsg) + name_size);
2033 emsg->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO);
2034 emsg->header.size = htons (sizeof (*emsg) + name_size);
2035
2036 GNUNET_CRYPTO_ecdsa_key_get_public (&ego->key, &emsg->ego_pub_key);
2037 GNUNET_memcpy (&emsg[1], ego->name, name_size);
2038
2039 client_send_msg (client, &emsg->header);
2040 GNUNET_free (emsg);
2041}
2042
2043
2044void
2045app_notify_ego_end (struct GNUNET_SERVICE_Client *client)
2046{
2047 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2048 "%p Sending end of ego list notification to client\n",
2049 client);
2050
2051 struct GNUNET_MessageHeader msg;
2052 msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END);
2053 msg.size = htons (sizeof (msg));
2054
2055 client_send_msg (client, &msg);
2056}
2057
2058
2059int
2060app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value)
2061{
2062 struct GNUNET_MessageHeader *
2063 msg = GNUNET_CONTAINER_multihashmap_get (places, key);
2064 if (NULL != msg)
2065 app_notify_place (msg, cls);
2066 return GNUNET_YES;
2067}
2068
2069
2070int
2071ego_entry (void *cls, const struct GNUNET_HashCode *key, void *value)
2072{
2073 app_notify_ego (value, cls);
2074 return GNUNET_YES;
2075} 2117}
2076 2118
2077 2119
@@ -2154,13 +2196,15 @@ handle_client_app_detach (void *cls,
2154} 2196}
2155 2197
2156 2198
2157int 2199static void
2158app_places_entry_remove (void *cls, const struct GNUNET_HashCode *key, void *value) 2200place_leave_cb (void *cls)
2159{ 2201{
2160 struct Place *plc = cls; 2202 struct Place *plc = cls;
2161 const char *app_id = value; 2203
2162 app_place_remove (app_id, &plc->ego_pub_key, &plc->pub_key); 2204 place_send_leave_ack (plc);
2163 return GNUNET_YES; 2205 (GNUNET_YES == plc->is_host)
2206 ? cleanup_host ((struct Host *) plc)
2207 : cleanup_guest ((struct Guest *) plc);
2164} 2208}
2165 2209
2166 2210
@@ -2174,6 +2218,11 @@ handle_client_place_leave (void *cls,
2174 struct Client *c = cls; 2218 struct Client *c = cls;
2175 struct GNUNET_SERVICE_Client *client = c->client; 2219 struct GNUNET_SERVICE_Client *client = c->client;
2176 struct Place *plc = c->place; 2220 struct Place *plc = c->place;
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));
2177 if (NULL == plc) 2226 if (NULL == plc)
2178 { 2227 {
2179 GNUNET_break (0); 2228 GNUNET_break (0);
@@ -2181,40 +2230,28 @@ handle_client_place_leave (void *cls,
2181 return; 2230 return;
2182 } 2231 }
2183 2232
2184 /* FIXME: remove all app subscriptions and leave this place */ 2233 if (GNUNET_YES != plc->is_disconnecting)
2185
2186 struct GNUNET_CONTAINER_MultiHashMap *
2187 place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &plc->pub_key_hash);
2188 if (NULL != place_apps)
2189 { 2234 {
2190 GNUNET_CONTAINER_multihashmap_iterate (place_apps, app_places_entry_remove, plc); 2235 plc->is_disconnecting = GNUNET_YES;
2191 } 2236 if (plc->is_host)
2192 2237 {
2193 /* FIXME: disconnect from the network, but keep local connection for history access */ 2238 struct Host *host = plc->host;
2194 2239 GNUNET_assert (NULL != host);
2195 /* Disconnect all clients connected to the place */ 2240 GNUNET_PSYC_master_stop (host->master, GNUNET_NO, &place_leave_cb, plc);
2196 struct ClientListItem *cli = plc->clients_head, *next;
2197 while (NULL != cli)
2198 {
2199 GNUNET_CONTAINER_DLL_remove (plc->clients_head, plc->clients_tail, cli);
2200 GNUNET_SERVICE_client_drop (cli->client);
2201 next = cli->next;
2202 GNUNET_free (cli);
2203 cli = next;
2204 }
2205
2206 if (GNUNET_YES != plc->is_disconnected)
2207 {
2208 plc->is_disconnected = GNUNET_YES;
2209 if (NULL != plc->tmit_msgs_head)
2210 { /* Send pending messages to PSYC before cleanup. */
2211 psyc_transmit_message (plc);
2212 } 2241 }
2213 else 2242 else
2214 { 2243 {
2215 cleanup_place (plc); 2244 struct Guest *guest = plc->guest;
2245 GNUNET_assert (NULL != guest);
2246 GNUNET_PSYC_slave_part (guest->slave, GNUNET_NO, &place_leave_cb, plc);
2216 } 2247 }
2217 } 2248 }
2249 else
2250 {
2251 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2252 "got leave request but place is already leaving\n");
2253 }
2254 GNUNET_SERVICE_client_continue (client);
2218} 2255}
2219 2256
2220 2257
@@ -2273,6 +2310,9 @@ handle_client_join_decision (void *cls,
2273 ? (struct GNUNET_PSYC_Message *) &dcsn[1] 2310 ? (struct GNUNET_PSYC_Message *) &dcsn[1]
2274 : NULL; 2311 : NULL;
2275 2312
2313 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2314 "jcls.msg = %p\n",
2315 jcls.msg);
2276 struct GNUNET_HashCode slave_pub_hash; 2316 struct GNUNET_HashCode slave_pub_hash;
2277 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),
2278 &slave_pub_hash); 2318 &slave_pub_hash);
@@ -2302,10 +2342,11 @@ handle_client_join_decision (void *cls,
2302static void 2342static void
2303send_message_ack (struct Place *plc, struct GNUNET_SERVICE_Client *client) 2343send_message_ack (struct Place *plc, struct GNUNET_SERVICE_Client *client)
2304{ 2344{
2305 struct GNUNET_MessageHeader res; 2345 struct GNUNET_MQ_Envelope *env;
2306 res.size = htons (sizeof (res)); 2346
2307 res.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK); 2347 env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK);
2308 client_send_msg (client, &res); 2348 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
2349 env);
2309} 2350}
2310 2351
2311 2352
@@ -2437,7 +2478,6 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data)
2437 { 2478 {
2438 *data_size = 0; 2479 *data_size = 0;
2439 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); 2480 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg);
2440 plc->is_disconnected = GNUNET_YES;
2441 GNUNET_SERVICE_client_drop (tmit_frag->client); 2481 GNUNET_SERVICE_client_drop (tmit_frag->client);
2442 GNUNET_SCHEDULER_add_now (&cleanup_place, plc); 2482 GNUNET_SCHEDULER_add_now (&cleanup_place, plc);
2443 return ret; 2483 return ret;
@@ -2479,11 +2519,7 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data)
2479 { 2519 {
2480 psyc_transmit_message (plc); 2520 psyc_transmit_message (plc);
2481 } 2521 }
2482 else if (GNUNET_YES == plc->is_disconnected) 2522 /* FIXME: handle partial message (when still in_transmit) */
2483 {
2484 /* FIXME: handle partial message (when still in_transmit) */
2485 cleanup_place (plc);
2486 }
2487 } 2523 }
2488 return ret; 2524 return ret;
2489} 2525}
@@ -2597,7 +2633,6 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data,
2597 *data_size = 0; 2633 *data_size = 0;
2598 ret = GNUNET_SYSERR; 2634 ret = GNUNET_SYSERR;
2599 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); 2635 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg);
2600 plc->is_disconnected = GNUNET_YES;
2601 GNUNET_SERVICE_client_drop (tmit_frag->client); 2636 GNUNET_SERVICE_client_drop (tmit_frag->client);
2602 GNUNET_SCHEDULER_add_now (&cleanup_place, plc); 2637 GNUNET_SCHEDULER_add_now (&cleanup_place, plc);
2603 } 2638 }
@@ -2862,26 +2897,26 @@ psyc_transmit_queue_message (struct Place *plc,
2862} 2897}
2863 2898
2864 2899
2865/** 2900///**
2866 * Cancel transmission of current message to PSYC. 2901// * Cancel transmission of current message to PSYC.
2867 * 2902// *
2868 * @param plc Place to send to. 2903// * @param plc Place to send to.
2869 * @param client Client the message originates from. 2904// * @param client Client the message originates from.
2870 */ 2905// */
2871static void 2906//static void
2872psyc_transmit_cancel (struct Place *plc, struct GNUNET_SERVICE_Client *client) 2907//psyc_transmit_cancel (struct Place *plc, struct GNUNET_SERVICE_Client *client)
2873{ 2908//{
2874 uint16_t type = GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL; 2909// uint16_t type = GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL;
2875 2910//
2876 struct GNUNET_MessageHeader msg; 2911// struct GNUNET_MessageHeader msg;
2877 msg.size = htons (sizeof (msg)); 2912// msg.size = htons (sizeof (msg));
2878 msg.type = htons (type); 2913// msg.type = htons (type);
2879 2914//
2880 psyc_transmit_queue_message (plc, client, sizeof (msg), &msg, type, type, NULL); 2915// psyc_transmit_queue_message (plc, client, sizeof (msg), &msg, type, type, NULL);
2881 psyc_transmit_message (plc); 2916// psyc_transmit_message (plc);
2882 2917//
2883 /* FIXME: cleanup */ 2918// /* FIXME: cleanup */
2884} 2919//}
2885 2920
2886 2921
2887static int 2922static int
@@ -2902,17 +2937,19 @@ handle_client_psyc_message (void *cls,
2902 struct Client *c = cls; 2937 struct Client *c = cls;
2903 struct GNUNET_SERVICE_Client *client = c->client; 2938 struct GNUNET_SERVICE_Client *client = c->client;
2904 struct Place *plc = c->place; 2939 struct Place *plc = c->place;
2940 int ret;
2941
2905 if (NULL == plc) 2942 if (NULL == plc)
2906 { 2943 {
2944 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2945 "received PSYC message for non-existing client %p\n",
2946 client);
2907 GNUNET_break (0); 2947 GNUNET_break (0);
2908 GNUNET_SERVICE_client_drop (client); 2948 GNUNET_SERVICE_client_drop (client);
2909 return; 2949 return;
2910 } 2950 }
2911
2912 int ret = GNUNET_SYSERR;
2913
2914 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2951 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2915 "%p Received message from client.\n", plc); 2952 "%p Received message of type %d from client.\n", plc, ntohs (msg->type));
2916 GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg); 2953 GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg);
2917 2954
2918 if (GNUNET_YES != plc->is_ready) 2955 if (GNUNET_YES != plc->is_ready)
@@ -2933,20 +2970,19 @@ handle_client_psyc_message (void *cls,
2933 "%p Received message with invalid payload size (%u) from client.\n", 2970 "%p Received message with invalid payload size (%u) from client.\n",
2934 plc, psize); 2971 plc, psize);
2935 GNUNET_break (0); 2972 GNUNET_break (0);
2936 psyc_transmit_cancel (plc, client);
2937 GNUNET_SERVICE_client_drop (client); 2973 GNUNET_SERVICE_client_drop (client);
2938 return; 2974 return;
2939 } 2975 }
2940 2976
2941 uint16_t first_ptype = 0, last_ptype = 0; 2977 uint16_t first_ptype = 0;
2942 if (GNUNET_SYSERR 2978 uint16_t last_ptype = 0;
2943 == GNUNET_PSYC_receive_check_parts (psize, (const char *) &msg[1], 2979 if (GNUNET_SYSERR ==
2944 &first_ptype, &last_ptype)) 2980 GNUNET_PSYC_receive_check_parts (psize, (const char *) &msg[1],
2981 &first_ptype, &last_ptype))
2945 { 2982 {
2946 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2983 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2947 "%p Received invalid message part from client.\n", plc); 2984 "%p Received invalid message part from client.\n", plc);
2948 GNUNET_break (0); 2985 GNUNET_break (0);
2949 psyc_transmit_cancel (plc, client);
2950 GNUNET_SERVICE_client_drop (client); 2986 GNUNET_SERVICE_client_drop (client);
2951 return; 2987 return;
2952 } 2988 }
@@ -2963,20 +2999,19 @@ handle_client_psyc_message (void *cls,
2963 c->tmit_msg = NULL; 2999 c->tmit_msg = NULL;
2964 ret = psyc_transmit_message (plc); 3000 ret = psyc_transmit_message (plc);
2965 } 3001 }
2966 3002 else
3003 {
3004 ret = GNUNET_SYSERR;
3005 }
2967 if (GNUNET_OK != ret) 3006 if (GNUNET_OK != ret)
2968 { 3007 {
2969 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3008 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2970 "%p Received invalid message part from client.\n", plc); 3009 "%p Received invalid message part from client.\n", plc);
2971 GNUNET_break (0); 3010 GNUNET_break (0);
2972 psyc_transmit_cancel (plc, client);
2973 ret = GNUNET_SYSERR;
2974 }
2975
2976 if (GNUNET_OK == ret)
2977 GNUNET_SERVICE_client_continue (client);
2978 else
2979 GNUNET_SERVICE_client_drop (client); 3011 GNUNET_SERVICE_client_drop (client);
3012 return;
3013 }
3014 GNUNET_SERVICE_client_continue (client);
2980} 3015}
2981 3016
2982 3017
@@ -3006,7 +3041,7 @@ psyc_recv_history_message (void *cls, const struct GNUNET_PSYC_MessageHeader *ms
3006 GNUNET_memcpy (&res[1], msg, size); 3041 GNUNET_memcpy (&res[1], msg, size);
3007 3042
3008 /** @todo FIXME: send only to requesting client */ 3043 /** @todo FIXME: send only to requesting client */
3009 place_send_msg (plc, &res->header); 3044 place_send_msg (plc, GNUNET_MQ_msg_copy (&res->header));
3010 3045
3011 GNUNET_free (res); 3046 GNUNET_free (res);
3012} 3047}
@@ -3108,29 +3143,24 @@ psyc_recv_state_var (void *cls,
3108 uint32_t value_size, 3143 uint32_t value_size,
3109 uint32_t full_value_size) 3144 uint32_t full_value_size)
3110{ 3145{
3146 struct GNUNET_OperationResultMessage *result_msg;
3147 struct GNUNET_MQ_Envelope *env;
3111 struct OperationClosure *opcls = cls; 3148 struct OperationClosure *opcls = cls;
3112 struct Client *c = opcls->client; 3149 struct Client *c = opcls->client;
3113 struct Place *plc = c->place; 3150 struct Place *plc = c->place;
3151 uint16_t size = ntohs (mod->size);
3114 3152
3115 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3153 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3116 "%p Received state variable %s from PSYC\n", 3154 "%p Received state variable %s from PSYC\n",
3117 plc, name); 3155 plc, name);
3118 3156 env = GNUNET_MQ_msg_extra (result_msg,
3119 uint16_t size = ntohs (mod->size); 3157 size,
3120 3158 GNUNET_MESSAGE_TYPE_PSYC_STATE_RESULT);
3121 struct GNUNET_OperationResultMessage * 3159 result_msg->op_id = opcls->op_id;
3122 res = GNUNET_malloc (sizeof (*res) + size); 3160 result_msg->result_code = GNUNET_htonll (GNUNET_OK);
3123 res->header.size = htons (sizeof (*res) + size); 3161 GNUNET_memcpy (&result_msg[1], mod, size);
3124 res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_STATE_RESULT);
3125 res->op_id = opcls->op_id;
3126 res->result_code = GNUNET_htonll (GNUNET_OK);
3127
3128 GNUNET_memcpy (&res[1], mod, size);
3129
3130 /** @todo FIXME: send only to requesting client */ 3162 /** @todo FIXME: send only to requesting client */
3131 place_send_msg (plc, &res->header); 3163 place_send_msg (plc, env);
3132
3133 GNUNET_free (res);
3134} 3164}
3135 3165
3136 3166
@@ -3184,7 +3214,7 @@ handle_client_state_get (void *cls,
3184 uint16_t size = ntohs (req->header.size); 3214 uint16_t size = ntohs (req->header.size);
3185 const char *name = (const char *) &req[1]; 3215 const char *name = (const char *) &req[1];
3186 3216
3187 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3188 "%p State get #%" PRIu64 ": %s\n", 3218 "%p State get #%" PRIu64 ": %s\n",
3189 plc, GNUNET_ntohll (req->op_id), name); 3219 plc, GNUNET_ntohll (req->op_id), name);
3190 3220
@@ -3382,7 +3412,7 @@ path_basename (const char *path)
3382 if (NULL != basename) 3412 if (NULL != basename)
3383 basename++; 3413 basename++;
3384 3414
3385 if (NULL == basename || '\0' == basename) 3415 if (NULL == basename || '\0' == *basename)
3386 return NULL; 3416 return NULL;
3387 3417
3388 return basename; 3418 return basename;
@@ -3468,7 +3498,10 @@ file_place_load (void *cls, const char *place_filename)
3468 return GNUNET_OK; 3498 return GNUNET_OK;
3469 } 3499 }
3470 3500
3471 app_place_add (plcls->app_id, ereq); 3501 if (GNUNET_SYSERR == app_place_add (plcls->app_id, ereq))
3502 {
3503 GNUNET_assert (0);
3504 }
3472 GNUNET_free (ereq); 3505 GNUNET_free (ereq);
3473 return GNUNET_OK; 3506 return GNUNET_OK;
3474} 3507}
@@ -3523,6 +3556,10 @@ identity_recv_ego (void *cls, struct GNUNET_IDENTITY_Ego *id_ego,
3523 if (NULL == id_ego) // end of initial list of egos 3556 if (NULL == id_ego) // end of initial list of egos
3524 return; 3557 return;
3525 3558
3559 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3560 "social service received ego %s\n",
3561 name);
3562
3526 struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key; 3563 struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
3527 GNUNET_IDENTITY_ego_get_public_key (id_ego, &ego_pub_key); 3564 GNUNET_IDENTITY_ego_get_public_key (id_ego, &ego_pub_key);
3528 3565
@@ -3571,6 +3608,9 @@ run (void *cls,
3571 const struct GNUNET_CONFIGURATION_Handle *c, 3608 const struct GNUNET_CONFIGURATION_Handle *c,
3572 struct GNUNET_SERVICE_Handle *svc) 3609 struct GNUNET_SERVICE_Handle *svc)
3573{ 3610{
3611 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3612 "starting social service\n");
3613
3574 cfg = c; 3614 cfg = c;
3575 service = svc; 3615 service = svc;
3576 GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); 3616 GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer);
@@ -3583,7 +3623,7 @@ run (void *cls,
3583 apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); 3623 apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
3584 places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); 3624 places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO);
3585 apps_places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); 3625 apps_places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO);
3586 places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); 3626 //places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO);
3587 3627
3588 id = GNUNET_IDENTITY_connect (cfg, &identity_recv_ego, NULL); 3628 id = GNUNET_IDENTITY_connect (cfg, &identity_recv_ego, NULL);
3589 gns = GNUNET_GNS_connect (cfg); 3629 gns = GNUNET_GNS_connect (cfg);
diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c
index de680b11c..12c5bf2e1 100644
--- a/src/social/gnunet-social.c
+++ b/src/social/gnunet-social.c
@@ -283,7 +283,7 @@ exit_fail ()
283static void 283static void
284host_left (void *cls) 284host_left (void *cls)
285{ 285{
286 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 286 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
287 "The host has left the place.\n"); 287 "The host has left the place.\n");
288 exit_success (); 288 exit_success ();
289} 289}
@@ -309,7 +309,7 @@ host_leave ()
309static void 309static void
310guest_left (void *cls) 310guest_left (void *cls)
311{ 311{
312 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 312 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
313 "Guest has left the place.\n"); 313 "Guest has left the place.\n");
314} 314}
315 315
@@ -518,7 +518,7 @@ look_var (void *cls,
518 uint32_t value_size, 518 uint32_t value_size,
519 uint32_t full_value_size) 519 uint32_t full_value_size)
520{ 520{
521 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 521 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
522 "Received var: %s\n%.*s\n", 522 "Received var: %s\n%.*s\n",
523 name, value_size, (const char *) value); 523 name, value_size, (const char *) value);
524} 524}
@@ -558,7 +558,7 @@ slicer_recv_method (void *cls,
558 const char *method_name) 558 const char *method_name)
559{ 559{
560 method_received = method_name; 560 method_received = method_name;
561 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 561 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
562 "Received method for message ID %" PRIu64 ":\n" 562 "Received method for message ID %" PRIu64 ":\n"
563 "%s (flags: %x)\n", 563 "%s (flags: %x)\n",
564 message_id, method_name, ntohl (meth->flags)); 564 message_id, method_name, ntohl (meth->flags));
@@ -584,7 +584,7 @@ slicer_recv_modifier (void *cls,
584 uint16_t full_value_size) 584 uint16_t full_value_size)
585{ 585{
586#if 0 586#if 0
587 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 587 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
588 "Received modifier for message ID %" PRIu64 ":\n" 588 "Received modifier for message ID %" PRIu64 ":\n"
589 "%c%s: %.*s (size: %u)\n", 589 "%c%s: %.*s (size: %u)\n",
590 message_id, oper, name, value_size, (const char *) value, value_size); 590 message_id, oper, name, value_size, (const char *) value, value_size);
@@ -608,7 +608,7 @@ slicer_recv_data (void *cls,
608 uint16_t data_size) 608 uint16_t data_size)
609{ 609{
610#if 0 610#if 0
611 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 611 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
612 "Received data for message ID %" PRIu64 ":\n" 612 "Received data for message ID %" PRIu64 ":\n"
613 "%.*s\n", 613 "%.*s\n",
614 message_id, data_size, (const char *) data); 614 message_id, data_size, (const char *) data);
@@ -631,7 +631,7 @@ slicer_recv_eom (void *cls,
631 uint8_t is_cancelled) 631 uint8_t is_cancelled)
632{ 632{
633 printf(".\n"); 633 printf(".\n");
634 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 634 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
635 "Received end of message ID %" PRIu64 635 "Received end of message ID %" PRIu64
636 ", cancelled: %u\n", 636 ", cancelled: %u\n",
637 message_id, is_cancelled); 637 message_id, is_cancelled);
@@ -668,7 +668,7 @@ guest_recv_entry_decision (void *cls,
668 int is_admitted, 668 int is_admitted,
669 const struct GNUNET_PSYC_Message *entry_msg) 669 const struct GNUNET_PSYC_Message *entry_msg)
670{ 670{
671 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 671 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
672 "Guest received entry decision %d\n", 672 "Guest received entry decision %d\n",
673 is_admitted); 673 is_admitted);
674 674
@@ -683,7 +683,7 @@ guest_recv_entry_decision (void *cls,
683 GNUNET_PSYC_message_parse (pmsg, &method_name, env, &data, &data_size); 683 GNUNET_PSYC_message_parse (pmsg, &method_name, env, &data, &data_size);
684 GNUNET_free (pmsg); 684 GNUNET_free (pmsg);
685 685
686 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 686 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
687 "%s\n%.*s\n", 687 "%s\n%.*s\n",
688 method_name, data_size, (const char *) data); 688 method_name, data_size, (const char *) data);
689 } 689 }
@@ -704,7 +704,7 @@ guest_recv_local_enter (void *cls, int result,
704 uint64_t max_message_id) 704 uint64_t max_message_id)
705{ 705{
706 char *pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key); 706 char *pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key);
707 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 707 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
708 "Guest entered local place: %s, max_message_id: %" PRIu64 "\n", 708 "Guest entered local place: %s, max_message_id: %" PRIu64 "\n",
709 pub_str, max_message_id); 709 pub_str, max_message_id);
710 GNUNET_free (pub_str); 710 GNUNET_free (pub_str);
@@ -802,7 +802,7 @@ host_answer_door (void *cls,
802 char * 802 char *
803 nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key); 803 nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
804 804
805 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 805 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
806 "Entry request: %s\n", nym_str); 806 "Entry request: %s\n", nym_str);
807 GNUNET_free (nym_str); 807 GNUNET_free (nym_str);
808 808
@@ -840,7 +840,7 @@ host_farewell (void *cls,
840 char * 840 char *
841 nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key); 841 nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
842 842
843 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 843 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
844 "Farewell: %s\n", nym_str); 844 "Farewell: %s\n", nym_str);
845 GNUNET_free (nym_str); 845 GNUNET_free (nym_str);
846} 846}
@@ -856,7 +856,7 @@ host_entered (void *cls, int result,
856{ 856{
857 place_pub_key = *pub_key; 857 place_pub_key = *pub_key;
858 char *pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key); 858 char *pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key);
859 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 859 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
860 "Host entered: %s, max_message_id: %" PRIu64 "\n", 860 "Host entered: %s, max_message_id: %" PRIu64 "\n",
861 pub_str, max_message_id); 861 pub_str, max_message_id);
862 GNUNET_free (pub_str); 862 GNUNET_free (pub_str);
diff --git a/src/social/social_api.c b/src/social/social_api.c
index d57d16cfb..89843831b 100644
--- a/src/social/social_api.c
+++ b/src/social/social_api.c
@@ -183,6 +183,7 @@ struct GNUNET_SOCIAL_Place
183 */ 183 */
184 struct GNUNET_PSYC_Slicer *slicer; 184 struct GNUNET_PSYC_Slicer *slicer;
185 185
186 // FIXME: do we need is_disconnecing like on the psyc and multicast APIs?
186 /** 187 /**
187 * Function called after disconnected from the service. 188 * Function called after disconnected from the service.
188 */ 189 */
@@ -371,6 +372,68 @@ struct ZoneAddNymHandle
371}; 372};
372 373
373 374
375/*** CLEANUP / DISCONNECT ***/
376
377
378static void
379host_cleanup (struct GNUNET_SOCIAL_Host *hst)
380{
381 if (NULL != hst->slicer)
382 {
383 GNUNET_PSYC_slicer_destroy (hst->slicer);
384 hst->slicer = NULL;
385 }
386 GNUNET_free (hst);
387}
388
389
390static void
391guest_cleanup (struct GNUNET_SOCIAL_Guest *gst)
392{
393 GNUNET_free (gst);
394}
395
396
397static void
398place_cleanup (struct GNUNET_SOCIAL_Place *plc)
399{
400 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
401 "cleaning up place %p\n",
402 plc);
403 if (NULL != plc->tmit)
404 {
405 GNUNET_PSYC_transmit_destroy (plc->tmit);
406 plc->tmit = NULL;
407 }
408 if (NULL != plc->connect_env)
409 {
410 GNUNET_MQ_discard (plc->connect_env);
411 plc->connect_env = NULL;
412 }
413 if (NULL != plc->mq)
414 {
415 GNUNET_MQ_destroy (plc->mq);
416 plc->mq = NULL;
417 }
418 if (NULL != plc->disconnect_cb)
419 {
420 plc->disconnect_cb (plc->disconnect_cls);
421 plc->disconnect_cb = NULL;
422 }
423
424 (GNUNET_YES == plc->is_host)
425 ? host_cleanup ((struct GNUNET_SOCIAL_Host *) plc)
426 : guest_cleanup ((struct GNUNET_SOCIAL_Guest *) plc);
427}
428
429
430static void
431place_disconnect (struct GNUNET_SOCIAL_Place *plc)
432{
433 place_cleanup (plc);
434}
435
436
374/*** NYM ***/ 437/*** NYM ***/
375 438
376static struct GNUNET_SOCIAL_Nym * 439static struct GNUNET_SOCIAL_Nym *
@@ -428,7 +491,7 @@ host_recv_notice_place_leave_method (void *cls,
428 491
429 struct GNUNET_SOCIAL_Nym *nym = nym_get_or_create (&msg->slave_pub_key); 492 struct GNUNET_SOCIAL_Nym *nym = nym_get_or_create (&msg->slave_pub_key);
430 493
431 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 494 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
432 "Host received method for message ID %" PRIu64 " from nym %s: %s\n", 495 "Host received method for message ID %" PRIu64 " from nym %s: %s\n",
433 message_id, GNUNET_h2s (&nym->pub_key_hash), method_name); 496 message_id, GNUNET_h2s (&nym->pub_key_hash), method_name);
434 497
@@ -436,7 +499,7 @@ host_recv_notice_place_leave_method (void *cls,
436 hst->notice_place_leave_env = GNUNET_PSYC_env_create (); 499 hst->notice_place_leave_env = GNUNET_PSYC_env_create ();
437 500
438 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key); 501 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key);
439 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
440 "_notice_place_leave: got method from nym %s (%s).\n", 503 "_notice_place_leave: got method from nym %s (%s).\n",
441 GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str); 504 GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str);
442 GNUNET_free (str); 505 GNUNET_free (str);
@@ -458,7 +521,7 @@ host_recv_notice_place_leave_modifier (void *cls,
458 if (NULL == hst->notice_place_leave_env) 521 if (NULL == hst->notice_place_leave_env)
459 return; 522 return;
460 523
461 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 524 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
462 "Host received modifier for _notice_place_leave message with ID %" PRIu64 ":\n" 525 "Host received modifier for _notice_place_leave message with ID %" PRIu64 ":\n"
463 "%c%s: %.*s\n", 526 "%c%s: %.*s\n",
464 message_id, oper, name, value_size, (const char *) value); 527 message_id, oper, name, value_size, (const char *) value);
@@ -485,7 +548,7 @@ host_recv_notice_place_leave_eom (void *cls,
485 return; 548 return;
486 549
487 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key); 550 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key);
488 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 551 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
489 "_notice_place_leave: got EOM from nym %s (%s).\n", 552 "_notice_place_leave: got EOM from nym %s (%s).\n",
490 GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str); 553 GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str);
491 GNUNET_free (str); 554 GNUNET_free (str);
@@ -1015,100 +1078,24 @@ handle_app_place_end (void *cls,
1015} 1078}
1016 1079
1017 1080
1018/*** CLEANUP / DISCONNECT ***/ 1081/**
1019 1082 * Handler for a #GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK message received
1020 1083 * from the social service.
1021static void 1084 *
1022host_cleanup (struct GNUNET_SOCIAL_Host *hst) 1085 * @param cls the place of type `struct GNUNET_SOCIAL_Place`
1023{ 1086 * @param msg the message received from the service
1024 if (NULL != hst->slicer) 1087 */
1025 {
1026 GNUNET_PSYC_slicer_destroy (hst->slicer);
1027 hst->slicer = NULL;
1028 }
1029 GNUNET_free (hst);
1030}
1031
1032
1033static void 1088static void
1034guest_cleanup (struct GNUNET_SOCIAL_Guest *gst) 1089handle_place_leave_ack (void *cls,
1090 const struct GNUNET_MessageHeader *msg)
1035{ 1091{
1036 GNUNET_free (gst); 1092 struct GNUNET_SOCIAL_Place *plc = cls;
1037}
1038
1039 1093
1040static void
1041place_cleanup (struct GNUNET_SOCIAL_Place *plc)
1042{
1043 struct GNUNET_HashCode place_pub_hash;
1044 GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash);
1045 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1094 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1046 "%s place cleanup: %s\n", 1095 "%s left place %p\n",
1047 GNUNET_YES == plc->is_host ? "host" : "guest", 1096 plc->is_host ? "host" : "guest",
1048 GNUNET_h2s (&place_pub_hash)); 1097 plc);
1049 1098 place_disconnect (plc);
1050 if (NULL != plc->tmit)
1051 {
1052 GNUNET_PSYC_transmit_destroy (plc->tmit);
1053 plc->tmit = NULL;
1054 }
1055 if (NULL != plc->connect_env)
1056 {
1057 GNUNET_MQ_discard (plc->connect_env);
1058 plc->connect_env = NULL;
1059 }
1060 if (NULL != plc->mq)
1061 {
1062 GNUNET_MQ_destroy (plc->mq);
1063 plc->mq = NULL;
1064 }
1065 if (NULL != plc->disconnect_cb)
1066 {
1067 plc->disconnect_cb (plc->disconnect_cls);
1068 plc->disconnect_cb = NULL;
1069 }
1070
1071 (GNUNET_YES == plc->is_host)
1072 ? host_cleanup ((struct GNUNET_SOCIAL_Host *) plc)
1073 : guest_cleanup ((struct GNUNET_SOCIAL_Guest *) plc);
1074}
1075
1076
1077void
1078place_disconnect (struct GNUNET_SOCIAL_Place *plc,
1079 GNUNET_ContinuationCallback cb,
1080 void *cls)
1081{
1082 plc->disconnect_cb = cb;
1083 plc->disconnect_cls = cls;
1084
1085 if (NULL != plc->mq)
1086 {
1087 struct GNUNET_MQ_Envelope *env = GNUNET_MQ_get_last_envelope (plc->mq);
1088 if (NULL != env)
1089 {
1090 GNUNET_MQ_notify_sent (env, (GNUNET_SCHEDULER_TaskCallback) place_cleanup, plc);
1091 }
1092 else
1093 {
1094 place_cleanup (plc);
1095 }
1096 }
1097 else
1098 {
1099 place_cleanup (plc);
1100 }
1101}
1102
1103
1104void
1105place_leave (struct GNUNET_SOCIAL_Place *plc)
1106{
1107 struct GNUNET_MessageHeader *msg;
1108 struct GNUNET_MQ_Envelope *
1109 env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE);
1110
1111 GNUNET_MQ_send (plc->mq, env);
1112} 1099}
1113 1100
1114 1101
@@ -1168,6 +1155,10 @@ host_connect (struct GNUNET_SOCIAL_Host *hst)
1168 GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK, 1155 GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK,
1169 struct HostEnterAck, 1156 struct HostEnterAck,
1170 hst), 1157 hst),
1158 GNUNET_MQ_hd_fixed_size (place_leave_ack,
1159 GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK,
1160 struct GNUNET_MessageHeader,
1161 plc),
1171 GNUNET_MQ_hd_var_size (host_enter_request, 1162 GNUNET_MQ_hd_var_size (host_enter_request,
1172 GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, 1163 GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST,
1173 struct GNUNET_PSYC_JoinRequestMessage, 1164 struct GNUNET_PSYC_JoinRequestMessage,
@@ -1516,6 +1507,9 @@ GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *hst,
1516 void *notify_data_cls, 1507 void *notify_data_cls,
1517 enum GNUNET_SOCIAL_AnnounceFlags flags) 1508 enum GNUNET_SOCIAL_AnnounceFlags flags)
1518{ 1509{
1510 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1511 "PSYC_transmit_message for host, method: %s\n",
1512 method_name);
1519 if (GNUNET_OK == 1513 if (GNUNET_OK ==
1520 GNUNET_PSYC_transmit_message (hst->plc.tmit, method_name, env, 1514 GNUNET_PSYC_transmit_message (hst->plc.tmit, method_name, env,
1521 NULL, notify_data, notify_data_cls, flags)) 1515 NULL, notify_data, notify_data_cls, flags))
@@ -1580,7 +1574,11 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst,
1580 GNUNET_ContinuationCallback disconnect_cb, 1574 GNUNET_ContinuationCallback disconnect_cb,
1581 void *cls) 1575 void *cls)
1582{ 1576{
1583 place_disconnect (&hst->plc, disconnect_cb, cls); 1577 struct GNUNET_SOCIAL_Place *plc = &hst->plc;
1578
1579 plc->disconnect_cb = disconnect_cb;
1580 plc->disconnect_cls = cls;
1581 place_disconnect (plc);
1584} 1582}
1585 1583
1586 1584
@@ -1607,10 +1605,15 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst,
1607 GNUNET_ContinuationCallback disconnect_cb, 1605 GNUNET_ContinuationCallback disconnect_cb,
1608 void *cls) 1606 void *cls)
1609{ 1607{
1608 struct GNUNET_MQ_Envelope *envelope;
1609
1610 GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, 1610 GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL,
1611 GNUNET_SOCIAL_ANNOUNCE_NONE); 1611 GNUNET_SOCIAL_ANNOUNCE_NONE);
1612 place_leave (&hst->plc); 1612 hst->plc.disconnect_cb = disconnect_cb;
1613 GNUNET_SOCIAL_host_disconnect (hst, disconnect_cb, cls); 1613 hst->plc.disconnect_cls = cls;
1614 envelope = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE);
1615 GNUNET_MQ_send (hst->plc.mq,
1616 envelope);
1614} 1617}
1615 1618
1616 1619
@@ -1670,6 +1673,10 @@ guest_connect (struct GNUNET_SOCIAL_Guest *gst)
1670 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK, 1673 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK,
1671 struct GNUNET_PSYC_CountersResultMessage, 1674 struct GNUNET_PSYC_CountersResultMessage,
1672 gst), 1675 gst),
1676 GNUNET_MQ_hd_fixed_size (place_leave_ack,
1677 GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK,
1678 struct GNUNET_MessageHeader,
1679 plc),
1673 GNUNET_MQ_hd_var_size (guest_enter_decision, 1680 GNUNET_MQ_hd_var_size (guest_enter_decision,
1674 GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, 1681 GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION,
1675 struct GNUNET_PSYC_JoinDecisionMessage, 1682 struct GNUNET_PSYC_JoinDecisionMessage,
@@ -1896,6 +1903,64 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
1896} 1903}
1897 1904
1898 1905
1906struct ReconnectContext
1907{
1908 struct GNUNET_SOCIAL_Guest *guest;
1909 int *result;
1910 int64_t *max_message_id;
1911 GNUNET_SOCIAL_GuestEnterCallback enter_cb;
1912 void *enter_cls;
1913};
1914
1915
1916static void
1917guest_enter_reconnect_cb (void *cls,
1918 int result,
1919 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
1920 uint64_t max_message_id)
1921{
1922 struct ReconnectContext *reconnect_ctx = cls;
1923
1924 GNUNET_assert (NULL != reconnect_ctx);
1925 reconnect_ctx->result = GNUNET_new (int);
1926 *(reconnect_ctx->result) = result;
1927 reconnect_ctx->max_message_id = GNUNET_new (int64_t);
1928 *(reconnect_ctx->max_message_id) = max_message_id;
1929}
1930
1931
1932static void
1933guest_entry_dcsn_reconnect_cb (void *cls,
1934 int is_admitted,
1935 const struct GNUNET_PSYC_Message *entry_resp)
1936{
1937 struct ReconnectContext *reconnect_ctx = cls;
1938 struct GNUNET_SOCIAL_Guest *gst = reconnect_ctx->guest;
1939
1940 GNUNET_assert (NULL != reconnect_ctx);
1941 GNUNET_assert (NULL != reconnect_ctx->result);
1942 GNUNET_assert (NULL != reconnect_ctx->max_message_id);
1943 if (GNUNET_YES != is_admitted)
1944 {
1945 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1946 "Guest was rejected after calling "
1947 "GNUNET_SOCIAL_guest_enter_reconnect ()\n");
1948 }
1949 else if (NULL != reconnect_ctx->enter_cb)
1950 {
1951 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1952 "guest reconnected!\n");
1953 reconnect_ctx->enter_cb (reconnect_ctx->enter_cls,
1954 *(reconnect_ctx->result),
1955 &gst->plc.pub_key,
1956 *(reconnect_ctx->max_message_id));
1957 }
1958 GNUNET_free (reconnect_ctx->result);
1959 GNUNET_free (reconnect_ctx->max_message_id);
1960 GNUNET_free (reconnect_ctx);
1961}
1962
1963
1899/** 1964/**
1900 * Reconnect to an already entered place as guest. 1965 * Reconnect to an already entered place as guest.
1901 * 1966 *
@@ -1906,8 +1971,8 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
1906 * Flags for the entry. 1971 * Flags for the entry.
1907 * @param slicer 1972 * @param slicer
1908 * Slicer to use for processing incoming requests from guests. 1973 * Slicer to use for processing incoming requests from guests.
1909 * @param local_enter_cb 1974 * @param enter_cb
1910 * Called upon connection established to the social service. 1975 * Called upon re-entering is complete.
1911 * @param entry_decision_cb 1976 * @param entry_decision_cb
1912 * Called upon receiving entry decision. 1977 * Called upon receiving entry decision.
1913 * 1978 *
@@ -1917,11 +1982,12 @@ struct GNUNET_SOCIAL_Guest *
1917GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, 1982GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn,
1918 enum GNUNET_PSYC_SlaveJoinFlags flags, 1983 enum GNUNET_PSYC_SlaveJoinFlags flags,
1919 struct GNUNET_PSYC_Slicer *slicer, 1984 struct GNUNET_PSYC_Slicer *slicer,
1920 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, 1985 GNUNET_SOCIAL_GuestEnterCallback enter_cb,
1921 void *cls) 1986 void *cls)
1922{ 1987{
1923 struct GNUNET_SOCIAL_Guest *gst = GNUNET_malloc (sizeof (*gst)); 1988 struct GNUNET_SOCIAL_Guest *gst = GNUNET_malloc (sizeof (*gst));
1924 struct GNUNET_SOCIAL_Place *plc = &gst->plc; 1989 struct GNUNET_SOCIAL_Place *plc = &gst->plc;
1990 struct ReconnectContext *reconnect_ctx;
1925 1991
1926 uint16_t app_id_size = strlen (gconn->app->id) + 1; 1992 uint16_t app_id_size = strlen (gconn->app->id) + 1;
1927 struct GuestEnterRequest *greq; 1993 struct GuestEnterRequest *greq;
@@ -1940,10 +2006,15 @@ GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn
1940 plc->pub_key = gconn->plc_msg.place_pub_key; 2006 plc->pub_key = gconn->plc_msg.place_pub_key;
1941 plc->ego_pub_key = gconn->plc_msg.ego_pub_key; 2007 plc->ego_pub_key = gconn->plc_msg.ego_pub_key;
1942 2008
1943 plc->op = GNUNET_OP_create (); 2009 reconnect_ctx = GNUNET_new (struct ReconnectContext);
2010 reconnect_ctx->guest = gst;
2011 reconnect_ctx->enter_cb = enter_cb;
2012 reconnect_ctx->enter_cls = cls;
1944 2013
1945 gst->enter_cb = local_enter_cb; 2014 plc->op = GNUNET_OP_create ();
1946 gst->cb_cls = cls; 2015 gst->enter_cb = &guest_enter_reconnect_cb;
2016 gst->entry_dcsn_cb = &guest_entry_dcsn_reconnect_cb;
2017 gst->cb_cls = reconnect_ctx;
1947 2018
1948 guest_connect (gst); 2019 guest_connect (gst);
1949 return gst; 2020 return gst;
@@ -2028,7 +2099,11 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst,
2028 GNUNET_ContinuationCallback disconnect_cb, 2099 GNUNET_ContinuationCallback disconnect_cb,
2029 void *cls) 2100 void *cls)
2030{ 2101{
2031 place_disconnect (&gst->plc, disconnect_cb, cls); 2102 struct GNUNET_SOCIAL_Place *plc = &gst->plc;
2103
2104 plc->disconnect_cb = disconnect_cb;
2105 plc->disconnect_cls = cls;
2106 place_disconnect (plc);
2032} 2107}
2033 2108
2034 2109
@@ -2054,10 +2129,15 @@ GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst,
2054 GNUNET_ContinuationCallback disconnect_cb, 2129 GNUNET_ContinuationCallback disconnect_cb,
2055 void *cls) 2130 void *cls)
2056{ 2131{
2132 struct GNUNET_MQ_Envelope *envelope;
2133
2057 GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL, 2134 GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL,
2058 GNUNET_SOCIAL_TALK_NONE); 2135 GNUNET_SOCIAL_TALK_NONE);
2059 place_leave (&gst->plc); 2136 gst->plc.disconnect_cb = disconnect_cb;
2060 GNUNET_SOCIAL_guest_disconnect (gst, disconnect_cb, cls); 2137 gst->plc.disconnect_cls = cls;
2138 envelope = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE);
2139 GNUNET_MQ_send (gst->plc.mq,
2140 envelope);
2061} 2141}
2062 2142
2063 2143
diff --git a/src/social/test_social.c b/src/social/test_social.c
index 64ef10125..4d95cf005 100644
--- a/src/social/test_social.c
+++ b/src/social/test_social.c
@@ -129,22 +129,22 @@ enum
129 TEST_HOST_ANSWER_DOOR_REFUSE = 4, 129 TEST_HOST_ANSWER_DOOR_REFUSE = 4,
130 TEST_GUEST_RECV_ENTRY_DCSN_REFUSE = 5, 130 TEST_GUEST_RECV_ENTRY_DCSN_REFUSE = 5,
131 TEST_HOST_ANSWER_DOOR_ADMIT = 6, 131 TEST_HOST_ANSWER_DOOR_ADMIT = 6,
132 TEST_GUEST_RECV_ENTRY_DCSN_ADMIT = 9, 132 TEST_GUEST_RECV_ENTRY_DCSN_ADMIT = 7,
133 TEST_HOST_ANNOUNCE = 10, 133 TEST_HOST_ANNOUNCE = 8,
134 TEST_HOST_ANNOUNCE_END = 11, 134 TEST_HOST_ANNOUNCE_END = 9,
135 TEST_GUEST_TALK = 12, 135 TEST_GUEST_TALK = 10,
136 TEST_HOST_ANNOUNCE2 = 13, 136 TEST_HOST_ANNOUNCE2 = 11,
137 TEST_HOST_ANNOUNCE2_END = 14, 137 TEST_HOST_ANNOUNCE2_END = 12,
138 TEST_GUEST_HISTORY_REPLAY = 15, 138 TEST_GUEST_HISTORY_REPLAY = 13,
139 TEST_GUEST_HISTORY_REPLAY_LATEST = 16, 139 TEST_GUEST_HISTORY_REPLAY_LATEST = 14,
140 TEST_GUEST_LOOK_AT = 17, 140 TEST_GUEST_LOOK_AT = 15,
141 TEST_GUEST_LOOK_FOR = 18, 141 TEST_GUEST_LOOK_FOR = 16,
142 TEST_GUEST_LEAVE = 18, 142 TEST_GUEST_LEAVE = 17,
143 TEST_ZONE_ADD_PLACE = 20, 143 TEST_ZONE_ADD_PLACE = 18,
144 TEST_GUEST_ENTER_BY_NAME = 21, 144 TEST_GUEST_ENTER_BY_NAME = 19,
145 TEST_RECONNECT = 22, 145 TEST_RECONNECT = 20,
146 TEST_GUEST_LEAVE2 = 23, 146 TEST_GUEST_LEAVE2 = 21,
147 TEST_HOST_LEAVE = 24, 147 TEST_HOST_LEAVE = 22,
148} test; 148} test;
149 149
150 150
@@ -180,10 +180,28 @@ host_announce2 ();
180 180
181 181
182/** 182/**
183 * Clean up all resources used. 183 * Terminate the test case (failure).
184 *
185 * @param cls NULL
186 */
187static void
188end_badly (void *cls)
189{
190 end_badly_task = NULL;
191 GNUNET_SCHEDULER_shutdown ();
192 res = 2;
193 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
194 "Test FAILED.\n");
195}
196
197
198/**
199 * Terminate the test case (failure).
200 *
201 * @param cls NULL
184 */ 202 */
185static void 203static void
186cleanup () 204end_shutdown (void *cls)
187{ 205{
188 if (NULL != id) 206 if (NULL != id)
189 { 207 {
@@ -202,7 +220,11 @@ cleanup ()
202 GNUNET_PSYC_slicer_destroy (host_slicer); 220 GNUNET_PSYC_slicer_destroy (host_slicer);
203 host_slicer = NULL; 221 host_slicer = NULL;
204 } 222 }
205 223 if (NULL != end_badly_task)
224 {
225 GNUNET_SCHEDULER_cancel (end_badly_task);
226 end_badly_task = NULL;
227 }
206 if (NULL != gst) 228 if (NULL != gst)
207 { 229 {
208 GNUNET_SOCIAL_guest_leave (gst, NULL, NULL, NULL); 230 GNUNET_SOCIAL_guest_leave (gst, NULL, NULL, NULL);
@@ -216,21 +238,6 @@ cleanup ()
216 hst_plc = NULL; 238 hst_plc = NULL;
217 } 239 }
218 GNUNET_SOCIAL_app_disconnect (app, NULL, NULL); 240 GNUNET_SOCIAL_app_disconnect (app, NULL, NULL);
219 GNUNET_SCHEDULER_shutdown ();
220}
221
222
223/**
224 * Terminate the test case (failure).
225 *
226 * @param cls NULL
227 */
228static void
229end_badly (void *cls)
230{
231 res = 1;
232 cleanup ();
233 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test FAILED.\n");
234} 241}
235 242
236 243
@@ -242,9 +249,9 @@ end_badly (void *cls)
242static void 249static void
243end_normally (void *cls) 250end_normally (void *cls)
244{ 251{
252 GNUNET_SCHEDULER_shutdown ();
245 res = 0; 253 res = 0;
246 cleanup (); 254 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Test PASSED.\n");
247 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test PASSED.\n");
248} 255}
249 256
250 257
@@ -254,7 +261,7 @@ end_normally (void *cls)
254static void 261static void
255end () 262end ()
256{ 263{
257 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 264 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
258 "Test #%u: Ending tests.\n", test); 265 "Test #%u: Ending tests.\n", test);
259 266
260 if (end_badly_task != NULL) 267 if (end_badly_task != NULL)
@@ -271,7 +278,7 @@ transmit_resume (void *cls)
271{ 278{
272 struct TransmitClosure *tmit = cls; 279 struct TransmitClosure *tmit = cls;
273 280
274 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 281 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
275 "Test #%u: Transmission resumed.\n", test); 282 "Test #%u: Transmission resumed.\n", test);
276 if (NULL != tmit->host_ann) 283 if (NULL != tmit->host_ann)
277 GNUNET_SOCIAL_host_announce_resume (tmit->host_ann); 284 GNUNET_SOCIAL_host_announce_resume (tmit->host_ann);
@@ -296,7 +303,7 @@ notify_data (void *cls, uint16_t *data_size, void *data)
296 } 303 }
297 304
298 uint16_t size = strlen (tmit->data[tmit->n]); 305 uint16_t size = strlen (tmit->data[tmit->n]);
299 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 306 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
300 "Test #%u: Transmit notify data: %u bytes available, " 307 "Test #%u: Transmit notify data: %u bytes available, "
301 "processing fragment %u/%u (size %u).\n", 308 "processing fragment %u/%u (size %u).\n",
302 test, *data_size, tmit->n + 1, tmit->data_count, size); 309 test, *data_size, tmit->n + 1, tmit->data_count, size);
@@ -309,7 +316,7 @@ notify_data (void *cls, uint16_t *data_size, void *data)
309 316
310 if (GNUNET_YES != tmit->paused && 0 < tmit->data_delay[tmit->n]) 317 if (GNUNET_YES != tmit->paused && 0 < tmit->data_delay[tmit->n])
311 { 318 {
312 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 319 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
313 "Test #%u: Transmission paused.\n", test); 320 "Test #%u: Transmission paused.\n", test);
314 tmit->paused = GNUNET_YES; 321 tmit->paused = GNUNET_YES;
315 GNUNET_SCHEDULER_add_delayed ( 322 GNUNET_SCHEDULER_add_delayed (
@@ -331,7 +338,7 @@ notify_data (void *cls, uint16_t *data_size, void *data)
331static void 338static void
332host_left () 339host_left ()
333{ 340{
334 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 341 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
335 "Test #%u: The host has left the place.\n", test); 342 "Test #%u: The host has left the place.\n", test);
336 end (); 343 end ();
337} 344}
@@ -352,7 +359,7 @@ host_farewell2 (void *cls,
352 const struct GNUNET_SOCIAL_Nym *nym, 359 const struct GNUNET_SOCIAL_Nym *nym,
353 struct GNUNET_PSYC_Environment *env) 360 struct GNUNET_PSYC_Environment *env)
354{ 361{
355 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 362 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
356 "Nym left the place again.\n"); 363 "Nym left the place again.\n");
357 GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL); 364 GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL);
358} 365}
@@ -365,13 +372,14 @@ host_reconnected (void *cls, int result,
365{ 372{
366 place_pub_key = *home_pub_key; 373 place_pub_key = *home_pub_key;
367 GNUNET_CRYPTO_hash (&place_pub_key, sizeof (place_pub_key), &place_pub_hash); 374 GNUNET_CRYPTO_hash (&place_pub_key, sizeof (place_pub_key), &place_pub_hash);
368 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 375 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
369 "Test #%u: Host reconnected to place %s\n", 376 "Test #%u: Host reconnected to place %s\n",
370 test, GNUNET_h2s (&place_pub_hash)); 377 test, GNUNET_h2s (&place_pub_hash));
371 378
372 is_host_reconnected = GNUNET_YES; 379 is_host_reconnected = GNUNET_YES;
373 if (GNUNET_YES == is_guest_reconnected) 380 if (GNUNET_YES == is_guest_reconnected)
374 { 381 {
382 GNUNET_assert (NULL != gst);
375 GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL); 383 GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL);
376 } 384 }
377} 385}
@@ -382,7 +390,7 @@ guest_reconnected (void *cls, int result,
382 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, 390 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
383 uint64_t max_message_id) 391 uint64_t max_message_id)
384{ 392{
385 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 393 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
386 "Test #%u: Guest reconnected to place: %d\n", 394 "Test #%u: Guest reconnected to place: %d\n",
387 test, result); 395 test, result);
388 GNUNET_assert (0 <= result); 396 GNUNET_assert (0 <= result);
@@ -390,6 +398,7 @@ guest_reconnected (void *cls, int result,
390 is_guest_reconnected = GNUNET_YES; 398 is_guest_reconnected = GNUNET_YES;
391 if (GNUNET_YES == is_host_reconnected) 399 if (GNUNET_YES == is_host_reconnected)
392 { 400 {
401 GNUNET_assert (NULL != gst);
393 GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL); 402 GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL);
394 } 403 }
395} 404}
@@ -398,7 +407,7 @@ guest_reconnected (void *cls, int result,
398static void 407static void
399app_connected (void *cls) 408app_connected (void *cls)
400{ 409{
401 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 410 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
402 "Test #%u: App connected: %p\n", test, cls); 411 "Test #%u: App connected: %p\n", test, cls);
403} 412}
404 413
@@ -411,21 +420,28 @@ app_recv_host (void *cls,
411 enum GNUNET_SOCIAL_AppPlaceState place_state) 420 enum GNUNET_SOCIAL_AppPlaceState place_state)
412{ 421{
413 struct GNUNET_HashCode host_pub_hash; 422 struct GNUNET_HashCode host_pub_hash;
414 GNUNET_CRYPTO_hash (host_pub_key, sizeof (*host_pub_key), &host_pub_hash);
415 423
416 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 424 GNUNET_CRYPTO_hash (host_pub_key,
425 sizeof (*host_pub_key),
426 &host_pub_hash);
427
428 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
417 "Test #%u: Got app host place notification: %s\n", 429 "Test #%u: Got app host place notification: %s\n",
418 test, GNUNET_h2s (&host_pub_hash)); 430 test,
431 GNUNET_h2s (&host_pub_hash));
419 432
420 if (test == TEST_RECONNECT) 433 if (test == TEST_RECONNECT)
421 { 434 {
422 if (0 == memcmp (&place_pub_key, host_pub_key, sizeof (*host_pub_key))) 435 if (0 == memcmp (&place_pub_key, host_pub_key, sizeof (*host_pub_key)))
423 { 436 {
424 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 437 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
425 "Test #%u: Reconnecting to host place: %s\n", 438 "Test #%u: Reconnecting to host place: %s\n",
426 test, GNUNET_h2s (&host_pub_hash)); 439 test, GNUNET_h2s (&host_pub_hash));
427 hst = GNUNET_SOCIAL_host_enter_reconnect (hconn, host_slicer, host_reconnected, 440 hst = GNUNET_SOCIAL_host_enter_reconnect (hconn, host_slicer,
428 host_answer_door, host_farewell2, NULL); 441 &host_reconnected,
442 &host_answer_door,
443 &host_farewell2,
444 NULL);
429 } 445 }
430 } 446 }
431} 447}
@@ -439,21 +455,30 @@ app_recv_guest (void *cls,
439 enum GNUNET_SOCIAL_AppPlaceState place_state) 455 enum GNUNET_SOCIAL_AppPlaceState place_state)
440{ 456{
441 struct GNUNET_HashCode guest_pub_hash; 457 struct GNUNET_HashCode guest_pub_hash;
442 GNUNET_CRYPTO_hash (guest_pub_key, sizeof (*guest_pub_key), &guest_pub_hash);
443 458
444 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 459 GNUNET_CRYPTO_hash (guest_pub_key,
460 sizeof (*guest_pub_key),
461 &guest_pub_hash);
462
463 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
445 "Test #%u: Got app guest place notification: %s\n", 464 "Test #%u: Got app guest place notification: %s\n",
446 test, GNUNET_h2s (&guest_pub_hash)); 465 test, GNUNET_h2s (&guest_pub_hash));
447 466
448 if (test == TEST_RECONNECT) 467 if (test == TEST_RECONNECT)
449 { 468 {
450 if (0 == memcmp (&place_pub_key, guest_pub_key, sizeof (*guest_pub_key))) 469 if (0 == memcmp (&place_pub_key,
470 guest_pub_key,
471 sizeof (*guest_pub_key)))
451 { 472 {
452 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 473 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
453 "Test #%u: Reconnecting to guest place: %s\n", 474 "Test #%u: Reconnecting to guest place: %s\n",
454 test, GNUNET_h2s (&guest_pub_hash)); 475 test, GNUNET_h2s (&guest_pub_hash));
455 gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn, GNUNET_PSYC_SLAVE_JOIN_NONE, 476 gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn,
456 guest_slicer, guest_reconnected, NULL); 477 GNUNET_PSYC_SLAVE_JOIN_NONE,
478 guest_slicer,
479 &guest_reconnected,
480 NULL);
481 GNUNET_assert (NULL != gst);
457 } 482 }
458 } 483 }
459} 484}
@@ -478,7 +503,7 @@ app_recv_ego (void *cls,
478 const char *name) 503 const char *name)
479{ 504{
480 char *ego_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (ego_pub_key); 505 char *ego_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (ego_pub_key);
481 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 506 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
482 "Test #%u: Got app ego notification: %p %s %s\n", 507 "Test #%u: Got app ego notification: %p %s %s\n",
483 test, ego, name, ego_pub_str); 508 test, ego, name, ego_pub_str);
484 GNUNET_free (ego_pub_str); 509 GNUNET_free (ego_pub_str);
@@ -487,15 +512,30 @@ app_recv_ego (void *cls,
487 { 512 {
488 host_ego = ego; 513 host_ego = ego;
489 host_pub_key = ego_pub_key; 514 host_pub_key = ego_pub_key;
490 GNUNET_assert (TEST_IDENTITIES_CREATE == test); 515 if (TEST_IDENTITIES_CREATE == test)
491 enter_if_ready (); 516 {
517 enter_if_ready ();
518 }
519 else
520 {
521 GNUNET_assert (TEST_RECONNECT == test);
522 }
492 } 523 }
493 else if (NULL != strstr (name, guest_name)) 524 else if (NULL != strstr (name, guest_name))
494 { 525 {
495 guest_ego = ego; 526 guest_ego = ego;
496 guest_pub_key = ego_pub_key; 527 guest_pub_key = ego_pub_key;
497 GNUNET_assert (TEST_IDENTITIES_CREATE == test); 528 if (TEST_IDENTITIES_CREATE == test)
498 enter_if_ready (); 529 {
530 enter_if_ready ();
531 }
532 else
533 {
534 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
535 "test = %d\n",
536 test);
537 GNUNET_assert (TEST_RECONNECT == test);
538 }
499 } 539 }
500} 540}
501 541
@@ -504,7 +544,6 @@ static void
504schedule_reconnect (void *cls) 544schedule_reconnect (void *cls)
505{ 545{
506 test = TEST_RECONNECT; 546 test = TEST_RECONNECT;
507
508 GNUNET_SOCIAL_host_disconnect (hst, NULL, NULL); 547 GNUNET_SOCIAL_host_disconnect (hst, NULL, NULL);
509 GNUNET_SOCIAL_guest_disconnect (gst, NULL, NULL); 548 GNUNET_SOCIAL_guest_disconnect (gst, NULL, NULL);
510 hst = NULL; 549 hst = NULL;
@@ -512,10 +551,10 @@ schedule_reconnect (void *cls)
512 551
513 GNUNET_SOCIAL_app_disconnect (app, NULL, NULL); 552 GNUNET_SOCIAL_app_disconnect (app, NULL, NULL);
514 app = GNUNET_SOCIAL_app_connect (cfg, app_id, 553 app = GNUNET_SOCIAL_app_connect (cfg, app_id,
515 app_recv_ego, 554 &app_recv_ego,
516 app_recv_host, 555 &app_recv_host,
517 app_recv_guest, 556 &app_recv_guest,
518 app_connected, 557 &app_connected,
519 NULL); 558 NULL);
520} 559}
521 560
@@ -524,7 +563,7 @@ static void
524host_recv_zone_add_place_result (void *cls, int64_t result, 563host_recv_zone_add_place_result (void *cls, int64_t result,
525 const void *data, uint16_t data_size) 564 const void *data, uint16_t data_size)
526{ 565{
527 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 566 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
528 "Test #%u: Zone add place result: %" PRId64 " (%.*s).\n", 567 "Test #%u: Zone add place result: %" PRId64 " (%.*s).\n",
529 test, result, data_size, (const char *) data); 568 test, result, data_size, (const char *) data);
530 GNUNET_assert (GNUNET_YES == result); 569 GNUNET_assert (GNUNET_YES == result);
@@ -538,7 +577,7 @@ static void
538zone_add_place () 577zone_add_place ()
539{ 578{
540 test = TEST_ZONE_ADD_PLACE; 579 test = TEST_ZONE_ADD_PLACE;
541 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 580 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
542 "Test #%u: Adding place to zone.\n", test); 581 "Test #%u: Adding place to zone.\n", test);
543 582
544 GNUNET_SOCIAL_zone_add_place (app, host_ego, "home", "let.me*in!", 583 GNUNET_SOCIAL_zone_add_place (app, host_ego, "home", "let.me*in!",
@@ -557,7 +596,7 @@ host_farewell (void *cls,
557 nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym); 596 nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym);
558 597
559 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key); 598 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
560 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 599 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
561 "Test #%u: Farewell: nym %s (%s) has left the place.\n", 600 "Test #%u: Farewell: nym %s (%s) has left the place.\n",
562 test, GNUNET_h2s (GNUNET_SOCIAL_nym_get_pub_key_hash (nym)), str); 601 test, GNUNET_h2s (GNUNET_SOCIAL_nym_get_pub_key_hash (nym)), str);
563 GNUNET_free (str); 602 GNUNET_free (str);
@@ -578,13 +617,13 @@ host_farewell (void *cls,
578static void 617static void
579guest_left (void *cls) 618guest_left (void *cls)
580{ 619{
581 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 620 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
582 "Test #%u: The guest has left the place.\n", test); 621 "Test #%u: The guest has left the place.\n", test);
583} 622}
584 623
585 624
586static void 625static void
587guest_leave() 626guest_leave ()
588{ 627{
589 if (test < TEST_RECONNECT) 628 if (test < TEST_RECONNECT)
590 test = TEST_GUEST_LEAVE; 629 test = TEST_GUEST_LEAVE;
@@ -615,11 +654,11 @@ guest_look_for_result (void *cls,
615 uint16_t data_size) 654 uint16_t data_size)
616{ 655{
617 struct ResultClosure *rcls = cls; 656 struct ResultClosure *rcls = cls;
618 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 657 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
619 "Test #%u: guest_look_for_result: %" PRId64 "\n", 658 "Test #%u: guest_look_for_result: %" PRId64 "\n",
620 test, result_code); 659 test, result_code);
621 GNUNET_assert (GNUNET_OK == result_code); 660 GNUNET_assert (GNUNET_OK == result_code);
622 GNUNET_assert (3 == rcls->n); 661 GNUNET_assert (6 == rcls->n);
623 GNUNET_free (rcls); 662 GNUNET_free (rcls);
624 GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL); 663 GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL);
625} 664}
@@ -635,7 +674,7 @@ guest_look_for_var (void *cls,
635{ 674{
636 struct ResultClosure *rcls = cls; 675 struct ResultClosure *rcls = cls;
637 rcls->n++; 676 rcls->n++;
638 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 677 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
639 "Test #%u: guest_look_for_var: %s\n%.*s\n", 678 "Test #%u: guest_look_for_var: %s\n%.*s\n",
640 test, name, value_size, (const char *) value); 679 test, name, value_size, (const char *) value);
641} 680}
@@ -656,7 +695,7 @@ guest_look_at_result (void *cls, int64_t result_code,
656{ 695{
657 struct ResultClosure *rcls = cls; 696 struct ResultClosure *rcls = cls;
658 697
659 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 698 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
660 "Test #%u: guest_look_at_result: %" PRId64 "\n", 699 "Test #%u: guest_look_at_result: %" PRId64 "\n",
661 test, result_code); 700 test, result_code);
662 GNUNET_assert (GNUNET_OK == result_code); 701 GNUNET_assert (GNUNET_OK == result_code);
@@ -677,7 +716,7 @@ guest_look_at_var (void *cls,
677 struct ResultClosure *rcls = cls; 716 struct ResultClosure *rcls = cls;
678 rcls->n++; 717 rcls->n++;
679 718
680 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 719 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
681 "Test #%u: guest_look_at_var: %s\n%.*s\n", 720 "Test #%u: guest_look_at_var: %s\n%.*s\n",
682 test ,name, value_size, (const char *) value); 721 test ,name, value_size, (const char *) value);
683} 722}
@@ -696,7 +735,7 @@ static void
696guest_recv_history_replay_latest_result (void *cls, int64_t result, 735guest_recv_history_replay_latest_result (void *cls, int64_t result,
697 const void *data, uint16_t data_size) 736 const void *data, uint16_t data_size)
698{ 737{
699 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 738 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
700 "Test #%u: Guest received latest history replay result " 739 "Test #%u: Guest received latest history replay result "
701 "(%" PRIu32 " messages, %" PRId64 " fragments):\n" 740 "(%" PRIu32 " messages, %" PRId64 " fragments):\n"
702 "%.*s\n", 741 "%.*s\n",
@@ -725,7 +764,7 @@ static void
725guest_recv_history_replay_result (void *cls, int64_t result, 764guest_recv_history_replay_result (void *cls, int64_t result,
726 const void *data, uint16_t data_size) 765 const void *data, uint16_t data_size)
727{ 766{
728 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 767 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
729 "Test #%u: Guest received history replay result: %" PRId64 "\n" 768 "Test #%u: Guest received history replay result: %" PRId64 "\n"
730 "%.*s\n", 769 "%.*s\n",
731 test, result, data_size, (const char *) data); 770 test, result, data_size, (const char *) data);
@@ -756,7 +795,7 @@ guest_recv_method (void *cls,
756 uint64_t message_id, 795 uint64_t message_id,
757 const char *method_name) 796 const char *method_name)
758{ 797{
759 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 798 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
760 "Test #%u: Guest received method for message ID %" PRIu64 ":\n" 799 "Test #%u: Guest received method for message ID %" PRIu64 ":\n"
761 "%s (flags: %x)\n", 800 "%s (flags: %x)\n",
762 test, message_id, method_name, ntohl (meth->flags)); 801 test, message_id, method_name, ntohl (meth->flags));
@@ -775,7 +814,7 @@ guest_recv_modifier (void *cls,
775 uint16_t value_size, 814 uint16_t value_size,
776 uint16_t full_value_size) 815 uint16_t full_value_size)
777{ 816{
778 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 817 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
779 "Test #%u: Guest received modifier for message ID %" PRIu64 ":\n" 818 "Test #%u: Guest received modifier for message ID %" PRIu64 ":\n"
780 "%c%s: %.*s (size: %u)\n", 819 "%c%s: %.*s (size: %u)\n",
781 test, message_id, oper, name, value_size, (const char *) value, value_size); 820 test, message_id, oper, name, value_size, (const char *) value, value_size);
@@ -793,7 +832,7 @@ guest_recv_mod_foo_bar (void *cls,
793 uint16_t value_size, 832 uint16_t value_size,
794 uint16_t full_value_size) 833 uint16_t full_value_size)
795{ 834{
796 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 835 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
797 "Test #%u: Guest received modifier matching _foo_bar for message ID %" PRIu64 ":\n" 836 "Test #%u: Guest received modifier matching _foo_bar for message ID %" PRIu64 ":\n"
798 "%c%s: %.*s (size: %u)\n", 837 "%c%s: %.*s (size: %u)\n",
799 test, message_id, oper, name, value_size, (const char *) value, value_size); 838 test, message_id, oper, name, value_size, (const char *) value, value_size);
@@ -811,7 +850,7 @@ guest_recv_data (void *cls,
811 const void *data, 850 const void *data,
812 uint16_t data_size) 851 uint16_t data_size)
813{ 852{
814 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 853 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
815 "Test #%u: Guest received data for message ID %" PRIu64 ":\n" 854 "Test #%u: Guest received data for message ID %" PRIu64 ":\n"
816 "%.*s\n", 855 "%.*s\n",
817 test, message_id, data_size, (const char *) data); 856 test, message_id, data_size, (const char *) data);
@@ -826,7 +865,7 @@ guest_recv_eom (void *cls,
826 uint64_t message_id, 865 uint64_t message_id,
827 uint8_t is_cancelled) 866 uint8_t is_cancelled)
828{ 867{
829 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 868 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
830 "Test #%u: Guest received end of message ID %" PRIu64 869 "Test #%u: Guest received end of message ID %" PRIu64
831 ", cancelled: %u\n", 870 ", cancelled: %u\n",
832 test, message_id, is_cancelled); 871 test, message_id, is_cancelled);
@@ -868,7 +907,7 @@ host_recv_method (void *cls,
868 uint64_t message_id, 907 uint64_t message_id,
869 const char *method_name) 908 const char *method_name)
870{ 909{
871 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 910 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
872 "Test #%u: Host received method for message ID %" PRIu64 ":\n" 911 "Test #%u: Host received method for message ID %" PRIu64 ":\n"
873 "%s\n", 912 "%s\n",
874 test, message_id, method_name); 913 test, message_id, method_name);
@@ -887,7 +926,7 @@ host_recv_modifier (void *cls,
887 uint16_t value_size, 926 uint16_t value_size,
888 uint16_t full_value_size) 927 uint16_t full_value_size)
889{ 928{
890 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 929 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
891 "Test #%u: Host received modifier for message ID %" PRIu64 ":\n" 930 "Test #%u: Host received modifier for message ID %" PRIu64 ":\n"
892 "%c%s: %.*s\n", 931 "%c%s: %.*s\n",
893 test, message_id, oper, name, value_size, (const char *) value); 932 test, message_id, oper, name, value_size, (const char *) value);
@@ -902,7 +941,7 @@ host_recv_data (void *cls,
902 const void *data, 941 const void *data,
903 uint16_t data_size) 942 uint16_t data_size)
904{ 943{
905 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 944 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
906 "Test #%u: Host received data for message ID %" PRIu64 ":\n" 945 "Test #%u: Host received data for message ID %" PRIu64 ":\n"
907 "%.*s\n", 946 "%.*s\n",
908 test, message_id, data_size, (const char *) data); 947 test, message_id, data_size, (const char *) data);
@@ -916,7 +955,7 @@ host_recv_eom (void *cls,
916 uint64_t message_id, 955 uint64_t message_id,
917 uint8_t is_cancelled) 956 uint8_t is_cancelled)
918{ 957{
919 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 958 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
920 "Test #%u: Host received end of message ID %" PRIu64 959 "Test #%u: Host received end of message ID %" PRIu64
921 ", cancelled: %u\n", 960 ", cancelled: %u\n",
922 test, message_id, is_cancelled); 961 test, message_id, is_cancelled);
@@ -981,7 +1020,7 @@ host_announce ()
981{ 1020{
982 test = TEST_HOST_ANNOUNCE; 1021 test = TEST_HOST_ANNOUNCE;
983 1022
984 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1023 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
985 "Test #%u: Host announcement.\n", test); 1024 "Test #%u: Host announcement.\n", test);
986 1025
987 tmit = (struct TransmitClosure) {}; 1026 tmit = (struct TransmitClosure) {};
@@ -1015,7 +1054,7 @@ host_announce2 ()
1015 1054
1016 test = TEST_HOST_ANNOUNCE2; 1055 test = TEST_HOST_ANNOUNCE2;
1017 1056
1018 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1057 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1019 "Test #%u: Host announcement 2.\n", test); 1058 "Test #%u: Host announcement 2.\n", test);
1020 1059
1021 tmit = (struct TransmitClosure) {}; 1060 tmit = (struct TransmitClosure) {};
@@ -1025,7 +1064,7 @@ host_announce2 ()
1025 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN, 1064 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
1026 "_foo2_bar", DATA2ARG ("FOO BAR")); 1065 "_foo2_bar", DATA2ARG ("FOO BAR"));
1027 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN, 1066 GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN,
1028 "_foo2_bar", DATA2ARG ("FOO BAR BAZ")); 1067 "_foo2_bar_baz", DATA2ARG ("FOO BAR BAZ"));
1029 tmit.data[0] = "AAA BBB CCC "; 1068 tmit.data[0] = "AAA BBB CCC ";
1030 tmit.data[1] = "ABC DEF GHI JKL.\n"; 1069 tmit.data[1] = "ABC DEF GHI JKL.\n";
1031 tmit.data[2] = "TESTING ONE TWO THREE.\n"; 1070 tmit.data[2] = "TESTING ONE TWO THREE.\n";
@@ -1043,7 +1082,7 @@ guest_recv_entry_decision (void *cls,
1043 int is_admitted, 1082 int is_admitted,
1044 const struct GNUNET_PSYC_Message *entry_msg) 1083 const struct GNUNET_PSYC_Message *entry_msg)
1045{ 1084{
1046 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1085 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1047 "Test #%u: Guest received entry decision (try %u): %d.\n", 1086 "Test #%u: Guest received entry decision (try %u): %d.\n",
1048 test, join_req_count, is_admitted); 1087 test, join_req_count, is_admitted);
1049 1088
@@ -1068,7 +1107,8 @@ guest_recv_entry_decision (void *cls,
1068 { 1107 {
1069 case TEST_GUEST_RECV_ENTRY_DCSN_REFUSE: 1108 case TEST_GUEST_RECV_ENTRY_DCSN_REFUSE:
1070 GNUNET_assert (GNUNET_NO == is_admitted); 1109 GNUNET_assert (GNUNET_NO == is_admitted);
1071 guest_enter (); 1110 test = TEST_HOST_ANSWER_DOOR_ADMIT;
1111 GNUNET_SOCIAL_guest_disconnect (gst, &guest_enter, NULL);
1072 break; 1112 break;
1073 1113
1074 case TEST_GUEST_RECV_ENTRY_DCSN_ADMIT: 1114 case TEST_GUEST_RECV_ENTRY_DCSN_ADMIT:
@@ -1097,7 +1137,7 @@ host_answer_door (void *cls,
1097{ 1137{
1098 join_req_count++; 1138 join_req_count++;
1099 1139
1100 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1140 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1101 "Test #%u: Host received entry request from guest (try %u).\n", 1141 "Test #%u: Host received entry request from guest (try %u).\n",
1102 (uint8_t) test, join_req_count); 1142 (uint8_t) test, join_req_count);
1103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1143 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1118,7 +1158,7 @@ host_answer_door (void *cls,
1118 // fall through 1158 // fall through
1119 1159
1120 case TEST_GUEST_ENTER_BY_NAME: 1160 case TEST_GUEST_ENTER_BY_NAME:
1121 join_resp = GNUNET_PSYC_message_create ("_notice_place_admit", env, 1161 join_resp = GNUNET_PSYC_message_create ("_notice_place_admit", env,
1122 DATA2ARG ("Welcome, nym!")); 1162 DATA2ARG ("Welcome, nym!"));
1123 GNUNET_SOCIAL_host_entry_decision (hst, nym, GNUNET_YES, join_resp); 1163 GNUNET_SOCIAL_host_entry_decision (hst, nym, GNUNET_YES, join_resp);
1124 break; 1164 break;
@@ -1135,18 +1175,18 @@ guest_recv_local_enter (void *cls, int result,
1135 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, 1175 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
1136 uint64_t max_message_id) 1176 uint64_t max_message_id)
1137{ 1177{
1138 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1178 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1139 "Test #%u: Guest entered to local place: %d\n", 1179 "Test #%u: Guest entered local place: %d\n",
1140 test, result); 1180 test, result);
1141 GNUNET_assert (0 <= result); 1181 GNUNET_assert (GNUNET_OK == result);
1142} 1182}
1143 1183
1144 1184
1145static void 1185static void
1146guest_enter () 1186guest_enter ()
1147{ 1187{
1148 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1188 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1149 "Test #%u: Entering to place as guest.\n", test); 1189 "Test #%u: Entering place as guest.\n", test);
1150 1190
1151 struct GuestEnterMessage *emsg = &guest_enter_msg; 1191 struct GuestEnterMessage *emsg = &guest_enter_msg;
1152 1192
@@ -1177,8 +1217,8 @@ static void
1177guest_enter_by_name () 1217guest_enter_by_name ()
1178{ 1218{
1179 test = TEST_GUEST_ENTER_BY_NAME; 1219 test = TEST_GUEST_ENTER_BY_NAME;
1180 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1220 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1181 "Test #%u: Entering to place by name as guest.\n", test); 1221 "Test #%u: Entering place by name as guest.\n", test);
1182 1222
1183 struct GuestEnterMessage *emsg = &guest_enter_msg; 1223 struct GuestEnterMessage *emsg = &guest_enter_msg;
1184 1224
@@ -1222,7 +1262,7 @@ guest_init ()
1222 guest_recv_data, guest_recv_eom, NULL); 1262 guest_recv_data, guest_recv_eom, NULL);
1223 GNUNET_PSYC_slicer_modifier_add (guest_slicer, "_foo_bar", 1263 GNUNET_PSYC_slicer_modifier_add (guest_slicer, "_foo_bar",
1224 guest_recv_mod_foo_bar, &mod_foo_bar_rcls); 1264 guest_recv_mod_foo_bar, &mod_foo_bar_rcls);
1225 test = TEST_HOST_ANSWER_DOOR_ADMIT; 1265 test = TEST_HOST_ANSWER_DOOR_REFUSE;
1226 1266
1227 GNUNET_SOCIAL_zone_add_nym (app, guest_ego, "host", host_pub_key, 1267 GNUNET_SOCIAL_zone_add_nym (app, guest_ego, "host", host_pub_key,
1228 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES), 1268 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES),
@@ -1270,8 +1310,8 @@ host_entered (void *cls, int result,
1270{ 1310{
1271 place_pub_key = *home_pub_key; 1311 place_pub_key = *home_pub_key;
1272 GNUNET_CRYPTO_hash (&place_pub_key, sizeof (place_pub_key), &place_pub_hash); 1312 GNUNET_CRYPTO_hash (&place_pub_key, sizeof (place_pub_key), &place_pub_hash);
1273 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1313 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1274 "Test #%u: Host entered to place %s\n", 1314 "Test #%u: Host entered place %s\n",
1275 test, GNUNET_h2s (&place_pub_hash)); 1315 test, GNUNET_h2s (&place_pub_hash));
1276 guest_enter (); 1316 guest_enter ();
1277} 1317}
@@ -1285,8 +1325,8 @@ host_enter ()
1285 host_recv_method, host_recv_modifier, 1325 host_recv_method, host_recv_modifier,
1286 host_recv_data, host_recv_eom, NULL); 1326 host_recv_data, host_recv_eom, NULL);
1287 1327
1288 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1328 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1289 "Test #%u: Entering to place as host.\n", test); 1329 "Test #%u: Entering place as host.\n", test);
1290 test = TEST_HOST_ENTER; 1330 test = TEST_HOST_ENTER;
1291 hst = GNUNET_SOCIAL_host_enter (app, host_ego, 1331 hst = GNUNET_SOCIAL_host_enter (app, host_ego,
1292 GNUNET_PSYC_CHANNEL_PRIVATE, 1332 GNUNET_PSYC_CHANNEL_PRIVATE,
@@ -1306,6 +1346,8 @@ start_app_if_ready ()
1306 { 1346 {
1307 return; 1347 return;
1308 } 1348 }
1349 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1350 "starting app...\n");
1309 app = GNUNET_SOCIAL_app_connect (cfg, 1351 app = GNUNET_SOCIAL_app_connect (cfg,
1310 app_id, 1352 app_id,
1311 app_recv_ego, 1353 app_recv_ego,
@@ -1324,17 +1366,17 @@ identity_ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego,
1324 { 1366 {
1325 if (ego == identity_host_ego) 1367 if (ego == identity_host_ego)
1326 { 1368 {
1327 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1369 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1328 "Host ego deleted\n"); 1370 "Host ego deleted\n");
1329 } 1371 }
1330 else if (ego == identity_guest_ego) 1372 else if (ego == identity_guest_ego)
1331 { 1373 {
1332 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1374 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1333 "Guest ego deleted\n"); 1375 "Guest ego deleted\n");
1334 } 1376 }
1335 else if (0 == strcmp (name, host_name)) 1377 else if (0 == strcmp (name, host_name))
1336 { 1378 {
1337 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1379 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1338 "Created ego %s\n", 1380 "Created ego %s\n",
1339 name); 1381 name);
1340 identity_host_ego = ego; 1382 identity_host_ego = ego;
@@ -1342,7 +1384,7 @@ identity_ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego,
1342 } 1384 }
1343 else if (0 == strcmp (name, guest_name)) 1385 else if (0 == strcmp (name, guest_name))
1344 { 1386 {
1345 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1387 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
1346 "Created guest ego %s\n", 1388 "Created guest ego %s\n",
1347 name); 1389 name);
1348 identity_guest_ego = ego; 1390 identity_guest_ego = ego;
@@ -1370,9 +1412,11 @@ run (void *cls,
1370#endif 1412#endif
1371{ 1413{
1372 cfg = c; 1414 cfg = c;
1415 res = 1;
1373 end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 1416 end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
1374 &end_badly, NULL); 1417 &end_badly, NULL);
1375 1418 GNUNET_SCHEDULER_add_shutdown (&end_shutdown,
1419 NULL);
1376 GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); 1420 GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer);
1377 1421
1378 id = GNUNET_IDENTITY_connect (cfg, &identity_ego_cb, NULL); 1422 id = GNUNET_IDENTITY_connect (cfg, &identity_ego_cb, NULL);
diff --git a/src/social/test_social.conf b/src/social/test_social.conf
index e69de29bb..7cf858b1c 100644
--- a/src/social/test_social.conf
+++ b/src/social/test_social.conf
@@ -0,0 +1,19 @@
1@INLINE@ ../../contrib/no_forcestart.conf
2
3[PATHS]
4GNUNET_TEST_HOME = /tmp/gnunet-test-social/
5
6[social]
7FORCESTART = YES
8
9[transport]
10PLUGINS = tcp
11
12[nat]
13DISABLEV6 = YES
14ENABLE_UPNP = NO
15BEHIND_NAT = NO
16ALLOW_NAT = NO
17INTERNAL_ADDRESS = 127.0.0.1
18EXTERNAL_ADDRESS = 127.0.0.1
19