From: lurchi Date: Fri, 13 Oct 2017 17:25:45 +0000 (+0200) Subject: trying to fix test_social and social service with a lot of debug outputs X-Git-Tag: gnunet-0.11.0rc0~48^2~1^2~48 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6d067bc953382bc09712810604747b3ea37b97ec;p=oweals%2Fgnunet.git trying to fix test_social and social service with a lot of debug outputs --- diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index dee68fdb8..30e113f18 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; * Application subscriptions per place. * H(place_pub_key) -> H(app_id) */ -static struct GNUNET_CONTAINER_MultiHashMap *places_apps; +//static struct GNUNET_CONTAINER_MultiHashMap *places_apps; /** * Connected applications. @@ -501,6 +501,9 @@ cleanup_host (struct Host *hst) static void cleanup_guest (struct Guest *gst) { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "cleanup_guest, gst = %p\n", + gst); struct Place *plc = &gst->place; struct GNUNET_CONTAINER_MultiHashMap * plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, @@ -536,7 +539,7 @@ cleanup_place (void *cls) { struct Place *plc = cls; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%p Cleaning up place %s\n", plc, GNUNET_h2s (&plc->pub_key_hash)); @@ -1173,7 +1176,11 @@ app_place_add (const char *app_id, return GNUNET_NO; if (GNUNET_SYSERR == place_add (ereq)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "could not add place\n"); return GNUNET_SYSERR; + } if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (app_places, &ego_place_pub_hash, NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) @@ -1182,30 +1189,30 @@ app_place_add (const char *app_id, return GNUNET_SYSERR; } - struct GNUNET_HashCode place_pub_hash; - GNUNET_CRYPTO_hash (&ereq->place_pub_key, sizeof (ereq->place_pub_key), &place_pub_hash); + //struct GNUNET_HashCode place_pub_hash; + //GNUNET_CRYPTO_hash (&ereq->place_pub_key, sizeof (ereq->place_pub_key), &place_pub_hash); - struct GNUNET_CONTAINER_MultiHashMap * - place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); - if (NULL == place_apps) - { - place_apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); - if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (places_apps, &place_pub_hash, place_apps, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) - { - GNUNET_break (0); - } - } + //struct GNUNET_CONTAINER_MultiHashMap * + // place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); + //if (NULL == place_apps) + //{ + // place_apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); + // if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (places_apps, &place_pub_hash, place_apps, + // GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) + // { + // GNUNET_break (0); + // } + //} - size_t app_id_size = strlen (app_id) + 1; - void *app_id_value = GNUNET_malloc (app_id_size); - GNUNET_memcpy (app_id_value, app_id, app_id_size); + //size_t app_id_size = strlen (app_id) + 1; + //void *app_id_value = GNUNET_malloc (app_id_size); + //GNUNET_memcpy (app_id_value, app_id, app_id_size); - if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (place_apps, &app_id_hash, app_id_value, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) - { - GNUNET_break (0); - } + //if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (place_apps, &app_id_hash, app_id_value, + // GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) + //{ + // GNUNET_break (0); + //} return GNUNET_OK; } @@ -1223,7 +1230,10 @@ static int app_place_save (const char *app_id, const struct PlaceEnterRequest *ereq) { - app_place_add (app_id, ereq); + if (GNUNET_SYSERR == app_place_add (app_id, ereq)) + { + GNUNET_assert (0); + } if (NULL == dir_places) return GNUNET_SYSERR; @@ -1304,17 +1314,17 @@ app_place_remove (const char *app_id, if (NULL != app_places) GNUNET_CONTAINER_multihashmap_remove (app_places, &place_pub_hash, NULL); - struct GNUNET_CONTAINER_MultiHashMap * - place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); - if (NULL != place_apps) - { - void *app_id_value = GNUNET_CONTAINER_multihashmap_get (place_apps, &app_id_hash); - if (NULL != app_id_value) - { - GNUNET_CONTAINER_multihashmap_remove (place_apps, &app_id_hash, app_id_value); - GNUNET_free (app_id_value); - } - } + //struct GNUNET_CONTAINER_MultiHashMap * + // place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); + //if (NULL != place_apps) + //{ + // void *app_id_value = GNUNET_CONTAINER_multihashmap_get (place_apps, &app_id_hash); + // if (NULL != app_id_value) + // { + // GNUNET_CONTAINER_multihashmap_remove (place_apps, &app_id_hash, app_id_value); + // GNUNET_free (app_id_value); + // } + //} int ret = GNUNET_OK; @@ -1407,6 +1417,120 @@ msg_proc_parse (const struct MsgProcRequest *mpreq, } +void +app_notify_place (const struct GNUNET_MessageHeader *msg, + struct GNUNET_SERVICE_Client *client) +{ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "%p Sending place notification of type %u to client.\n", + client, ntohs (msg->type)); + + uint16_t msg_size = ntohs (msg->size); + struct AppPlaceMessage amsg; + amsg.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); + amsg.header.size = htons (sizeof (amsg)); + // FIXME: also notify about not entered places + amsg.place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; + + switch (ntohs (msg->type)) + { + case GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER: + if (msg_size < sizeof (struct HostEnterRequest)) + return; + struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg; + amsg.is_host = GNUNET_YES; + amsg.ego_pub_key = hreq->ego_pub_key; + amsg.place_pub_key = hreq->place_pub_key; + break; + + case GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER: + if (msg_size < sizeof (struct GuestEnterRequest)) + return; + struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg; + amsg.is_host = GNUNET_NO; + amsg.ego_pub_key = greq->ego_pub_key; + amsg.place_pub_key = greq->place_pub_key; + break; + + default: + return; + } + + client_send_msg (client, &amsg.header); +} + + +void +app_notify_place_end (struct GNUNET_SERVICE_Client *client) +{ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "%p Sending end of place list notification to client\n", + client); + + struct GNUNET_MessageHeader msg; + msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END); + msg.size = htons (sizeof (msg)); + + client_send_msg (client, &msg); +} + + +void +app_notify_ego (struct Ego *ego, struct GNUNET_SERVICE_Client *client) +{ + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "%p Sending ego notification to client: %s\n", + client, ego->name); + + size_t name_size = strlen (ego->name) + 1; + struct AppEgoMessage *emsg = GNUNET_malloc (sizeof (*emsg) + name_size); + emsg->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO); + emsg->header.size = htons (sizeof (*emsg) + name_size); + + GNUNET_CRYPTO_ecdsa_key_get_public (&ego->key, &emsg->ego_pub_key); + GNUNET_memcpy (&emsg[1], ego->name, name_size); + + client_send_msg (client, &emsg->header); + GNUNET_free (emsg); +} + + +void +app_notify_ego_end (struct GNUNET_SERVICE_Client *client) +{ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "%p Sending end of ego list notification to client\n", + client); + + struct GNUNET_MessageHeader msg; + msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END); + msg.size = htons (sizeof (msg)); + + client_send_msg (client, &msg); +} + + +int +app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value) +{ + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "app_place_entry_notify\n"); + struct GNUNET_MessageHeader * + msg = GNUNET_CONTAINER_multihashmap_get (places, key); + if (NULL != msg) + app_notify_place (msg, cls); + return GNUNET_YES; +} + + +int +ego_entry (void *cls, const struct GNUNET_HashCode *key, void *value) +{ + app_notify_ego (value, cls); + return GNUNET_YES; +} + + static int check_client_msg_proc_set (void *cls, const struct MsgProcRequest *mpreq) @@ -1518,12 +1642,15 @@ static void handle_client_host_enter (void *cls, const struct HostEnterRequest *hr) { - struct Client *c = cls; + struct Client *c = cls; struct GNUNET_SERVICE_Client *client = c->client; struct HostEnterRequest * hreq = (struct HostEnterRequest *) GNUNET_copy_message (&hr->header); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "handle_client_host_enter\n"); + uint8_t app_id_size = ntohs (hreq->header.size) - sizeof (*hreq); const char *app_id = NULL; uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &hreq[1], @@ -1586,6 +1713,7 @@ handle_client_host_enter (void *cls, cli->client = client; GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli); c->place = plc; + app_notify_place (&hreq->header, client); } GNUNET_CRYPTO_eddsa_key_clear (&hreq->place_key); @@ -1622,7 +1750,11 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash); if (NULL == ego) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "NULL == ego\n"); return GNUNET_SYSERR; + } struct GNUNET_HashCode place_pub_hash; GNUNET_CRYPTO_hash (&greq->place_pub_key, sizeof (greq->place_pub_key), @@ -1635,6 +1767,10 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) if (NULL != plc_gst) gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "guest enter, gst = %p\n", + gst); + if (NULL == gst || NULL == gst->slave) { gst = GNUNET_new (struct Guest); @@ -1672,6 +1808,9 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) struct GNUNET_PSYC_Message *join_msg = NULL; uint16_t join_msg_size = 0; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "guest_enter 2\n"); + if (sizeof (struct GNUNET_MessageHeader) <= remaining) { join_msg = (struct GNUNET_PSYC_Message *) p; @@ -1711,10 +1850,15 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); } + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Adding guest %p\n", + gst); (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "GNUNET_PSYC_slave_join\n"); gst->slave = GNUNET_PSYC_slave_join (cfg, &plc->pub_key, &plc->ego_key, gst->join_flags, &gst->origin, @@ -1748,9 +1892,14 @@ static void handle_client_guest_enter (void *cls, const struct GuestEnterRequest *greq) { + // FIXME: this must not be called directly by gns_result_guest_enter because then + // GNUNET_SERVICE_client_continue is called twice struct Client *c = cls; struct GNUNET_SERVICE_Client *client = c->client; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "handle_client_guest_enter\n"); + uint16_t remaining = ntohs (greq->header.size) - sizeof (*greq); const char *app_id = NULL; uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &greq[1], @@ -1771,6 +1920,7 @@ handle_client_guest_enter (void *cls, plc = c->place = &gst->place; plc->guest = gst; app_place_save (app_id, (const struct PlaceEnterRequest *) greq); + app_notify_place (&greq->header, client); break; case GNUNET_NO: @@ -1960,118 +2110,7 @@ handle_client_guest_enter_by_name (void *cls, GNUNET_GNSRECORD_TYPE_PLACE, GNUNET_GNS_LO_DEFAULT, &gns_result_guest_enter, gcls); -} - - -void -app_notify_place (struct GNUNET_MessageHeader *msg, - struct GNUNET_SERVICE_Client *client) -{ - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p Sending place notification of type %u to client.\n", - client, ntohs (msg->type)); - - uint16_t msg_size = ntohs (msg->size); - struct AppPlaceMessage amsg; - amsg.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); - amsg.header.size = htons (sizeof (amsg)); - // FIXME: also notify about not entered places - amsg.place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; - - switch (ntohs (msg->type)) - { - case GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER: - if (msg_size < sizeof (struct HostEnterRequest)) - return; - struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg; - amsg.is_host = GNUNET_YES; - amsg.ego_pub_key = hreq->ego_pub_key; - amsg.place_pub_key = hreq->place_pub_key; - break; - - case GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER: - if (msg_size < sizeof (struct GuestEnterRequest)) - return; - struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg; - amsg.is_host = GNUNET_NO; - amsg.ego_pub_key = greq->ego_pub_key; - amsg.place_pub_key = greq->place_pub_key; - break; - - default: - return; - } - - client_send_msg (client, &amsg.header); -} - - -void -app_notify_place_end (struct GNUNET_SERVICE_Client *client) -{ - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p Sending end of place list notification to client\n", - client); - - struct GNUNET_MessageHeader msg; - msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END); - msg.size = htons (sizeof (msg)); - - client_send_msg (client, &msg); -} - - -void -app_notify_ego (struct Ego *ego, struct GNUNET_SERVICE_Client *client) -{ - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p Sending ego notification to client: %s\n", - client, ego->name); - - size_t name_size = strlen (ego->name) + 1; - struct AppEgoMessage *emsg = GNUNET_malloc (sizeof (*emsg) + name_size); - emsg->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO); - emsg->header.size = htons (sizeof (*emsg) + name_size); - - GNUNET_CRYPTO_ecdsa_key_get_public (&ego->key, &emsg->ego_pub_key); - GNUNET_memcpy (&emsg[1], ego->name, name_size); - - client_send_msg (client, &emsg->header); - GNUNET_free (emsg); -} - - -void -app_notify_ego_end (struct GNUNET_SERVICE_Client *client) -{ - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%p Sending end of ego list notification to client\n", - client); - - struct GNUNET_MessageHeader msg; - msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END); - msg.size = htons (sizeof (msg)); - - client_send_msg (client, &msg); -} - - -int -app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value) -{ - struct GNUNET_MessageHeader * - msg = GNUNET_CONTAINER_multihashmap_get (places, key); - if (NULL != msg) - app_notify_place (msg, cls); - return GNUNET_YES; -} - - -int -ego_entry (void *cls, const struct GNUNET_HashCode *key, void *value) -{ - app_notify_ego (value, cls); - return GNUNET_YES; + GNUNET_SERVICE_client_continue (client); } @@ -2107,6 +2146,8 @@ handle_client_app_connect (void *cls, struct GNUNET_HashCode app_id_hash; GNUNET_CRYPTO_hash (app_id, app_id_size, &app_id_hash); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "iterating egos\n"); GNUNET_CONTAINER_multihashmap_iterate (egos, ego_entry, client); app_notify_ego_end (client); @@ -2174,6 +2215,10 @@ handle_client_place_leave (void *cls, struct Client *c = cls; struct GNUNET_SERVICE_Client *client = c->client; struct Place *plc = c->place; + + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "handle_client_place_leave\n"); + if (NULL == plc) { GNUNET_break (0); @@ -2183,12 +2228,12 @@ handle_client_place_leave (void *cls, /* FIXME: remove all app subscriptions and leave this place */ - struct GNUNET_CONTAINER_MultiHashMap * - place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &plc->pub_key_hash); - if (NULL != place_apps) - { - GNUNET_CONTAINER_multihashmap_iterate (place_apps, app_places_entry_remove, plc); - } + //struct GNUNET_CONTAINER_MultiHashMap * + // place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &plc->pub_key_hash); + //if (NULL != place_apps) + //{ + // GNUNET_CONTAINER_multihashmap_iterate (place_apps, app_places_entry_remove, plc); + //} /* FIXME: disconnect from the network, but keep local connection for history access */ @@ -2215,6 +2260,7 @@ handle_client_place_leave (void *cls, cleanup_place (plc); } } + //GNUNET_SERVICE_client_continue (client); } @@ -3237,6 +3283,8 @@ namestore_recv_records_store_result (void *cls, int32_t result, struct OperationClosure *opcls = cls; struct Client *c = opcls->client; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "namestore_recv_records_store_result\n"); // FIXME: client might have been disconnected client_send_result (c->client, opcls->op_id, result, err_msg, (NULL != err_msg) ? strlen (err_msg) : 0); @@ -3468,7 +3516,10 @@ file_place_load (void *cls, const char *place_filename) return GNUNET_OK; } - app_place_add (plcls->app_id, ereq); + if (GNUNET_SYSERR == app_place_add (plcls->app_id, ereq)) + { + GNUNET_assert (0); + } GNUNET_free (ereq); return GNUNET_OK; } @@ -3523,6 +3574,10 @@ identity_recv_ego (void *cls, struct GNUNET_IDENTITY_Ego *id_ego, if (NULL == id_ego) // end of initial list of egos return; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "social service received ego %s\n", + name); + struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key; GNUNET_IDENTITY_ego_get_public_key (id_ego, &ego_pub_key); @@ -3571,6 +3626,9 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *svc) { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "starting social service\n"); + cfg = c; service = svc; GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); @@ -3583,7 +3641,7 @@ run (void *cls, apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); apps_places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); - places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); + //places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); id = GNUNET_IDENTITY_connect (cfg, &identity_recv_ego, NULL); gns = GNUNET_GNS_connect (cfg); diff --git a/src/social/social_api.c b/src/social/social_api.c index af1d6e57e..04b671120 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c @@ -818,6 +818,9 @@ handle_host_enter_request (void *cls, { struct GNUNET_SOCIAL_Host *hst = cls; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "handle_host_enter_request\n"); + if (NULL == hst->answer_door_cb) return; @@ -1042,7 +1045,7 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc) { struct GNUNET_HashCode place_pub_hash; GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s place cleanup: %s\n", GNUNET_YES == plc->is_host ? "host" : "guest", GNUNET_h2s (&place_pub_hash)); @@ -1075,19 +1078,17 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc) void -place_disconnect (struct GNUNET_SOCIAL_Place *plc, - GNUNET_ContinuationCallback cb, - void *cls) +place_disconnect (struct GNUNET_SOCIAL_Place *plc) { - plc->disconnect_cb = cb; - plc->disconnect_cls = cls; - + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "place_disconnect, plc = %p\n", + plc); if (NULL != plc->mq) { struct GNUNET_MQ_Envelope *env = GNUNET_MQ_get_last_envelope (plc->mq); if (NULL != env) { - GNUNET_MQ_notify_sent (env, (GNUNET_SCHEDULER_TaskCallback) place_cleanup, plc); + GNUNET_MQ_notify_sent (env, (GNUNET_SCHEDULER_TaskCallback) place_disconnect, plc); } else { @@ -1104,6 +1105,8 @@ place_disconnect (struct GNUNET_SOCIAL_Place *plc, void place_leave (struct GNUNET_SOCIAL_Place *plc) { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "social_api: place_leave\n"); struct GNUNET_MessageHeader *msg; struct GNUNET_MQ_Envelope * env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); @@ -1580,7 +1583,11 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst, GNUNET_ContinuationCallback disconnect_cb, void *cls) { - place_disconnect (&hst->plc, disconnect_cb, cls); + struct GNUNET_SOCIAL_Place *plc = &hst->plc; + + plc->disconnect_cb = disconnect_cb; + plc->disconnect_cls = cls; + place_disconnect (plc); } @@ -1607,6 +1614,8 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, GNUNET_ContinuationCallback disconnect_cb, void *cls) { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "GNUNET_SOCIAL_host_leave\n"); GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, GNUNET_SOCIAL_ANNOUNCE_NONE); place_leave (&hst->plc); @@ -2028,7 +2037,14 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst, GNUNET_ContinuationCallback disconnect_cb, void *cls) { - place_disconnect (&gst->plc, disconnect_cb, cls); + struct GNUNET_SOCIAL_Place *plc = &gst->plc; + + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "GNUNET_SOCIAL_guest_disconnect, gst = %p\n", + gst); + plc->disconnect_cb = disconnect_cb; + plc->disconnect_cls = cls; + place_disconnect (plc); } diff --git a/src/social/test_social.c b/src/social/test_social.c index 64ef10125..505780a69 100644 --- a/src/social/test_social.c +++ b/src/social/test_social.c @@ -129,22 +129,22 @@ enum TEST_HOST_ANSWER_DOOR_REFUSE = 4, TEST_GUEST_RECV_ENTRY_DCSN_REFUSE = 5, TEST_HOST_ANSWER_DOOR_ADMIT = 6, - TEST_GUEST_RECV_ENTRY_DCSN_ADMIT = 9, - TEST_HOST_ANNOUNCE = 10, - TEST_HOST_ANNOUNCE_END = 11, - TEST_GUEST_TALK = 12, - TEST_HOST_ANNOUNCE2 = 13, - TEST_HOST_ANNOUNCE2_END = 14, - TEST_GUEST_HISTORY_REPLAY = 15, - TEST_GUEST_HISTORY_REPLAY_LATEST = 16, - TEST_GUEST_LOOK_AT = 17, - TEST_GUEST_LOOK_FOR = 18, - TEST_GUEST_LEAVE = 18, - TEST_ZONE_ADD_PLACE = 20, - TEST_GUEST_ENTER_BY_NAME = 21, - TEST_RECONNECT = 22, - TEST_GUEST_LEAVE2 = 23, - TEST_HOST_LEAVE = 24, + TEST_GUEST_RECV_ENTRY_DCSN_ADMIT = 7, + TEST_HOST_ANNOUNCE = 8, + TEST_HOST_ANNOUNCE_END = 9, + TEST_GUEST_TALK = 10, + TEST_HOST_ANNOUNCE2 = 11, + TEST_HOST_ANNOUNCE2_END = 12, + TEST_GUEST_HISTORY_REPLAY = 13, + TEST_GUEST_HISTORY_REPLAY_LATEST = 14, + TEST_GUEST_LOOK_AT = 15, + TEST_GUEST_LOOK_FOR = 16, + TEST_GUEST_LEAVE = 17, + TEST_ZONE_ADD_PLACE = 18, + TEST_GUEST_ENTER_BY_NAME = 19, + TEST_RECONNECT = 20, + TEST_GUEST_LEAVE2 = 21, + TEST_HOST_LEAVE = 22, } test; @@ -254,7 +254,7 @@ end_normally (void *cls) static void end () { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Ending tests.\n", test); if (end_badly_task != NULL) @@ -271,7 +271,7 @@ transmit_resume (void *cls) { struct TransmitClosure *tmit = cls; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Transmission resumed.\n", test); if (NULL != tmit->host_ann) GNUNET_SOCIAL_host_announce_resume (tmit->host_ann); @@ -296,7 +296,7 @@ notify_data (void *cls, uint16_t *data_size, void *data) } uint16_t size = strlen (tmit->data[tmit->n]); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Transmit notify data: %u bytes available, " "processing fragment %u/%u (size %u).\n", test, *data_size, tmit->n + 1, tmit->data_count, size); @@ -309,7 +309,7 @@ notify_data (void *cls, uint16_t *data_size, void *data) if (GNUNET_YES != tmit->paused && 0 < tmit->data_delay[tmit->n]) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Transmission paused.\n", test); tmit->paused = GNUNET_YES; GNUNET_SCHEDULER_add_delayed ( @@ -331,7 +331,7 @@ notify_data (void *cls, uint16_t *data_size, void *data) static void host_left () { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: The host has left the place.\n", test); end (); } @@ -365,7 +365,7 @@ host_reconnected (void *cls, int result, { place_pub_key = *home_pub_key; GNUNET_CRYPTO_hash (&place_pub_key, sizeof (place_pub_key), &place_pub_hash); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Host reconnected to place %s\n", test, GNUNET_h2s (&place_pub_hash)); @@ -382,7 +382,7 @@ guest_reconnected (void *cls, int result, const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, uint64_t max_message_id) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Guest reconnected to place: %d\n", test, result); GNUNET_assert (0 <= result); @@ -398,7 +398,7 @@ guest_reconnected (void *cls, int result, static void app_connected (void *cls) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: App connected: %p\n", test, cls); } @@ -413,7 +413,7 @@ app_recv_host (void *cls, struct GNUNET_HashCode host_pub_hash; GNUNET_CRYPTO_hash (host_pub_key, sizeof (*host_pub_key), &host_pub_hash); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Got app host place notification: %s\n", test, GNUNET_h2s (&host_pub_hash)); @@ -421,7 +421,7 @@ app_recv_host (void *cls, { if (0 == memcmp (&place_pub_key, host_pub_key, sizeof (*host_pub_key))) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Reconnecting to host place: %s\n", test, GNUNET_h2s (&host_pub_hash)); hst = GNUNET_SOCIAL_host_enter_reconnect (hconn, host_slicer, host_reconnected, @@ -441,7 +441,7 @@ app_recv_guest (void *cls, struct GNUNET_HashCode guest_pub_hash; GNUNET_CRYPTO_hash (guest_pub_key, sizeof (*guest_pub_key), &guest_pub_hash); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Got app guest place notification: %s\n", test, GNUNET_h2s (&guest_pub_hash)); @@ -449,7 +449,7 @@ app_recv_guest (void *cls, { if (0 == memcmp (&place_pub_key, guest_pub_key, sizeof (*guest_pub_key))) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Reconnecting to guest place: %s\n", test, GNUNET_h2s (&guest_pub_hash)); gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn, GNUNET_PSYC_SLAVE_JOIN_NONE, @@ -487,15 +487,30 @@ app_recv_ego (void *cls, { host_ego = ego; host_pub_key = ego_pub_key; - GNUNET_assert (TEST_IDENTITIES_CREATE == test); - enter_if_ready (); + if (TEST_IDENTITIES_CREATE == test) + { + enter_if_ready (); + } + else + { + GNUNET_assert (TEST_RECONNECT == test); + } } else if (NULL != strstr (name, guest_name)) { guest_ego = ego; guest_pub_key = ego_pub_key; - GNUNET_assert (TEST_IDENTITIES_CREATE == test); - enter_if_ready (); + if (TEST_IDENTITIES_CREATE == test) + { + enter_if_ready (); + } + else + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "test = %d\n", + test); + GNUNET_assert (TEST_RECONNECT == test); + } } } @@ -524,7 +539,7 @@ static void host_recv_zone_add_place_result (void *cls, int64_t result, const void *data, uint16_t data_size) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Zone add place result: %" PRId64 " (%.*s).\n", test, result, data_size, (const char *) data); GNUNET_assert (GNUNET_YES == result); @@ -538,7 +553,7 @@ static void zone_add_place () { test = TEST_ZONE_ADD_PLACE; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Adding place to zone.\n", test); GNUNET_SOCIAL_zone_add_place (app, host_ego, "home", "let.me*in!", @@ -557,7 +572,7 @@ host_farewell (void *cls, nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym); char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Farewell: nym %s (%s) has left the place.\n", test, GNUNET_h2s (GNUNET_SOCIAL_nym_get_pub_key_hash (nym)), str); GNUNET_free (str); @@ -578,7 +593,7 @@ host_farewell (void *cls, static void guest_left (void *cls) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: The guest has left the place.\n", test); } @@ -615,11 +630,11 @@ guest_look_for_result (void *cls, uint16_t data_size) { struct ResultClosure *rcls = cls; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: guest_look_for_result: %" PRId64 "\n", test, result_code); GNUNET_assert (GNUNET_OK == result_code); - GNUNET_assert (3 == rcls->n); + GNUNET_assert (6 == rcls->n); GNUNET_free (rcls); GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL); } @@ -635,7 +650,7 @@ guest_look_for_var (void *cls, { struct ResultClosure *rcls = cls; rcls->n++; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: guest_look_for_var: %s\n%.*s\n", test, name, value_size, (const char *) value); } @@ -656,7 +671,7 @@ guest_look_at_result (void *cls, int64_t result_code, { struct ResultClosure *rcls = cls; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: guest_look_at_result: %" PRId64 "\n", test, result_code); GNUNET_assert (GNUNET_OK == result_code); @@ -677,7 +692,7 @@ guest_look_at_var (void *cls, struct ResultClosure *rcls = cls; rcls->n++; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: guest_look_at_var: %s\n%.*s\n", test ,name, value_size, (const char *) value); } @@ -696,7 +711,7 @@ static void guest_recv_history_replay_latest_result (void *cls, int64_t result, const void *data, uint16_t data_size) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Guest received latest history replay result " "(%" PRIu32 " messages, %" PRId64 " fragments):\n" "%.*s\n", @@ -725,7 +740,7 @@ static void guest_recv_history_replay_result (void *cls, int64_t result, const void *data, uint16_t data_size) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Guest received history replay result: %" PRId64 "\n" "%.*s\n", test, result, data_size, (const char *) data); @@ -756,7 +771,7 @@ guest_recv_method (void *cls, uint64_t message_id, const char *method_name) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Guest received method for message ID %" PRIu64 ":\n" "%s (flags: %x)\n", test, message_id, method_name, ntohl (meth->flags)); @@ -775,7 +790,7 @@ guest_recv_modifier (void *cls, uint16_t value_size, uint16_t full_value_size) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Guest received modifier for message ID %" PRIu64 ":\n" "%c%s: %.*s (size: %u)\n", test, message_id, oper, name, value_size, (const char *) value, value_size); @@ -793,7 +808,7 @@ guest_recv_mod_foo_bar (void *cls, uint16_t value_size, uint16_t full_value_size) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Guest received modifier matching _foo_bar for message ID %" PRIu64 ":\n" "%c%s: %.*s (size: %u)\n", test, message_id, oper, name, value_size, (const char *) value, value_size); @@ -811,7 +826,7 @@ guest_recv_data (void *cls, const void *data, uint16_t data_size) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Guest received data for message ID %" PRIu64 ":\n" "%.*s\n", test, message_id, data_size, (const char *) data); @@ -826,7 +841,7 @@ guest_recv_eom (void *cls, uint64_t message_id, uint8_t is_cancelled) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Guest received end of message ID %" PRIu64 ", cancelled: %u\n", test, message_id, is_cancelled); @@ -868,7 +883,7 @@ host_recv_method (void *cls, uint64_t message_id, const char *method_name) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Host received method for message ID %" PRIu64 ":\n" "%s\n", test, message_id, method_name); @@ -887,7 +902,7 @@ host_recv_modifier (void *cls, uint16_t value_size, uint16_t full_value_size) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Host received modifier for message ID %" PRIu64 ":\n" "%c%s: %.*s\n", test, message_id, oper, name, value_size, (const char *) value); @@ -902,7 +917,7 @@ host_recv_data (void *cls, const void *data, uint16_t data_size) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Host received data for message ID %" PRIu64 ":\n" "%.*s\n", test, message_id, data_size, (const char *) data); @@ -916,7 +931,7 @@ host_recv_eom (void *cls, uint64_t message_id, uint8_t is_cancelled) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Host received end of message ID %" PRIu64 ", cancelled: %u\n", test, message_id, is_cancelled); @@ -981,7 +996,7 @@ host_announce () { test = TEST_HOST_ANNOUNCE; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Host announcement.\n", test); tmit = (struct TransmitClosure) {}; @@ -1015,7 +1030,7 @@ host_announce2 () test = TEST_HOST_ANNOUNCE2; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Host announcement 2.\n", test); tmit = (struct TransmitClosure) {}; @@ -1025,7 +1040,7 @@ host_announce2 () GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN, "_foo2_bar", DATA2ARG ("FOO BAR")); GNUNET_PSYC_env_add (tmit.env, GNUNET_PSYC_OP_ASSIGN, - "_foo2_bar", DATA2ARG ("FOO BAR BAZ")); + "_foo2_bar_baz", DATA2ARG ("FOO BAR BAZ")); tmit.data[0] = "AAA BBB CCC "; tmit.data[1] = "ABC DEF GHI JKL.\n"; tmit.data[2] = "TESTING ONE TWO THREE.\n"; @@ -1097,7 +1112,7 @@ host_answer_door (void *cls, { join_req_count++; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Host received entry request from guest (try %u).\n", (uint8_t) test, join_req_count); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1177,7 +1192,7 @@ static void guest_enter_by_name () { test = TEST_GUEST_ENTER_BY_NAME; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Entering to place by name as guest.\n", test); struct GuestEnterMessage *emsg = &guest_enter_msg; @@ -1306,6 +1321,8 @@ start_app_if_ready () { return; } + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "starting app...\n"); app = GNUNET_SOCIAL_app_connect (cfg, app_id, app_recv_ego,