diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/multicast/multicast_api.c | 74 | ||||
-rw-r--r-- | src/multicast/test_multicast.c | 34 | ||||
-rw-r--r-- | src/psyc/psyc_api.c | 43 | ||||
-rw-r--r-- | src/social/social_api.c | 143 |
4 files changed, 169 insertions, 125 deletions
diff --git a/src/multicast/multicast_api.c b/src/multicast/multicast_api.c index 89a9bf5e1..ad9929dca 100644 --- a/src/multicast/multicast_api.c +++ b/src/multicast/multicast_api.c | |||
@@ -522,27 +522,51 @@ handle_member_join_decision (void *cls, | |||
522 | static void | 522 | static void |
523 | group_cleanup (struct GNUNET_MULTICAST_Group *grp) | 523 | group_cleanup (struct GNUNET_MULTICAST_Group *grp) |
524 | { | 524 | { |
525 | GNUNET_MQ_discard (grp->connect_env); | 525 | if (NULL != grp->connect_env) |
526 | { | ||
527 | GNUNET_MQ_discard (grp->connect_env); | ||
528 | grp->connect_env = NULL; | ||
529 | } | ||
530 | if (NULL != grp->mq) | ||
531 | { | ||
532 | GNUNET_MQ_destroy (grp->mq); | ||
533 | grp->mq = NULL; | ||
534 | } | ||
526 | if (NULL != grp->disconnect_cb) | 535 | if (NULL != grp->disconnect_cb) |
536 | { | ||
527 | grp->disconnect_cb (grp->disconnect_cls); | 537 | grp->disconnect_cb (grp->disconnect_cls); |
538 | grp->disconnect_cb = NULL; | ||
539 | } | ||
540 | GNUNET_free (grp); | ||
528 | } | 541 | } |
529 | 542 | ||
530 | 543 | ||
531 | static void | 544 | static void |
532 | origin_cleanup (void *cls) | 545 | group_disconnect (struct GNUNET_MULTICAST_Group *grp, |
546 | GNUNET_ContinuationCallback cb, | ||
547 | void *cls) | ||
533 | { | 548 | { |
534 | struct GNUNET_MULTICAST_Origin *orig = cls; | 549 | grp->is_disconnecting = GNUNET_YES; |
535 | group_cleanup (&orig->grp); | 550 | grp->disconnect_cb = cb; |
536 | GNUNET_free (orig); | 551 | grp->disconnect_cls = cls; |
537 | } | ||
538 | |||
539 | 552 | ||
540 | static void | 553 | if (NULL != grp->mq) |
541 | member_cleanup (void *cls) | 554 | { |
542 | { | 555 | struct GNUNET_MQ_Envelope *last = GNUNET_MQ_get_last_envelope (grp->mq); |
543 | struct GNUNET_MULTICAST_Member *mem = cls; | 556 | if (NULL != last) |
544 | group_cleanup (&mem->grp); | 557 | { |
545 | GNUNET_free (mem); | 558 | GNUNET_MQ_notify_sent (last, |
559 | (GNUNET_MQ_NotifyCallback) group_cleanup, grp); | ||
560 | } | ||
561 | else | ||
562 | { | ||
563 | group_cleanup (grp); | ||
564 | } | ||
565 | } | ||
566 | else | ||
567 | { | ||
568 | group_cleanup (grp); | ||
569 | } | ||
546 | } | 570 | } |
547 | 571 | ||
548 | 572 | ||
@@ -861,17 +885,7 @@ GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *orig, | |||
861 | { | 885 | { |
862 | struct GNUNET_MULTICAST_Group *grp = &orig->grp; | 886 | struct GNUNET_MULTICAST_Group *grp = &orig->grp; |
863 | 887 | ||
864 | grp->is_disconnecting = GNUNET_YES; | 888 | group_disconnect (grp, stop_cb, stop_cls); |
865 | grp->disconnect_cb = stop_cb; | ||
866 | grp->disconnect_cls = stop_cls; | ||
867 | |||
868 | // FIXME: wait till queued messages are sent | ||
869 | if (NULL != grp->mq) | ||
870 | { | ||
871 | GNUNET_MQ_destroy (grp->mq); | ||
872 | grp->mq = NULL; | ||
873 | } | ||
874 | origin_cleanup (orig); | ||
875 | } | 889 | } |
876 | 890 | ||
877 | 891 | ||
@@ -1198,23 +1212,13 @@ GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *mem, | |||
1198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Member parting.\n", mem); | 1212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Member parting.\n", mem); |
1199 | struct GNUNET_MULTICAST_Group *grp = &mem->grp; | 1213 | struct GNUNET_MULTICAST_Group *grp = &mem->grp; |
1200 | 1214 | ||
1201 | grp->is_disconnecting = GNUNET_YES; | ||
1202 | grp->disconnect_cb = part_cb; | ||
1203 | grp->disconnect_cls = part_cls; | ||
1204 | |||
1205 | mem->join_dcsn_cb = NULL; | 1215 | mem->join_dcsn_cb = NULL; |
1206 | grp->join_req_cb = NULL; | 1216 | grp->join_req_cb = NULL; |
1207 | grp->message_cb = NULL; | 1217 | grp->message_cb = NULL; |
1208 | grp->replay_msg_cb = NULL; | 1218 | grp->replay_msg_cb = NULL; |
1209 | grp->replay_frag_cb = NULL; | 1219 | grp->replay_frag_cb = NULL; |
1210 | 1220 | ||
1211 | // FIXME: wait till queued messages are sent | 1221 | group_disconnect (grp, part_cb, part_cls); |
1212 | if (NULL != grp->mq) | ||
1213 | { | ||
1214 | GNUNET_MQ_destroy (grp->mq); | ||
1215 | grp->mq = NULL; | ||
1216 | } | ||
1217 | member_cleanup (mem); | ||
1218 | } | 1222 | } |
1219 | 1223 | ||
1220 | 1224 | ||
diff --git a/src/multicast/test_multicast.c b/src/multicast/test_multicast.c index 63f162d00..a4288e93d 100644 --- a/src/multicast/test_multicast.c +++ b/src/multicast/test_multicast.c | |||
@@ -239,7 +239,7 @@ member_recv_join_request (void *cls, | |||
239 | const struct GNUNET_MessageHeader *join_msg, | 239 | const struct GNUNET_MessageHeader *join_msg, |
240 | struct GNUNET_MULTICAST_JoinHandle *jh) | 240 | struct GNUNET_MULTICAST_JoinHandle *jh) |
241 | { | 241 | { |
242 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 242 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
243 | "Test #%u: member_recv_join_request()\n", test); | 243 | "Test #%u: member_recv_join_request()\n", test); |
244 | } | 244 | } |
245 | 245 | ||
@@ -247,7 +247,7 @@ member_recv_join_request (void *cls, | |||
247 | static void | 247 | static void |
248 | origin_stopped (void *cls) | 248 | origin_stopped (void *cls) |
249 | { | 249 | { |
250 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 250 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
251 | "Test #%u: origin_stopped()\n", test); | 251 | "Test #%u: origin_stopped()\n", test); |
252 | end (); | 252 | end (); |
253 | } | 253 | } |
@@ -267,7 +267,7 @@ schedule_origin_stop (void *cls) | |||
267 | static void | 267 | static void |
268 | member_parted (void *cls) | 268 | member_parted (void *cls) |
269 | { | 269 | { |
270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 270 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
271 | "Test #%u: member_parted()\n", test); | 271 | "Test #%u: member_parted()\n", test); |
272 | member = NULL; | 272 | member = NULL; |
273 | 273 | ||
@@ -283,7 +283,7 @@ member_parted (void *cls) | |||
283 | 283 | ||
284 | default: | 284 | default: |
285 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 285 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
286 | "Invalid test #%d in member_recv_join_decision()\n", test); | 286 | "Invalid test #%d in member_parted()\n", test); |
287 | GNUNET_assert (0); | 287 | GNUNET_assert (0); |
288 | } | 288 | } |
289 | } | 289 | } |
@@ -292,7 +292,7 @@ member_parted (void *cls) | |||
292 | static void | 292 | static void |
293 | schedule_member_part (void *cls) | 293 | schedule_member_part (void *cls) |
294 | { | 294 | { |
295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 295 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
296 | "Test #%u: schedule_member_part()\n", test); | 296 | "Test #%u: schedule_member_part()\n", test); |
297 | GNUNET_MULTICAST_member_part (member, member_parted, NULL); | 297 | GNUNET_MULTICAST_member_part (member, member_parted, NULL); |
298 | } | 298 | } |
@@ -312,7 +312,7 @@ static void | |||
312 | member_replay_ok () | 312 | member_replay_ok () |
313 | { | 313 | { |
314 | test = TEST_MEMBER_REPLAY_OK; | 314 | test = TEST_MEMBER_REPLAY_OK; |
315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 315 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
316 | "Test #%u: member_replay_ok()\n", test); | 316 | "Test #%u: member_replay_ok()\n", test); |
317 | replay_fragment_id = 1; | 317 | replay_fragment_id = 1; |
318 | replay_flags = 1 | 1<<11; | 318 | replay_flags = 1 | 1<<11; |
@@ -325,7 +325,7 @@ static void | |||
325 | member_replay_error () | 325 | member_replay_error () |
326 | { | 326 | { |
327 | test = TEST_MEMBER_REPLAY_ERROR; | 327 | test = TEST_MEMBER_REPLAY_ERROR; |
328 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 328 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
329 | "Test #%u: member_replay_error()\n", test); | 329 | "Test #%u: member_replay_error()\n", test); |
330 | replay_fragment_id = 1234; | 330 | replay_fragment_id = 1234; |
331 | replay_flags = 11 | 1<<11; | 331 | replay_flags = 11 | 1<<11; |
@@ -342,7 +342,7 @@ origin_recv_replay_msg (void *cls, | |||
342 | uint64_t flags, | 342 | uint64_t flags, |
343 | struct GNUNET_MULTICAST_ReplayHandle *rh) | 343 | struct GNUNET_MULTICAST_ReplayHandle *rh) |
344 | { | 344 | { |
345 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 345 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
346 | "Test #%u: origin_recv_replay_msg()\n", test); | 346 | "Test #%u: origin_recv_replay_msg()\n", test); |
347 | GNUNET_assert (0); | 347 | GNUNET_assert (0); |
348 | } | 348 | } |
@@ -356,7 +356,7 @@ member_recv_replay_msg (void *cls, | |||
356 | uint64_t flags, | 356 | uint64_t flags, |
357 | struct GNUNET_MULTICAST_ReplayHandle *rh) | 357 | struct GNUNET_MULTICAST_ReplayHandle *rh) |
358 | { | 358 | { |
359 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 359 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
360 | "Test #%u: member_recv_replay_msg()\n", test); | 360 | "Test #%u: member_recv_replay_msg()\n", test); |
361 | GNUNET_assert (0); | 361 | GNUNET_assert (0); |
362 | } | 362 | } |
@@ -369,7 +369,7 @@ origin_recv_replay_frag (void *cls, | |||
369 | uint64_t flags, | 369 | uint64_t flags, |
370 | struct GNUNET_MULTICAST_ReplayHandle *rh) | 370 | struct GNUNET_MULTICAST_ReplayHandle *rh) |
371 | { | 371 | { |
372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 372 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
373 | "Test #%u: origin_recv_replay_frag()" | 373 | "Test #%u: origin_recv_replay_frag()" |
374 | " - fragment_id=%" PRIu64 " flags=%" PRIu64 "\n", | 374 | " - fragment_id=%" PRIu64 " flags=%" PRIu64 "\n", |
375 | test, fragment_id, flags); | 375 | test, fragment_id, flags); |
@@ -416,7 +416,7 @@ member_recv_replay_frag (void *cls, | |||
416 | uint64_t flags, | 416 | uint64_t flags, |
417 | struct GNUNET_MULTICAST_ReplayHandle *rh) | 417 | struct GNUNET_MULTICAST_ReplayHandle *rh) |
418 | { | 418 | { |
419 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 419 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
420 | "Test #%u: member_recv_replay_frag()\n", test); | 420 | "Test #%u: member_recv_replay_frag()\n", test); |
421 | GNUNET_assert (0); | 421 | GNUNET_assert (0); |
422 | } | 422 | } |
@@ -427,7 +427,7 @@ origin_recv_request (void *cls, | |||
427 | const struct GNUNET_MULTICAST_RequestHeader *req) | 427 | const struct GNUNET_MULTICAST_RequestHeader *req) |
428 | { | 428 | { |
429 | struct OriginClosure *ocls = cls; | 429 | struct OriginClosure *ocls = cls; |
430 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 430 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
431 | "Test #%u: origin_recv_request()\n", test); | 431 | "Test #%u: origin_recv_request()\n", test); |
432 | if (++ocls->n != ocls->msgs_expected) | 432 | if (++ocls->n != ocls->msgs_expected) |
433 | return; | 433 | return; |
@@ -446,7 +446,7 @@ static void | |||
446 | member_to_origin () | 446 | member_to_origin () |
447 | { | 447 | { |
448 | test = TEST_MEMBER_TO_ORIGIN; | 448 | test = TEST_MEMBER_TO_ORIGIN; |
449 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 449 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
450 | "Test #%u: member_to_origin()\n", test); | 450 | "Test #%u: member_to_origin()\n", test); |
451 | 451 | ||
452 | struct TransmitClosure *tmit = &tmit_cls; | 452 | struct TransmitClosure *tmit = &tmit_cls; |
@@ -471,7 +471,7 @@ member_recv_message (void *cls, | |||
471 | { | 471 | { |
472 | struct MemberClosure *mcls = cls; | 472 | struct MemberClosure *mcls = cls; |
473 | 473 | ||
474 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 474 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
475 | "Test #%u: member_recv_message() %u/%u\n", | 475 | "Test #%u: member_recv_message() %u/%u\n", |
476 | test, | 476 | test, |
477 | (unsigned int) (mcls->n + 1), | 477 | (unsigned int) (mcls->n + 1), |
@@ -505,7 +505,7 @@ origin_recv_message (void *cls, | |||
505 | const struct GNUNET_MULTICAST_MessageHeader *msg) | 505 | const struct GNUNET_MULTICAST_MessageHeader *msg) |
506 | { | 506 | { |
507 | struct OriginClosure *ocls = cls; | 507 | struct OriginClosure *ocls = cls; |
508 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 508 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
509 | "Test #%u: origin_recv_message() %u/%u\n", | 509 | "Test #%u: origin_recv_message() %u/%u\n", |
510 | test, ocls->n + 1, ocls->msgs_expected); | 510 | test, ocls->n + 1, ocls->msgs_expected); |
511 | if (++ocls->n != ocls->msgs_expected) | 511 | if (++ocls->n != ocls->msgs_expected) |
@@ -562,7 +562,7 @@ member_recv_join_decision (void *cls, | |||
562 | const struct GNUNET_PeerIdentity *relays, | 562 | const struct GNUNET_PeerIdentity *relays, |
563 | const struct GNUNET_MessageHeader *join_msg) | 563 | const struct GNUNET_MessageHeader *join_msg) |
564 | { | 564 | { |
565 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 565 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
566 | "Test #%u: member_recv_join_decision() - is_admitted: %d\n", | 566 | "Test #%u: member_recv_join_decision() - is_admitted: %d\n", |
567 | test, is_admitted); | 567 | test, is_admitted); |
568 | 568 | ||
@@ -597,7 +597,7 @@ origin_recv_join_request (void *cls, | |||
597 | const struct GNUNET_MessageHeader *join_msg, | 597 | const struct GNUNET_MessageHeader *join_msg, |
598 | struct GNUNET_MULTICAST_JoinHandle *jh) | 598 | struct GNUNET_MULTICAST_JoinHandle *jh) |
599 | { | 599 | { |
600 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 600 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
601 | "Test #%u: origin_recv_join_request()\n", test); | 601 | "Test #%u: origin_recv_join_request()\n", test); |
602 | 602 | ||
603 | GNUNET_assert (0 == memcmp (mem_key, &member_pub_key, sizeof (member_pub_key))); | 603 | GNUNET_assert (0 == memcmp (mem_key, &member_pub_key, sizeof (member_pub_key))); |
diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index 2f6a15bab..8e960c7be 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c | |||
@@ -548,29 +548,17 @@ channel_cleanup (struct GNUNET_PSYC_Channel *chn) | |||
548 | GNUNET_MQ_discard (chn->connect_env); | 548 | GNUNET_MQ_discard (chn->connect_env); |
549 | chn->connect_env = NULL; | 549 | chn->connect_env = NULL; |
550 | } | 550 | } |
551 | if (NULL != chn->mq) | ||
552 | { | ||
553 | GNUNET_MQ_destroy (chn->mq); | ||
554 | chn->mq = NULL; | ||
555 | } | ||
551 | if (NULL != chn->disconnect_cb) | 556 | if (NULL != chn->disconnect_cb) |
552 | { | 557 | { |
553 | chn->disconnect_cb (chn->disconnect_cls); | 558 | chn->disconnect_cb (chn->disconnect_cls); |
554 | chn->disconnect_cb = NULL; | 559 | chn->disconnect_cb = NULL; |
555 | } | 560 | } |
556 | } | 561 | GNUNET_free (chn); |
557 | |||
558 | |||
559 | static void | ||
560 | master_cleanup (void *cls) | ||
561 | { | ||
562 | struct GNUNET_PSYC_Master *mst = cls; | ||
563 | channel_cleanup (&mst->chn); | ||
564 | GNUNET_free (mst); | ||
565 | } | ||
566 | |||
567 | |||
568 | static void | ||
569 | slave_cleanup (void *cls) | ||
570 | { | ||
571 | struct GNUNET_PSYC_Slave *slv = cls; | ||
572 | channel_cleanup (&slv->chn); | ||
573 | GNUNET_free (slv); | ||
574 | } | 562 | } |
575 | 563 | ||
576 | 564 | ||
@@ -583,11 +571,22 @@ channel_disconnect (struct GNUNET_PSYC_Channel *chn, | |||
583 | chn->disconnect_cb = cb; | 571 | chn->disconnect_cb = cb; |
584 | chn->disconnect_cls = cls; | 572 | chn->disconnect_cls = cls; |
585 | 573 | ||
586 | // FIXME: wait till queued messages are sent | ||
587 | if (NULL != chn->mq) | 574 | if (NULL != chn->mq) |
588 | { | 575 | { |
589 | GNUNET_MQ_destroy (chn->mq); | 576 | struct GNUNET_MQ_Envelope *last = GNUNET_MQ_get_last_envelope (chn->mq); |
590 | chn->mq = NULL; | 577 | if (NULL != last) |
578 | { | ||
579 | GNUNET_MQ_notify_sent (last, | ||
580 | (GNUNET_MQ_NotifyCallback) channel_cleanup, chn); | ||
581 | } | ||
582 | else | ||
583 | { | ||
584 | channel_cleanup (chn); | ||
585 | } | ||
586 | } | ||
587 | else | ||
588 | { | ||
589 | channel_cleanup (chn); | ||
591 | } | 590 | } |
592 | } | 591 | } |
593 | 592 | ||
@@ -772,7 +771,6 @@ GNUNET_PSYC_master_stop (struct GNUNET_PSYC_Master *mst, | |||
772 | /* FIXME: send msg to service */ | 771 | /* FIXME: send msg to service */ |
773 | 772 | ||
774 | channel_disconnect (chn, stop_cb, stop_cls); | 773 | channel_disconnect (chn, stop_cb, stop_cls); |
775 | master_cleanup (mst); | ||
776 | } | 774 | } |
777 | 775 | ||
778 | 776 | ||
@@ -1107,7 +1105,6 @@ GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slv, | |||
1107 | /* FIXME: send msg to service */ | 1105 | /* FIXME: send msg to service */ |
1108 | 1106 | ||
1109 | channel_disconnect (chn, part_cb, part_cls); | 1107 | channel_disconnect (chn, part_cb, part_cls); |
1110 | slave_cleanup (slv); | ||
1111 | } | 1108 | } |
1112 | 1109 | ||
1113 | 1110 | ||
diff --git a/src/social/social_api.c b/src/social/social_api.c index 9f15b4146..c08de0356 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c | |||
@@ -359,7 +359,6 @@ struct GNUNET_SOCIAL_LookHandle | |||
359 | 359 | ||
360 | struct ZoneAddPlaceHandle | 360 | struct ZoneAddPlaceHandle |
361 | { | 361 | { |
362 | struct ZoneAddPlaceRequest *req; | ||
363 | GNUNET_ResultCallback result_cb; | 362 | GNUNET_ResultCallback result_cb; |
364 | void *result_cls; | 363 | void *result_cls; |
365 | }; | 364 | }; |
@@ -1007,6 +1006,28 @@ handle_app_place_end (void *cls, | |||
1007 | } | 1006 | } |
1008 | 1007 | ||
1009 | 1008 | ||
1009 | /*** CLEANUP / DISCONNECT ***/ | ||
1010 | |||
1011 | |||
1012 | static void | ||
1013 | host_cleanup (struct GNUNET_SOCIAL_Host *hst) | ||
1014 | { | ||
1015 | if (NULL != hst->slicer) | ||
1016 | { | ||
1017 | GNUNET_PSYC_slicer_destroy (hst->slicer); | ||
1018 | hst->slicer = NULL; | ||
1019 | } | ||
1020 | GNUNET_free (hst); | ||
1021 | } | ||
1022 | |||
1023 | |||
1024 | static void | ||
1025 | guest_cleanup (struct GNUNET_SOCIAL_Guest *gst) | ||
1026 | { | ||
1027 | GNUNET_free (gst); | ||
1028 | } | ||
1029 | |||
1030 | |||
1010 | static void | 1031 | static void |
1011 | place_cleanup (struct GNUNET_SOCIAL_Place *plc) | 1032 | place_cleanup (struct GNUNET_SOCIAL_Place *plc) |
1012 | { | 1033 | { |
@@ -1027,32 +1048,59 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc) | |||
1027 | GNUNET_MQ_discard (plc->connect_env); | 1048 | GNUNET_MQ_discard (plc->connect_env); |
1028 | plc->connect_env = NULL; | 1049 | plc->connect_env = NULL; |
1029 | } | 1050 | } |
1051 | if (NULL != plc->mq) | ||
1052 | { | ||
1053 | GNUNET_MQ_destroy (plc->mq); | ||
1054 | plc->mq = NULL; | ||
1055 | } | ||
1030 | if (NULL != plc->disconnect_cb) | 1056 | if (NULL != plc->disconnect_cb) |
1031 | { | 1057 | { |
1032 | plc->disconnect_cb (plc->disconnect_cls); | 1058 | plc->disconnect_cb (plc->disconnect_cls); |
1033 | plc->disconnect_cb = NULL; | 1059 | plc->disconnect_cb = NULL; |
1034 | } | 1060 | } |
1061 | |||
1062 | (GNUNET_YES == plc->is_host) | ||
1063 | ? host_cleanup ((struct GNUNET_SOCIAL_Host *) plc) | ||
1064 | : guest_cleanup ((struct GNUNET_SOCIAL_Guest *) plc); | ||
1035 | } | 1065 | } |
1036 | 1066 | ||
1037 | 1067 | ||
1038 | static void | 1068 | void |
1039 | host_cleanup (struct GNUNET_SOCIAL_Host *hst) | 1069 | place_disconnect (struct GNUNET_SOCIAL_Place *plc, |
1070 | GNUNET_ContinuationCallback disconnect_cb, | ||
1071 | void *disconnect_cls) | ||
1040 | { | 1072 | { |
1041 | place_cleanup (&hst->plc); | 1073 | plc->disconnect_cb = disconnect_cb; |
1042 | if (NULL != hst->slicer) | 1074 | plc->disconnect_cls = disconnect_cls; |
1075 | |||
1076 | if (NULL != plc->mq) | ||
1043 | { | 1077 | { |
1044 | GNUNET_PSYC_slicer_destroy (hst->slicer); | 1078 | struct GNUNET_MQ_Envelope *last = GNUNET_MQ_get_last_envelope (plc->mq); |
1045 | hst->slicer = NULL; | 1079 | if (NULL != last) |
1080 | { | ||
1081 | GNUNET_MQ_notify_sent (last, | ||
1082 | (GNUNET_MQ_NotifyCallback) place_cleanup, plc); | ||
1083 | } | ||
1084 | else | ||
1085 | { | ||
1086 | place_cleanup (plc); | ||
1087 | } | ||
1088 | } | ||
1089 | else | ||
1090 | { | ||
1091 | place_cleanup (plc); | ||
1046 | } | 1092 | } |
1047 | GNUNET_free (hst); | ||
1048 | } | 1093 | } |
1049 | 1094 | ||
1050 | 1095 | ||
1051 | static void | 1096 | void |
1052 | guest_cleanup (struct GNUNET_SOCIAL_Guest *gst) | 1097 | place_leave (struct GNUNET_SOCIAL_Place *plc) |
1053 | { | 1098 | { |
1054 | place_cleanup (&gst->plc); | 1099 | struct GNUNET_MessageHeader *msg; |
1055 | GNUNET_free (gst); | 1100 | struct GNUNET_MQ_Envelope * |
1101 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); | ||
1102 | |||
1103 | GNUNET_MQ_send (plc->mq, env); | ||
1056 | } | 1104 | } |
1057 | 1105 | ||
1058 | 1106 | ||
@@ -1518,34 +1566,6 @@ GNUNET_SOCIAL_host_get_place (struct GNUNET_SOCIAL_Host *hst) | |||
1518 | } | 1566 | } |
1519 | 1567 | ||
1520 | 1568 | ||
1521 | void | ||
1522 | place_leave (struct GNUNET_SOCIAL_Place *plc) | ||
1523 | { | ||
1524 | struct GNUNET_MessageHeader *msg; | ||
1525 | struct GNUNET_MQ_Envelope * | ||
1526 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); | ||
1527 | |||
1528 | GNUNET_MQ_send (plc->mq, env); | ||
1529 | } | ||
1530 | |||
1531 | |||
1532 | void | ||
1533 | place_disconnect (struct GNUNET_SOCIAL_Place *plc, | ||
1534 | GNUNET_ContinuationCallback disconnect_cb, | ||
1535 | void *disconnect_cls) | ||
1536 | { | ||
1537 | plc->disconnect_cb = disconnect_cb; | ||
1538 | plc->disconnect_cls = disconnect_cls; | ||
1539 | |||
1540 | // FIXME: wait till queued messages are sent | ||
1541 | if (NULL != plc->mq) | ||
1542 | { | ||
1543 | GNUNET_MQ_destroy (plc->mq); | ||
1544 | plc->mq = NULL; | ||
1545 | } | ||
1546 | } | ||
1547 | |||
1548 | |||
1549 | /** | 1569 | /** |
1550 | * Disconnect from a home. | 1570 | * Disconnect from a home. |
1551 | * | 1571 | * |
@@ -1560,7 +1580,6 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst, | |||
1560 | void *cls) | 1580 | void *cls) |
1561 | { | 1581 | { |
1562 | place_disconnect (&hst->plc, disconnect_cb, cls); | 1582 | place_disconnect (&hst->plc, disconnect_cb, cls); |
1563 | host_cleanup (hst); | ||
1564 | } | 1583 | } |
1565 | 1584 | ||
1566 | 1585 | ||
@@ -2016,7 +2035,6 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst, | |||
2016 | void *cls) | 2035 | void *cls) |
2017 | { | 2036 | { |
2018 | place_disconnect (&gst->plc, disconnect_cb, cls); | 2037 | place_disconnect (&gst->plc, disconnect_cb, cls); |
2019 | guest_cleanup (gst); | ||
2020 | } | 2038 | } |
2021 | 2039 | ||
2022 | 2040 | ||
@@ -2363,7 +2381,6 @@ op_recv_zone_add_place_result (void *cls, int64_t result, | |||
2363 | if (NULL != add_plc->result_cb) | 2381 | if (NULL != add_plc->result_cb) |
2364 | add_plc->result_cb (add_plc->result_cls, result, err_msg, err_msg_size); | 2382 | add_plc->result_cb (add_plc->result_cls, result, err_msg, err_msg_size); |
2365 | 2383 | ||
2366 | GNUNET_free (add_plc->req); | ||
2367 | GNUNET_free (add_plc); | 2384 | GNUNET_free (add_plc); |
2368 | } | 2385 | } |
2369 | 2386 | ||
@@ -2435,7 +2452,6 @@ GNUNET_SOCIAL_zone_add_place (const struct GNUNET_SOCIAL_App *app, | |||
2435 | GNUNET_memcpy (p, relays, relay_size); | 2452 | GNUNET_memcpy (p, relays, relay_size); |
2436 | 2453 | ||
2437 | struct ZoneAddPlaceHandle * add_plc = GNUNET_malloc (sizeof (*add_plc)); | 2454 | struct ZoneAddPlaceHandle * add_plc = GNUNET_malloc (sizeof (*add_plc)); |
2438 | add_plc->req = preq; | ||
2439 | add_plc->result_cb = result_cb; | 2455 | add_plc->result_cb = result_cb; |
2440 | add_plc->result_cls = result_cls; | 2456 | add_plc->result_cls = result_cls; |
2441 | 2457 | ||
@@ -2657,6 +2673,22 @@ GNUNET_SOCIAL_app_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
2657 | } | 2673 | } |
2658 | 2674 | ||
2659 | 2675 | ||
2676 | static void | ||
2677 | app_cleanup (struct GNUNET_SOCIAL_App *app) | ||
2678 | { | ||
2679 | if (NULL != app->mq) | ||
2680 | { | ||
2681 | GNUNET_MQ_destroy (app->mq); | ||
2682 | app->mq = NULL; | ||
2683 | } | ||
2684 | if (NULL != app->disconnect_cb) | ||
2685 | { | ||
2686 | app->disconnect_cb (app->disconnect_cls); | ||
2687 | app->disconnect_cb = NULL; | ||
2688 | } | ||
2689 | GNUNET_free (app); | ||
2690 | } | ||
2691 | |||
2660 | /** | 2692 | /** |
2661 | * Disconnect application. | 2693 | * Disconnect application. |
2662 | * | 2694 | * |
@@ -2672,15 +2704,26 @@ GNUNET_SOCIAL_app_disconnect (struct GNUNET_SOCIAL_App *app, | |||
2672 | GNUNET_ContinuationCallback disconnect_cb, | 2704 | GNUNET_ContinuationCallback disconnect_cb, |
2673 | void *disconnect_cls) | 2705 | void *disconnect_cls) |
2674 | { | 2706 | { |
2675 | // FIXME: wait till queued messages are sent | 2707 | app->disconnect_cb = disconnect_cb; |
2708 | app->disconnect_cls = disconnect_cls; | ||
2709 | |||
2676 | if (NULL != app->mq) | 2710 | if (NULL != app->mq) |
2677 | { | 2711 | { |
2678 | GNUNET_MQ_destroy (app->mq); | 2712 | struct GNUNET_MQ_Envelope *last = GNUNET_MQ_get_last_envelope (app->mq); |
2679 | app->mq = NULL; | 2713 | if (NULL != last) |
2714 | { | ||
2715 | GNUNET_MQ_notify_sent (last, | ||
2716 | (GNUNET_MQ_NotifyCallback) app_cleanup, app); | ||
2717 | } | ||
2718 | else | ||
2719 | { | ||
2720 | app_cleanup (app); | ||
2721 | } | ||
2722 | } | ||
2723 | else | ||
2724 | { | ||
2725 | app_cleanup (app); | ||
2680 | } | 2726 | } |
2681 | |||
2682 | if (NULL != disconnect_cb) | ||
2683 | disconnect_cb (disconnect_cls); | ||
2684 | } | 2727 | } |
2685 | 2728 | ||
2686 | 2729 | ||