diff options
author | lurchi <lurchi@strangeplace.net> | 2017-11-13 20:45:48 +0100 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2017-11-13 20:45:48 +0100 |
commit | 6599b4d49d58831ec38bab64478266ebfd9c59fe (patch) | |
tree | 107bbc1cd9ab888931abd01dba9aabe3b004128a /src/social | |
parent | 5d2fadf532f771a93f0c3873b5b47b73a0652b96 (diff) | |
download | gnunet-6599b4d49d58831ec38bab64478266ebfd9c59fe.tar.gz gnunet-6599b4d49d58831ec38bab64478266ebfd9c59fe.zip |
Use MQ API instead of manually allocating messages; simplify logic in handle_client_psyc_message; cleanup
Diffstat (limited to 'src/social')
-rw-r--r-- | src/social/gnunet-service-social.c | 406 | ||||
-rw-r--r-- | src/social/social_api.c | 36 |
2 files changed, 152 insertions, 290 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index 609cdab06..3e527cbaf 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -501,9 +501,6 @@ cleanup_host (struct Host *hst) | |||
501 | static void | 501 | static void |
502 | cleanup_guest (struct Guest *gst) | 502 | cleanup_guest (struct Guest *gst) |
503 | { | 503 | { |
504 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
505 | "cleanup_guest, gst = %p\n", | ||
506 | gst); | ||
507 | struct Place *plc = &gst->place; | 504 | struct Place *plc = &gst->place; |
508 | struct GNUNET_CONTAINER_MultiHashMap * | 505 | struct GNUNET_CONTAINER_MultiHashMap * |
509 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, | 506 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, |
@@ -539,10 +536,6 @@ cleanup_place (void *cls) | |||
539 | { | 536 | { |
540 | struct Place *plc = cls; | 537 | struct Place *plc = cls; |
541 | 538 | ||
542 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
543 | "%p Cleaning up place %s\n", | ||
544 | plc, GNUNET_h2s (&plc->pub_key_hash)); | ||
545 | |||
546 | (GNUNET_YES == plc->is_host) | 539 | (GNUNET_YES == plc->is_host) |
547 | ? cleanup_host ((struct Host *) plc) | 540 | ? cleanup_host ((struct Host *) plc) |
548 | : cleanup_guest ((struct Guest *) plc); | 541 | : cleanup_guest ((struct Guest *) plc); |
@@ -621,36 +614,24 @@ client_notify_connect (void *cls, | |||
621 | 614 | ||
622 | 615 | ||
623 | /** | 616 | /** |
624 | * Send message to a client. | 617 | * Send message to all clients connected to a place and |
625 | */ | 618 | * takes care of freeing @env. |
626 | static inline void | ||
627 | client_send_msg (struct GNUNET_SERVICE_Client *client, | ||
628 | const struct GNUNET_MessageHeader *msg) | ||
629 | { | ||
630 | struct GNUNET_MQ_Envelope * | ||
631 | env = GNUNET_MQ_msg_copy (msg); | ||
632 | |||
633 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), | ||
634 | env); | ||
635 | } | ||
636 | |||
637 | |||
638 | /** | ||
639 | * Send message to all clients connected to a place. | ||
640 | */ | 619 | */ |
641 | static void | 620 | static void |
642 | place_send_msg (const struct Place *plc, | 621 | place_send_msg (const struct Place *plc, |
643 | const struct GNUNET_MessageHeader *msg) | 622 | struct GNUNET_MQ_Envelope *env) |
644 | { | 623 | { |
624 | struct ClientListItem *cli = plc->clients_head; | ||
625 | |||
645 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 626 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
646 | "%p Sending message to clients of place.\n", plc); | 627 | "%p Sending message to clients of place.\n", plc); |
647 | |||
648 | struct ClientListItem *cli = plc->clients_head; | ||
649 | while (NULL != cli) | 628 | while (NULL != cli) |
650 | { | 629 | { |
651 | client_send_msg (cli->client, msg); | 630 | GNUNET_MQ_send_copy (GNUNET_SERVICE_client_get_mq (cli->client), |
631 | env); | ||
652 | cli = cli->next; | 632 | cli = cli->next; |
653 | } | 633 | } |
634 | GNUNET_MQ_discard (env); | ||
654 | } | 635 | } |
655 | 636 | ||
656 | 637 | ||
@@ -672,23 +653,21 @@ static void | |||
672 | client_send_result (struct GNUNET_SERVICE_Client *client, uint64_t op_id, | 653 | client_send_result (struct GNUNET_SERVICE_Client *client, uint64_t op_id, |
673 | int64_t result_code, const void *data, uint16_t data_size) | 654 | int64_t result_code, const void *data, uint16_t data_size) |
674 | { | 655 | { |
656 | struct GNUNET_MQ_Envelope *env; | ||
675 | struct GNUNET_OperationResultMessage *res; | 657 | struct GNUNET_OperationResultMessage *res; |
676 | 658 | ||
677 | res = GNUNET_malloc (sizeof (*res) + data_size); | 659 | env = GNUNET_MQ_msg_extra (res, |
678 | res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE); | 660 | data_size, |
679 | res->header.size = htons (sizeof (*res) + data_size); | 661 | GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE); |
680 | res->result_code = GNUNET_htonll (result_code); | 662 | res->result_code = GNUNET_htonll (result_code); |
681 | res->op_id = op_id; | 663 | res->op_id = op_id; |
682 | if (0 < data_size) | 664 | if (0 < data_size) |
683 | GNUNET_memcpy (&res[1], data, data_size); | 665 | GNUNET_memcpy (&res[1], data, data_size); |
684 | |||
685 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 666 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
686 | "%p Sending result to client for operation #%" PRIu64 ": " | 667 | "%p Sending result to client for operation #%" PRIu64 ": " |
687 | "%" PRId64 " (size: %u)\n", | 668 | "%" PRId64 " (size: %u)\n", |
688 | client, GNUNET_ntohll (op_id), result_code, data_size); | 669 | client, GNUNET_ntohll (op_id), result_code, data_size); |
689 | 670 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); | |
690 | client_send_msg (client, &res->header); | ||
691 | GNUNET_free (res); | ||
692 | } | 671 | } |
693 | 672 | ||
694 | 673 | ||
@@ -696,19 +675,21 @@ static void | |||
696 | client_send_host_enter_ack (struct GNUNET_SERVICE_Client *client, | 675 | client_send_host_enter_ack (struct GNUNET_SERVICE_Client *client, |
697 | struct Host *hst, uint32_t result) | 676 | struct Host *hst, uint32_t result) |
698 | { | 677 | { |
678 | struct GNUNET_MQ_Envelope *env; | ||
679 | struct HostEnterAck *hack; | ||
699 | struct Place *plc = &hst->place; | 680 | struct Place *plc = &hst->place; |
700 | 681 | ||
701 | struct HostEnterAck hack; | 682 | env = GNUNET_MQ_msg (hack, |
702 | hack.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); | 683 | GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); |
703 | hack.header.size = htons (sizeof (hack)); | 684 | hack->result_code = htonl (result); |
704 | hack.result_code = htonl (result); | 685 | hack->max_message_id = GNUNET_htonll (plc->max_message_id); |
705 | hack.max_message_id = GNUNET_htonll (plc->max_message_id); | 686 | hack->place_pub_key = plc->pub_key; |
706 | hack.place_pub_key = plc->pub_key; | ||
707 | 687 | ||
708 | if (NULL != client) | 688 | if (NULL != client) |
709 | client_send_msg (client, &hack.header); | 689 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), |
690 | env); | ||
710 | else | 691 | else |
711 | place_send_msg (plc, &hack.header); | 692 | place_send_msg (plc, env); |
712 | } | 693 | } |
713 | 694 | ||
714 | 695 | ||
@@ -742,7 +723,8 @@ psyc_recv_join_request (void *cls, | |||
742 | GNUNET_CRYPTO_hash (slave_key, sizeof (*slave_key), &slave_key_hash); | 723 | GNUNET_CRYPTO_hash (slave_key, sizeof (*slave_key), &slave_key_hash); |
743 | GNUNET_CONTAINER_multihashmap_put (hst->join_reqs, &slave_key_hash, jh, | 724 | GNUNET_CONTAINER_multihashmap_put (hst->join_reqs, &slave_key_hash, jh, |
744 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 725 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
745 | place_send_msg (&hst->place, &req->header); | 726 | place_send_msg (&hst->place, |
727 | GNUNET_MQ_msg_copy (&req->header)); | ||
746 | } | 728 | } |
747 | 729 | ||
748 | 730 | ||
@@ -752,18 +734,18 @@ psyc_recv_join_request (void *cls, | |||
752 | static void | 734 | static void |
753 | psyc_slave_connected (void *cls, int result, uint64_t max_message_id) | 735 | psyc_slave_connected (void *cls, int result, uint64_t max_message_id) |
754 | { | 736 | { |
737 | struct GNUNET_PSYC_CountersResultMessage *res; | ||
738 | struct GNUNET_MQ_Envelope *env; | ||
755 | struct Guest *gst = cls; | 739 | struct Guest *gst = cls; |
756 | struct Place *plc = &gst->place; | 740 | struct Place *plc = &gst->place; |
741 | |||
757 | plc->max_message_id = max_message_id; | 742 | plc->max_message_id = max_message_id; |
758 | plc->is_ready = GNUNET_YES; | 743 | plc->is_ready = GNUNET_YES; |
759 | 744 | env = GNUNET_MQ_msg (res, | |
760 | struct GNUNET_PSYC_CountersResultMessage res; | 745 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); |
761 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); | 746 | res->result_code = htonl (result); |
762 | res.header.size = htons (sizeof (res)); | 747 | res->max_message_id = GNUNET_htonll (plc->max_message_id); |
763 | res.result_code = htonl (result); | 748 | place_send_msg (plc, env); |
764 | res.max_message_id = GNUNET_htonll (plc->max_message_id); | ||
765 | |||
766 | place_send_msg (plc, &res.header); | ||
767 | } | 749 | } |
768 | 750 | ||
769 | 751 | ||
@@ -777,7 +759,7 @@ psyc_recv_join_dcsn (void *cls, | |||
777 | const struct GNUNET_PSYC_Message *join_msg) | 759 | const struct GNUNET_PSYC_Message *join_msg) |
778 | { | 760 | { |
779 | struct Guest *gst = cls; | 761 | struct Guest *gst = cls; |
780 | place_send_msg (&gst->place, &dcsn->header); | 762 | place_send_msg (&gst->place, GNUNET_MQ_msg_copy (&dcsn->header)); |
781 | } | 763 | } |
782 | 764 | ||
783 | 765 | ||
@@ -798,7 +780,7 @@ psyc_recv_message (void *cls, | |||
798 | 780 | ||
799 | GNUNET_PSYC_slicer_message (plc->slicer, msg); | 781 | GNUNET_PSYC_slicer_message (plc->slicer, msg); |
800 | 782 | ||
801 | place_send_msg (plc, &msg->header); | 783 | place_send_msg (plc, GNUNET_MQ_msg_copy (&msg->header)); |
802 | } | 784 | } |
803 | 785 | ||
804 | 786 | ||
@@ -1180,8 +1162,6 @@ app_place_add (const char *app_id, | |||
1180 | 1162 | ||
1181 | if (GNUNET_SYSERR == place_add (ereq)) | 1163 | if (GNUNET_SYSERR == place_add (ereq)) |
1182 | { | 1164 | { |
1183 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1184 | "could not add place\n"); | ||
1185 | return GNUNET_SYSERR; | 1165 | return GNUNET_SYSERR; |
1186 | } | 1166 | } |
1187 | 1167 | ||
@@ -1191,32 +1171,6 @@ app_place_add (const char *app_id, | |||
1191 | GNUNET_break (0); | 1171 | GNUNET_break (0); |
1192 | return GNUNET_SYSERR; | 1172 | return GNUNET_SYSERR; |
1193 | } | 1173 | } |
1194 | |||
1195 | //struct GNUNET_HashCode place_pub_hash; | ||
1196 | //GNUNET_CRYPTO_hash (&ereq->place_pub_key, sizeof (ereq->place_pub_key), &place_pub_hash); | ||
1197 | |||
1198 | //struct GNUNET_CONTAINER_MultiHashMap * | ||
1199 | // place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); | ||
1200 | //if (NULL == place_apps) | ||
1201 | //{ | ||
1202 | // place_apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); | ||
1203 | // if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (places_apps, &place_pub_hash, place_apps, | ||
1204 | // GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) | ||
1205 | // { | ||
1206 | // GNUNET_break (0); | ||
1207 | // } | ||
1208 | //} | ||
1209 | |||
1210 | //size_t app_id_size = strlen (app_id) + 1; | ||
1211 | //void *app_id_value = GNUNET_malloc (app_id_size); | ||
1212 | //GNUNET_memcpy (app_id_value, app_id, app_id_size); | ||
1213 | |||
1214 | //if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (place_apps, &app_id_hash, app_id_value, | ||
1215 | // GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | ||
1216 | //{ | ||
1217 | // GNUNET_break (0); | ||
1218 | //} | ||
1219 | |||
1220 | return GNUNET_OK; | 1174 | return GNUNET_OK; |
1221 | } | 1175 | } |
1222 | 1176 | ||
@@ -1317,18 +1271,6 @@ app_place_remove (const char *app_id, | |||
1317 | if (NULL != app_places) | 1271 | if (NULL != app_places) |
1318 | GNUNET_CONTAINER_multihashmap_remove (app_places, &place_pub_hash, NULL); | 1272 | GNUNET_CONTAINER_multihashmap_remove (app_places, &place_pub_hash, NULL); |
1319 | 1273 | ||
1320 | //struct GNUNET_CONTAINER_MultiHashMap * | ||
1321 | // place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); | ||
1322 | //if (NULL != place_apps) | ||
1323 | //{ | ||
1324 | // void *app_id_value = GNUNET_CONTAINER_multihashmap_get (place_apps, &app_id_hash); | ||
1325 | // if (NULL != app_id_value) | ||
1326 | // { | ||
1327 | // GNUNET_CONTAINER_multihashmap_remove (place_apps, &app_id_hash, app_id_value); | ||
1328 | // GNUNET_free (app_id_value); | ||
1329 | // } | ||
1330 | //} | ||
1331 | |||
1332 | int ret = GNUNET_OK; | 1274 | int ret = GNUNET_OK; |
1333 | 1275 | ||
1334 | if (0 != unlink (app_place_filename)) | 1276 | if (0 != unlink (app_place_filename)) |
@@ -1424,100 +1366,104 @@ void | |||
1424 | app_notify_place (const struct GNUNET_MessageHeader *msg, | 1366 | app_notify_place (const struct GNUNET_MessageHeader *msg, |
1425 | struct GNUNET_SERVICE_Client *client) | 1367 | struct GNUNET_SERVICE_Client *client) |
1426 | { | 1368 | { |
1369 | struct AppPlaceMessage *amsg; | ||
1370 | struct GNUNET_MQ_Envelope *env; | ||
1371 | uint16_t msg_size = ntohs (msg->size); | ||
1372 | |||
1427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1428 | "%p Sending place notification of type %u to client.\n", | 1374 | "%p Sending place notification of type %u to client.\n", |
1429 | client, ntohs (msg->type)); | 1375 | client, ntohs (msg->type)); |
1430 | |||
1431 | uint16_t msg_size = ntohs (msg->size); | ||
1432 | struct AppPlaceMessage amsg; | ||
1433 | amsg.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); | ||
1434 | amsg.header.size = htons (sizeof (amsg)); | ||
1435 | // FIXME: also notify about not entered places | ||
1436 | amsg.place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; | ||
1437 | |||
1438 | switch (ntohs (msg->type)) | 1376 | switch (ntohs (msg->type)) |
1439 | { | 1377 | { |
1440 | case GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER: | 1378 | case GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER: |
1379 | { | ||
1380 | struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg; | ||
1441 | if (msg_size < sizeof (struct HostEnterRequest)) | 1381 | if (msg_size < sizeof (struct HostEnterRequest)) |
1442 | return; | 1382 | return; |
1443 | struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg; | 1383 | env = GNUNET_MQ_msg (amsg, |
1444 | amsg.is_host = GNUNET_YES; | 1384 | GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); |
1445 | amsg.ego_pub_key = hreq->ego_pub_key; | 1385 | // FIXME: also notify about not entered places |
1446 | amsg.place_pub_key = hreq->place_pub_key; | 1386 | amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; |
1387 | amsg->is_host = GNUNET_YES; | ||
1388 | amsg->ego_pub_key = hreq->ego_pub_key; | ||
1389 | amsg->place_pub_key = hreq->place_pub_key; | ||
1390 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), | ||
1391 | env); | ||
1447 | break; | 1392 | break; |
1448 | 1393 | } | |
1449 | case GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER: | 1394 | case GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER: |
1395 | { | ||
1450 | if (msg_size < sizeof (struct GuestEnterRequest)) | 1396 | if (msg_size < sizeof (struct GuestEnterRequest)) |
1451 | return; | 1397 | return; |
1452 | struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg; | 1398 | struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg; |
1453 | amsg.is_host = GNUNET_NO; | 1399 | env = GNUNET_MQ_msg (amsg, |
1454 | amsg.ego_pub_key = greq->ego_pub_key; | 1400 | GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); |
1455 | amsg.place_pub_key = greq->place_pub_key; | 1401 | // FIXME: also notify about not entered places |
1402 | amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; | ||
1403 | amsg->is_host = GNUNET_NO; | ||
1404 | amsg->ego_pub_key = greq->ego_pub_key; | ||
1405 | amsg->place_pub_key = greq->place_pub_key; | ||
1406 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), | ||
1407 | env); | ||
1456 | break; | 1408 | break; |
1457 | 1409 | } | |
1458 | default: | 1410 | default: |
1459 | return; | 1411 | return; |
1460 | } | 1412 | } |
1461 | |||
1462 | client_send_msg (client, &amsg.header); | ||
1463 | } | 1413 | } |
1464 | 1414 | ||
1465 | 1415 | ||
1466 | void | 1416 | void |
1467 | app_notify_place_end (struct GNUNET_SERVICE_Client *client) | 1417 | app_notify_place_end (struct GNUNET_SERVICE_Client *client) |
1468 | { | 1418 | { |
1419 | struct GNUNET_MQ_Envelope *env; | ||
1420 | |||
1469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1470 | "%p Sending end of place list notification to client\n", | 1422 | "%p Sending end of place list notification to client\n", |
1471 | client); | 1423 | client); |
1472 | 1424 | env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END); | |
1473 | struct GNUNET_MessageHeader msg; | 1425 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), |
1474 | msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END); | 1426 | env); |
1475 | msg.size = htons (sizeof (msg)); | ||
1476 | |||
1477 | client_send_msg (client, &msg); | ||
1478 | } | 1427 | } |
1479 | 1428 | ||
1480 | 1429 | ||
1481 | void | 1430 | void |
1482 | app_notify_ego (struct Ego *ego, struct GNUNET_SERVICE_Client *client) | 1431 | app_notify_ego (struct Ego *ego, struct GNUNET_SERVICE_Client *client) |
1483 | { | 1432 | { |
1484 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 1433 | struct AppEgoMessage *emsg; |
1485 | "%p Sending ego notification to client: %s\n", | 1434 | struct GNUNET_MQ_Envelope *env; |
1486 | client, ego->name); | ||
1487 | |||
1488 | size_t name_size = strlen (ego->name) + 1; | 1435 | size_t name_size = strlen (ego->name) + 1; |
1489 | struct AppEgoMessage *emsg = GNUNET_malloc (sizeof (*emsg) + name_size); | ||
1490 | emsg->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO); | ||
1491 | emsg->header.size = htons (sizeof (*emsg) + name_size); | ||
1492 | 1436 | ||
1437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1438 | "%p Sending ego notification to client: %s\n", | ||
1439 | client, ego->name); | ||
1440 | env = GNUNET_MQ_msg_extra (emsg, | ||
1441 | name_size, | ||
1442 | GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO); | ||
1493 | GNUNET_CRYPTO_ecdsa_key_get_public (&ego->key, &emsg->ego_pub_key); | 1443 | GNUNET_CRYPTO_ecdsa_key_get_public (&ego->key, &emsg->ego_pub_key); |
1494 | GNUNET_memcpy (&emsg[1], ego->name, name_size); | 1444 | GNUNET_memcpy (&emsg[1], ego->name, name_size); |
1495 | 1445 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), | |
1496 | client_send_msg (client, &emsg->header); | 1446 | env); |
1497 | GNUNET_free (emsg); | ||
1498 | } | 1447 | } |
1499 | 1448 | ||
1500 | 1449 | ||
1501 | void | 1450 | void |
1502 | app_notify_ego_end (struct GNUNET_SERVICE_Client *client) | 1451 | app_notify_ego_end (struct GNUNET_SERVICE_Client *client) |
1503 | { | 1452 | { |
1453 | struct GNUNET_MQ_Envelope *env; | ||
1454 | |||
1504 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1455 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1505 | "%p Sending end of ego list notification to client\n", | 1456 | "%p Sending end of ego list notification to client\n", |
1506 | client); | 1457 | client); |
1507 | 1458 | env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END); | |
1508 | struct GNUNET_MessageHeader msg; | 1459 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), |
1509 | msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END); | 1460 | env); |
1510 | msg.size = htons (sizeof (msg)); | ||
1511 | |||
1512 | client_send_msg (client, &msg); | ||
1513 | } | 1461 | } |
1514 | 1462 | ||
1515 | 1463 | ||
1516 | int | 1464 | int |
1517 | app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value) | 1465 | app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value) |
1518 | { | 1466 | { |
1519 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
1520 | "app_place_entry_notify\n"); | ||
1521 | struct GNUNET_MessageHeader * | 1467 | struct GNUNET_MessageHeader * |
1522 | msg = GNUNET_CONTAINER_multihashmap_get (places, key); | 1468 | msg = GNUNET_CONTAINER_multihashmap_get (places, key); |
1523 | if (NULL != msg) | 1469 | if (NULL != msg) |
@@ -1647,13 +1593,9 @@ handle_client_host_enter (void *cls, | |||
1647 | { | 1593 | { |
1648 | struct Client *c = cls; | 1594 | struct Client *c = cls; |
1649 | struct GNUNET_SERVICE_Client *client = c->client; | 1595 | struct GNUNET_SERVICE_Client *client = c->client; |
1650 | |||
1651 | struct HostEnterRequest * | 1596 | struct HostEnterRequest * |
1652 | hreq = (struct HostEnterRequest *) GNUNET_copy_message (&hr->header); | 1597 | hreq = (struct HostEnterRequest *) GNUNET_copy_message (&hr->header); |
1653 | 1598 | ||
1654 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
1655 | "handle_client_host_enter\n"); | ||
1656 | |||
1657 | uint8_t app_id_size = ntohs (hreq->header.size) - sizeof (*hreq); | 1599 | uint8_t app_id_size = ntohs (hreq->header.size) - sizeof (*hreq); |
1658 | const char *app_id = NULL; | 1600 | const char *app_id = NULL; |
1659 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &hreq[1], | 1601 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &hreq[1], |
@@ -1708,7 +1650,7 @@ handle_client_host_enter (void *cls, | |||
1708 | if (ret != GNUNET_SYSERR) | 1650 | if (ret != GNUNET_SYSERR) |
1709 | { | 1651 | { |
1710 | 1652 | ||
1711 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 1653 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1712 | "%p Client connected as host to place %s.\n", | 1654 | "%p Client connected as host to place %s.\n", |
1713 | hst, GNUNET_h2s (&plc->pub_key_hash)); | 1655 | hst, GNUNET_h2s (&plc->pub_key_hash)); |
1714 | 1656 | ||
@@ -1754,8 +1696,6 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1754 | 1696 | ||
1755 | if (NULL == ego) | 1697 | if (NULL == ego) |
1756 | { | 1698 | { |
1757 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1758 | "NULL == ego\n"); | ||
1759 | return GNUNET_SYSERR; | 1699 | return GNUNET_SYSERR; |
1760 | } | 1700 | } |
1761 | 1701 | ||
@@ -1770,10 +1710,6 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1770 | if (NULL != plc_gst) | 1710 | if (NULL != plc_gst) |
1771 | gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash); | 1711 | gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash); |
1772 | 1712 | ||
1773 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
1774 | "guest enter, gst = %p\n", | ||
1775 | gst); | ||
1776 | |||
1777 | if (NULL == gst || NULL == gst->slave) | 1713 | if (NULL == gst || NULL == gst->slave) |
1778 | { | 1714 | { |
1779 | gst = GNUNET_new (struct Guest); | 1715 | gst = GNUNET_new (struct Guest); |
@@ -1811,9 +1747,6 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1811 | struct GNUNET_PSYC_Message *join_msg = NULL; | 1747 | struct GNUNET_PSYC_Message *join_msg = NULL; |
1812 | uint16_t join_msg_size = 0; | 1748 | uint16_t join_msg_size = 0; |
1813 | 1749 | ||
1814 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
1815 | "guest_enter 2\n"); | ||
1816 | |||
1817 | if (sizeof (struct GNUNET_MessageHeader) <= remaining) | 1750 | if (sizeof (struct GNUNET_MessageHeader) <= remaining) |
1818 | { | 1751 | { |
1819 | join_msg = (struct GNUNET_PSYC_Message *) p; | 1752 | join_msg = (struct GNUNET_PSYC_Message *) p; |
@@ -1853,15 +1786,10 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1853 | (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, | 1786 | (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, |
1854 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1787 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
1855 | } | 1788 | } |
1856 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
1857 | "Adding guest %p\n", | ||
1858 | gst); | ||
1859 | (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, | 1789 | (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, |
1860 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1790 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
1861 | (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst, | 1791 | (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst, |
1862 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1792 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1863 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
1864 | "GNUNET_PSYC_slave_join\n"); | ||
1865 | gst->slave | 1793 | gst->slave |
1866 | = GNUNET_PSYC_slave_join (cfg, &plc->pub_key, &plc->ego_key, | 1794 | = GNUNET_PSYC_slave_join (cfg, &plc->pub_key, &plc->ego_key, |
1867 | gst->join_flags, &gst->origin, | 1795 | gst->join_flags, &gst->origin, |
@@ -1884,23 +1812,20 @@ static int | |||
1884 | client_guest_enter (struct Client *c, | 1812 | client_guest_enter (struct Client *c, |
1885 | const struct GuestEnterRequest *greq) | 1813 | const struct GuestEnterRequest *greq) |
1886 | { | 1814 | { |
1815 | struct GNUNET_PSYC_CountersResultMessage *result_msg; | ||
1816 | struct GNUNET_MQ_Envelope *env; | ||
1887 | struct GNUNET_SERVICE_Client *client = c->client; | 1817 | struct GNUNET_SERVICE_Client *client = c->client; |
1888 | |||
1889 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
1890 | "handle_client_guest_enter\n"); | ||
1891 | |||
1892 | uint16_t remaining = ntohs (greq->header.size) - sizeof (*greq); | 1818 | uint16_t remaining = ntohs (greq->header.size) - sizeof (*greq); |
1893 | const char *app_id = NULL; | 1819 | const char *app_id = NULL; |
1894 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &greq[1], | 1820 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &greq[1], |
1895 | remaining, 1, &app_id); | 1821 | remaining, 1, &app_id); |
1822 | struct Guest *gst = NULL; | ||
1823 | struct Place *plc = NULL; | ||
1824 | |||
1896 | if (0 == offset) | 1825 | if (0 == offset) |
1897 | { | 1826 | { |
1898 | return GNUNET_SYSERR; | 1827 | return GNUNET_SYSERR; |
1899 | } | 1828 | } |
1900 | |||
1901 | struct Guest *gst = NULL; | ||
1902 | struct Place *plc = NULL; | ||
1903 | |||
1904 | switch (guest_enter (greq, &gst)) | 1829 | switch (guest_enter (greq, &gst)) |
1905 | { | 1830 | { |
1906 | case GNUNET_YES: | 1831 | case GNUNET_YES: |
@@ -1914,17 +1839,18 @@ client_guest_enter (struct Client *c, | |||
1914 | { | 1839 | { |
1915 | plc = c->place = &gst->place; | 1840 | plc = c->place = &gst->place; |
1916 | plc->guest = gst; | 1841 | plc->guest = gst; |
1917 | 1842 | env = GNUNET_MQ_msg (result_msg, | |
1918 | struct GNUNET_PSYC_CountersResultMessage res; | 1843 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); |
1919 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); | 1844 | result_msg->result_code = htonl (GNUNET_OK); |
1920 | res.header.size = htons (sizeof (res)); | 1845 | result_msg->max_message_id = GNUNET_htonll (plc->max_message_id); |
1921 | res.result_code = htonl (GNUNET_OK); | 1846 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), |
1922 | res.max_message_id = GNUNET_htonll (plc->max_message_id); | 1847 | env); |
1923 | |||
1924 | client_send_msg (client, &res.header); | ||
1925 | if (NULL != gst->join_dcsn) | 1848 | if (NULL != gst->join_dcsn) |
1926 | client_send_msg (client, &gst->join_dcsn->header); | 1849 | { |
1927 | 1850 | env = GNUNET_MQ_msg_copy (&gst->join_dcsn->header); | |
1851 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), | ||
1852 | env); | ||
1853 | } | ||
1928 | break; | 1854 | break; |
1929 | } | 1855 | } |
1930 | case GNUNET_SYSERR: | 1856 | case GNUNET_SYSERR: |
@@ -1957,8 +1883,6 @@ static void | |||
1957 | handle_client_guest_enter (void *cls, | 1883 | handle_client_guest_enter (void *cls, |
1958 | const struct GuestEnterRequest *greq) | 1884 | const struct GuestEnterRequest *greq) |
1959 | { | 1885 | { |
1960 | // FIXME: this must not be called directly by gns_result_guest_enter because then | ||
1961 | // GNUNET_SERVICE_client_continue is called twice | ||
1962 | struct Client *c = cls; | 1886 | struct Client *c = cls; |
1963 | 1887 | ||
1964 | if (GNUNET_SYSERR == client_guest_enter (c, greq)) | 1888 | if (GNUNET_SYSERR == client_guest_enter (c, greq)) |
@@ -1992,7 +1916,7 @@ gns_result_guest_enter (void *cls, uint32_t rd_count, | |||
1992 | { | 1916 | { |
1993 | struct GuestEnterByNameClosure *gcls = cls; | 1917 | struct GuestEnterByNameClosure *gcls = cls; |
1994 | struct Client *c = gcls->client; | 1918 | struct Client *c = gcls->client; |
1995 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 1919 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1996 | "%p GNS result: %u records.\n", | 1920 | "%p GNS result: %u records.\n", |
1997 | c, rd_count); | 1921 | c, rd_count); |
1998 | 1922 | ||
@@ -2158,8 +2082,6 @@ handle_client_app_connect (void *cls, | |||
2158 | struct GNUNET_HashCode app_id_hash; | 2082 | struct GNUNET_HashCode app_id_hash; |
2159 | GNUNET_CRYPTO_hash (app_id, app_id_size, &app_id_hash); | 2083 | GNUNET_CRYPTO_hash (app_id, app_id_size, &app_id_hash); |
2160 | 2084 | ||
2161 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
2162 | "iterating egos\n"); | ||
2163 | GNUNET_CONTAINER_multihashmap_iterate (egos, ego_entry, client); | 2085 | GNUNET_CONTAINER_multihashmap_iterate (egos, ego_entry, client); |
2164 | app_notify_ego_end (client); | 2086 | app_notify_ego_end (client); |
2165 | 2087 | ||
@@ -2207,16 +2129,6 @@ handle_client_app_detach (void *cls, | |||
2207 | } | 2129 | } |
2208 | 2130 | ||
2209 | 2131 | ||
2210 | static int | ||
2211 | app_places_entry_remove (void *cls, const struct GNUNET_HashCode *key, void *value) | ||
2212 | { | ||
2213 | struct Place *plc = cls; | ||
2214 | const char *app_id = value; | ||
2215 | app_place_remove (app_id, &plc->ego_pub_key, &plc->pub_key); | ||
2216 | return GNUNET_YES; | ||
2217 | } | ||
2218 | |||
2219 | |||
2220 | /** | 2132 | /** |
2221 | * Handle application leave request. | 2133 | * Handle application leave request. |
2222 | */ | 2134 | */ |
@@ -2228,10 +2140,6 @@ handle_client_place_leave (void *cls, | |||
2228 | struct GNUNET_SERVICE_Client *client = c->client; | 2140 | struct GNUNET_SERVICE_Client *client = c->client; |
2229 | struct Place *plc = c->place; | 2141 | struct Place *plc = c->place; |
2230 | struct GNUNET_MQ_Envelope *env; | 2142 | struct GNUNET_MQ_Envelope *env; |
2231 | struct GNUNET_MessageHeader *ack_msg; | ||
2232 | |||
2233 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
2234 | "handle_client_place_leave\n"); | ||
2235 | 2143 | ||
2236 | if (NULL == plc) | 2144 | if (NULL == plc) |
2237 | { | 2145 | { |
@@ -2240,25 +2148,11 @@ handle_client_place_leave (void *cls, | |||
2240 | return; | 2148 | return; |
2241 | } | 2149 | } |
2242 | 2150 | ||
2243 | /* FIXME: remove all app subscriptions and leave this place */ | ||
2244 | |||
2245 | //struct GNUNET_CONTAINER_MultiHashMap * | ||
2246 | // place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &plc->pub_key_hash); | ||
2247 | //if (NULL != place_apps) | ||
2248 | //{ | ||
2249 | // GNUNET_CONTAINER_multihashmap_iterate (place_apps, app_places_entry_remove, plc); | ||
2250 | //} | ||
2251 | |||
2252 | /* FIXME: disconnect from the network, but keep local connection for history access */ | ||
2253 | |||
2254 | /* Disconnect all clients connected to the place */ | ||
2255 | |||
2256 | for (struct ClientListItem *cli = plc->clients_head; | 2151 | for (struct ClientListItem *cli = plc->clients_head; |
2257 | NULL != cli; | 2152 | NULL != cli; |
2258 | cli = cli->next) | 2153 | cli = cli->next) |
2259 | { | 2154 | { |
2260 | env = GNUNET_MQ_msg (ack_msg, | 2155 | env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK); |
2261 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK); | ||
2262 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cli->client), | 2156 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cli->client), |
2263 | env); | 2157 | env); |
2264 | } | 2158 | } |
@@ -2276,7 +2170,6 @@ handle_client_place_leave (void *cls, | |||
2276 | c->place = NULL; | 2170 | c->place = NULL; |
2277 | } | 2171 | } |
2278 | } | 2172 | } |
2279 | // FIXME: can't continue+drop above, but should not drop above! | ||
2280 | GNUNET_SERVICE_client_continue (client); | 2173 | GNUNET_SERVICE_client_continue (client); |
2281 | } | 2174 | } |
2282 | 2175 | ||
@@ -2365,10 +2258,15 @@ handle_client_join_decision (void *cls, | |||
2365 | static void | 2258 | static void |
2366 | send_message_ack (struct Place *plc, struct GNUNET_SERVICE_Client *client) | 2259 | send_message_ack (struct Place *plc, struct GNUNET_SERVICE_Client *client) |
2367 | { | 2260 | { |
2368 | struct GNUNET_MessageHeader res; | 2261 | struct GNUNET_MQ_Envelope *env; |
2369 | res.size = htons (sizeof (res)); | 2262 | |
2370 | res.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK); | 2263 | env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK); |
2371 | client_send_msg (client, &res); | 2264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2265 | "sending psyc message ack to client %p, mq = %p\n", | ||
2266 | client, | ||
2267 | GNUNET_SERVICE_client_get_mq (client)); | ||
2268 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), | ||
2269 | env); | ||
2372 | } | 2270 | } |
2373 | 2271 | ||
2374 | 2272 | ||
@@ -2925,26 +2823,26 @@ psyc_transmit_queue_message (struct Place *plc, | |||
2925 | } | 2823 | } |
2926 | 2824 | ||
2927 | 2825 | ||
2928 | /** | 2826 | ///** |
2929 | * Cancel transmission of current message to PSYC. | 2827 | // * Cancel transmission of current message to PSYC. |
2930 | * | 2828 | // * |
2931 | * @param plc Place to send to. | 2829 | // * @param plc Place to send to. |
2932 | * @param client Client the message originates from. | 2830 | // * @param client Client the message originates from. |
2933 | */ | 2831 | // */ |
2934 | static void | 2832 | //static void |
2935 | psyc_transmit_cancel (struct Place *plc, struct GNUNET_SERVICE_Client *client) | 2833 | //psyc_transmit_cancel (struct Place *plc, struct GNUNET_SERVICE_Client *client) |
2936 | { | 2834 | //{ |
2937 | uint16_t type = GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL; | 2835 | // uint16_t type = GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL; |
2938 | 2836 | // | |
2939 | struct GNUNET_MessageHeader msg; | 2837 | // struct GNUNET_MessageHeader msg; |
2940 | msg.size = htons (sizeof (msg)); | 2838 | // msg.size = htons (sizeof (msg)); |
2941 | msg.type = htons (type); | 2839 | // msg.type = htons (type); |
2942 | 2840 | // | |
2943 | psyc_transmit_queue_message (plc, client, sizeof (msg), &msg, type, type, NULL); | 2841 | // psyc_transmit_queue_message (plc, client, sizeof (msg), &msg, type, type, NULL); |
2944 | psyc_transmit_message (plc); | 2842 | // psyc_transmit_message (plc); |
2945 | 2843 | // | |
2946 | /* FIXME: cleanup */ | 2844 | // /* FIXME: cleanup */ |
2947 | } | 2845 | //} |
2948 | 2846 | ||
2949 | 2847 | ||
2950 | static int | 2848 | static int |
@@ -3033,13 +2931,10 @@ handle_client_psyc_message (void *cls, | |||
3033 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2931 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
3034 | "%p Received invalid message part from client.\n", plc); | 2932 | "%p Received invalid message part from client.\n", plc); |
3035 | GNUNET_break (0); | 2933 | GNUNET_break (0); |
3036 | ret = GNUNET_SYSERR; | ||
3037 | } | ||
3038 | |||
3039 | if (GNUNET_OK == ret) | ||
3040 | GNUNET_SERVICE_client_continue (client); | ||
3041 | else | ||
3042 | GNUNET_SERVICE_client_drop (client); | 2934 | GNUNET_SERVICE_client_drop (client); |
2935 | return; | ||
2936 | } | ||
2937 | GNUNET_SERVICE_client_continue (client); | ||
3043 | } | 2938 | } |
3044 | 2939 | ||
3045 | 2940 | ||
@@ -3069,7 +2964,7 @@ psyc_recv_history_message (void *cls, const struct GNUNET_PSYC_MessageHeader *ms | |||
3069 | GNUNET_memcpy (&res[1], msg, size); | 2964 | GNUNET_memcpy (&res[1], msg, size); |
3070 | 2965 | ||
3071 | /** @todo FIXME: send only to requesting client */ | 2966 | /** @todo FIXME: send only to requesting client */ |
3072 | place_send_msg (plc, &res->header); | 2967 | place_send_msg (plc, GNUNET_MQ_msg_copy (&res->header)); |
3073 | 2968 | ||
3074 | GNUNET_free (res); | 2969 | GNUNET_free (res); |
3075 | } | 2970 | } |
@@ -3171,29 +3066,24 @@ psyc_recv_state_var (void *cls, | |||
3171 | uint32_t value_size, | 3066 | uint32_t value_size, |
3172 | uint32_t full_value_size) | 3067 | uint32_t full_value_size) |
3173 | { | 3068 | { |
3069 | struct GNUNET_OperationResultMessage *result_msg; | ||
3070 | struct GNUNET_MQ_Envelope *env; | ||
3174 | struct OperationClosure *opcls = cls; | 3071 | struct OperationClosure *opcls = cls; |
3175 | struct Client *c = opcls->client; | 3072 | struct Client *c = opcls->client; |
3176 | struct Place *plc = c->place; | 3073 | struct Place *plc = c->place; |
3074 | uint16_t size = ntohs (mod->size); | ||
3177 | 3075 | ||
3178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3076 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3179 | "%p Received state variable %s from PSYC\n", | 3077 | "%p Received state variable %s from PSYC\n", |
3180 | plc, name); | 3078 | plc, name); |
3181 | 3079 | env = GNUNET_MQ_msg_extra (result_msg, | |
3182 | uint16_t size = ntohs (mod->size); | 3080 | size, |
3183 | 3081 | GNUNET_MESSAGE_TYPE_PSYC_STATE_RESULT); | |
3184 | struct GNUNET_OperationResultMessage * | 3082 | result_msg->op_id = opcls->op_id; |
3185 | res = GNUNET_malloc (sizeof (*res) + size); | 3083 | result_msg->result_code = GNUNET_htonll (GNUNET_OK); |
3186 | res->header.size = htons (sizeof (*res) + size); | 3084 | GNUNET_memcpy (&result_msg[1], mod, size); |
3187 | res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_STATE_RESULT); | ||
3188 | res->op_id = opcls->op_id; | ||
3189 | res->result_code = GNUNET_htonll (GNUNET_OK); | ||
3190 | |||
3191 | GNUNET_memcpy (&res[1], mod, size); | ||
3192 | |||
3193 | /** @todo FIXME: send only to requesting client */ | 3085 | /** @todo FIXME: send only to requesting client */ |
3194 | place_send_msg (plc, &res->header); | 3086 | place_send_msg (plc, env); |
3195 | |||
3196 | GNUNET_free (res); | ||
3197 | } | 3087 | } |
3198 | 3088 | ||
3199 | 3089 | ||
@@ -3247,7 +3137,7 @@ handle_client_state_get (void *cls, | |||
3247 | uint16_t size = ntohs (req->header.size); | 3137 | uint16_t size = ntohs (req->header.size); |
3248 | const char *name = (const char *) &req[1]; | 3138 | const char *name = (const char *) &req[1]; |
3249 | 3139 | ||
3250 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 3140 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3251 | "%p State get #%" PRIu64 ": %s\n", | 3141 | "%p State get #%" PRIu64 ": %s\n", |
3252 | plc, GNUNET_ntohll (req->op_id), name); | 3142 | plc, GNUNET_ntohll (req->op_id), name); |
3253 | 3143 | ||
@@ -3300,8 +3190,6 @@ namestore_recv_records_store_result (void *cls, int32_t result, | |||
3300 | struct OperationClosure *opcls = cls; | 3190 | struct OperationClosure *opcls = cls; |
3301 | struct Client *c = opcls->client; | 3191 | struct Client *c = opcls->client; |
3302 | 3192 | ||
3303 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | ||
3304 | "namestore_recv_records_store_result\n"); | ||
3305 | // FIXME: client might have been disconnected | 3193 | // FIXME: client might have been disconnected |
3306 | client_send_result (c->client, opcls->op_id, result, err_msg, | 3194 | client_send_result (c->client, opcls->op_id, result, err_msg, |
3307 | (NULL != err_msg) ? strlen (err_msg) : 0); | 3195 | (NULL != err_msg) ? strlen (err_msg) : 0); |
@@ -3591,7 +3479,7 @@ identity_recv_ego (void *cls, struct GNUNET_IDENTITY_Ego *id_ego, | |||
3591 | if (NULL == id_ego) // end of initial list of egos | 3479 | if (NULL == id_ego) // end of initial list of egos |
3592 | return; | 3480 | return; |
3593 | 3481 | ||
3594 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 3482 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3595 | "social service received ego %s\n", | 3483 | "social service received ego %s\n", |
3596 | name); | 3484 | name); |
3597 | 3485 | ||
@@ -3643,7 +3531,7 @@ run (void *cls, | |||
3643 | const struct GNUNET_CONFIGURATION_Handle *c, | 3531 | const struct GNUNET_CONFIGURATION_Handle *c, |
3644 | struct GNUNET_SERVICE_Handle *svc) | 3532 | struct GNUNET_SERVICE_Handle *svc) |
3645 | { | 3533 | { |
3646 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 3534 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3647 | "starting social service\n"); | 3535 | "starting social service\n"); |
3648 | 3536 | ||
3649 | cfg = c; | 3537 | cfg = c; |
diff --git a/src/social/social_api.c b/src/social/social_api.c index 87b46821e..73587598b 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c | |||
@@ -399,11 +399,6 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc) | |||
399 | struct GNUNET_HashCode place_pub_hash; | 399 | struct GNUNET_HashCode place_pub_hash; |
400 | 400 | ||
401 | GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); | 401 | GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); |
402 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
403 | "%s place cleanup: %s\n", | ||
404 | GNUNET_YES == plc->is_host ? "host" : "guest", | ||
405 | GNUNET_h2s (&place_pub_hash)); | ||
406 | |||
407 | if (NULL != plc->tmit) | 402 | if (NULL != plc->tmit) |
408 | { | 403 | { |
409 | GNUNET_PSYC_transmit_destroy (plc->tmit); | 404 | GNUNET_PSYC_transmit_destroy (plc->tmit); |
@@ -416,8 +411,6 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc) | |||
416 | } | 411 | } |
417 | if (NULL != plc->mq) | 412 | if (NULL != plc->mq) |
418 | { | 413 | { |
419 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
420 | "destroying MQ (place_cleanup)\n"); | ||
421 | GNUNET_MQ_destroy (plc->mq); | 414 | GNUNET_MQ_destroy (plc->mq); |
422 | plc->mq = NULL; | 415 | plc->mq = NULL; |
423 | } | 416 | } |
@@ -441,9 +434,6 @@ place_disconnect (struct GNUNET_SOCIAL_Place *plc) | |||
441 | GNUNET_CRYPTO_hash (&plc->pub_key, | 434 | GNUNET_CRYPTO_hash (&plc->pub_key, |
442 | sizeof (plc->pub_key), | 435 | sizeof (plc->pub_key), |
443 | &place_pub_hash); | 436 | &place_pub_hash); |
444 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
445 | "place_disconnect, plc = %s\n", | ||
446 | GNUNET_h2s (&place_pub_hash)); | ||
447 | place_cleanup (plc); | 437 | place_cleanup (plc); |
448 | } | 438 | } |
449 | 439 | ||
@@ -505,7 +495,7 @@ host_recv_notice_place_leave_method (void *cls, | |||
505 | 495 | ||
506 | struct GNUNET_SOCIAL_Nym *nym = nym_get_or_create (&msg->slave_pub_key); | 496 | struct GNUNET_SOCIAL_Nym *nym = nym_get_or_create (&msg->slave_pub_key); |
507 | 497 | ||
508 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 498 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
509 | "Host received method for message ID %" PRIu64 " from nym %s: %s\n", | 499 | "Host received method for message ID %" PRIu64 " from nym %s: %s\n", |
510 | message_id, GNUNET_h2s (&nym->pub_key_hash), method_name); | 500 | message_id, GNUNET_h2s (&nym->pub_key_hash), method_name); |
511 | 501 | ||
@@ -513,7 +503,7 @@ host_recv_notice_place_leave_method (void *cls, | |||
513 | hst->notice_place_leave_env = GNUNET_PSYC_env_create (); | 503 | hst->notice_place_leave_env = GNUNET_PSYC_env_create (); |
514 | 504 | ||
515 | char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key); | 505 | char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key); |
516 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
517 | "_notice_place_leave: got method from nym %s (%s).\n", | 507 | "_notice_place_leave: got method from nym %s (%s).\n", |
518 | GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str); | 508 | GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str); |
519 | GNUNET_free (str); | 509 | GNUNET_free (str); |
@@ -535,7 +525,7 @@ host_recv_notice_place_leave_modifier (void *cls, | |||
535 | if (NULL == hst->notice_place_leave_env) | 525 | if (NULL == hst->notice_place_leave_env) |
536 | return; | 526 | return; |
537 | 527 | ||
538 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 528 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
539 | "Host received modifier for _notice_place_leave message with ID %" PRIu64 ":\n" | 529 | "Host received modifier for _notice_place_leave message with ID %" PRIu64 ":\n" |
540 | "%c%s: %.*s\n", | 530 | "%c%s: %.*s\n", |
541 | message_id, oper, name, value_size, (const char *) value); | 531 | message_id, oper, name, value_size, (const char *) value); |
@@ -562,7 +552,7 @@ host_recv_notice_place_leave_eom (void *cls, | |||
562 | return; | 552 | return; |
563 | 553 | ||
564 | char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key); | 554 | char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key); |
565 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
566 | "_notice_place_leave: got EOM from nym %s (%s).\n", | 556 | "_notice_place_leave: got EOM from nym %s (%s).\n", |
567 | GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str); | 557 | GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str); |
568 | GNUNET_free (str); | 558 | GNUNET_free (str); |
@@ -895,9 +885,6 @@ handle_host_enter_request (void *cls, | |||
895 | { | 885 | { |
896 | struct GNUNET_SOCIAL_Host *hst = cls; | 886 | struct GNUNET_SOCIAL_Host *hst = cls; |
897 | 887 | ||
898 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
899 | "handle_host_enter_request\n"); | ||
900 | |||
901 | if (NULL == hst->answer_door_cb) | 888 | if (NULL == hst->answer_door_cb) |
902 | return; | 889 | return; |
903 | 890 | ||
@@ -1108,7 +1095,7 @@ handle_place_leave_ack (void *cls, | |||
1108 | { | 1095 | { |
1109 | struct GNUNET_SOCIAL_Place *plc = cls; | 1096 | struct GNUNET_SOCIAL_Place *plc = cls; |
1110 | 1097 | ||
1111 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1098 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1112 | "%s left place %p\n", | 1099 | "%s left place %p\n", |
1113 | plc->is_host ? "host" : "guest", | 1100 | plc->is_host ? "host" : "guest", |
1114 | plc); | 1101 | plc); |
@@ -1151,8 +1138,6 @@ host_disconnected (void *cls, enum GNUNET_MQ_Error error) | |||
1151 | } | 1138 | } |
1152 | if (NULL != plc->mq) | 1139 | if (NULL != plc->mq) |
1153 | { | 1140 | { |
1154 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1155 | "destroying MQ (host_disconnected)\n"); | ||
1156 | GNUNET_MQ_destroy (plc->mq); | 1141 | GNUNET_MQ_destroy (plc->mq); |
1157 | plc->mq = NULL; | 1142 | plc->mq = NULL; |
1158 | } | 1143 | } |
@@ -1624,8 +1609,6 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, | |||
1624 | struct GNUNET_MessageHeader *msg; | 1609 | struct GNUNET_MessageHeader *msg; |
1625 | struct GNUNET_MQ_Envelope *envelope; | 1610 | struct GNUNET_MQ_Envelope *envelope; |
1626 | 1611 | ||
1627 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1628 | "GNUNET_SOCIAL_host_leave\n"); | ||
1629 | GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, | 1612 | GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, |
1630 | GNUNET_SOCIAL_ANNOUNCE_NONE); | 1613 | GNUNET_SOCIAL_ANNOUNCE_NONE); |
1631 | hst->plc.disconnect_cb = disconnect_cb; | 1614 | hst->plc.disconnect_cb = disconnect_cb; |
@@ -1672,8 +1655,6 @@ guest_disconnected (void *cls, enum GNUNET_MQ_Error error) | |||
1672 | } | 1655 | } |
1673 | if (NULL != plc->mq) | 1656 | if (NULL != plc->mq) |
1674 | { | 1657 | { |
1675 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1676 | "destroying MQ (guest_disconnected)\n"); | ||
1677 | GNUNET_MQ_destroy (plc->mq); | 1658 | GNUNET_MQ_destroy (plc->mq); |
1678 | plc->mq = NULL; | 1659 | plc->mq = NULL; |
1679 | } | 1660 | } |
@@ -2059,9 +2040,6 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst, | |||
2059 | { | 2040 | { |
2060 | struct GNUNET_SOCIAL_Place *plc = &gst->plc; | 2041 | struct GNUNET_SOCIAL_Place *plc = &gst->plc; |
2061 | 2042 | ||
2062 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2063 | "GNUNET_SOCIAL_guest_disconnect, gst = %p\n", | ||
2064 | gst); | ||
2065 | plc->disconnect_cb = disconnect_cb; | 2043 | plc->disconnect_cb = disconnect_cb; |
2066 | plc->disconnect_cls = cls; | 2044 | plc->disconnect_cls = cls; |
2067 | place_disconnect (plc); | 2045 | place_disconnect (plc); |
@@ -2095,10 +2073,6 @@ GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, | |||
2095 | 2073 | ||
2096 | GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL, | 2074 | GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL, |
2097 | GNUNET_SOCIAL_TALK_NONE); | 2075 | GNUNET_SOCIAL_TALK_NONE); |
2098 | |||
2099 | |||
2100 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2101 | "social_api: place_leave\n"); | ||
2102 | gst->plc.disconnect_cb = disconnect_cb; | 2076 | gst->plc.disconnect_cb = disconnect_cb; |
2103 | gst->plc.disconnect_cls = cls; | 2077 | gst->plc.disconnect_cls = cls; |
2104 | envelope = GNUNET_MQ_msg (msg, | 2078 | envelope = GNUNET_MQ_msg (msg, |