diff options
author | Gabor X Toth <*@tg-x.net> | 2013-10-10 18:08:53 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2013-10-10 18:08:53 +0000 |
commit | 1b5d4aba9d8bbcb62c93f96782e3567f6f79d0cb (patch) | |
tree | 3cd28bfee831af0417c2dcbb543c03481517ad00 /src/multicast | |
parent | 67a8e21eedb6d35fec76841d4a1a6b4b41b37879 (diff) | |
download | gnunet-1b5d4aba9d8bbcb62c93f96782e3567f6f79d0cb.tar.gz gnunet-1b5d4aba9d8bbcb62c93f96782e3567f6f79d0cb.zip |
PSYC: master msg transmission
Diffstat (limited to 'src/multicast')
-rw-r--r-- | src/multicast/multicast_api.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/multicast/multicast_api.c b/src/multicast/multicast_api.c index 3dbc07f5d..49e648468 100644 --- a/src/multicast/multicast_api.c +++ b/src/multicast/multicast_api.c | |||
@@ -30,7 +30,10 @@ | |||
30 | #include "gnunet_multicast_service.h" | 30 | #include "gnunet_multicast_service.h" |
31 | #include "multicast.h" | 31 | #include "multicast.h" |
32 | 32 | ||
33 | /** | 33 | #define LOG(kind,...) GNUNET_log_from (kind, "multicast-api",__VA_ARGS__) |
34 | |||
35 | |||
36 | /** | ||
34 | * Handle for a request to send a message to all multicast group members | 37 | * Handle for a request to send a message to all multicast group members |
35 | * (from the origin). | 38 | * (from the origin). |
36 | */ | 39 | */ |
@@ -38,6 +41,7 @@ struct GNUNET_MULTICAST_OriginMessageHandle | |||
38 | { | 41 | { |
39 | GNUNET_MULTICAST_OriginTransmitNotify notify; | 42 | GNUNET_MULTICAST_OriginTransmitNotify notify; |
40 | void *notify_cls; | 43 | void *notify_cls; |
44 | struct GNUNET_MULTICAST_Origin *origin; | ||
41 | 45 | ||
42 | uint64_t message_id; | 46 | uint64_t message_id; |
43 | uint64_t group_generation; | 47 | uint64_t group_generation; |
@@ -353,6 +357,7 @@ GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
353 | static void | 357 | static void |
354 | schedule_origin_to_all (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 358 | schedule_origin_to_all (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
355 | { | 359 | { |
360 | LOG (GNUNET_ERROR_TYPE_DEBUG, "schedule_origin_to_all()\n"); | ||
356 | struct GNUNET_MULTICAST_Origin *orig = cls; | 361 | struct GNUNET_MULTICAST_Origin *orig = cls; |
357 | struct GNUNET_MULTICAST_OriginMessageHandle *mh = &orig->msg_handle; | 362 | struct GNUNET_MULTICAST_OriginMessageHandle *mh = &orig->msg_handle; |
358 | 363 | ||
@@ -361,12 +366,18 @@ schedule_origin_to_all (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
361 | = GNUNET_malloc (sizeof (*msg) + buf_size); | 366 | = GNUNET_malloc (sizeof (*msg) + buf_size); |
362 | int ret = mh->notify (mh->notify_cls, &buf_size, &msg[1]); | 367 | int ret = mh->notify (mh->notify_cls, &buf_size, &msg[1]); |
363 | 368 | ||
364 | if (ret != GNUNET_YES || ret != GNUNET_NO) | 369 | if (! (GNUNET_YES == ret || GNUNET_NO == ret) |
370 | || buf_size > GNUNET_MULTICAST_FRAGMENT_MAX_SIZE) | ||
365 | { | 371 | { |
372 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
373 | "MasterTransmitNotify() returned error or invalid message size.\n"); | ||
366 | /* FIXME: handle error */ | 374 | /* FIXME: handle error */ |
367 | return; | 375 | return; |
368 | } | 376 | } |
369 | 377 | ||
378 | if (GNUNET_NO == ret && 0 == buf_size) | ||
379 | return; /* Transmission paused. */ | ||
380 | |||
370 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE); | 381 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE); |
371 | msg->header.size = htons (buf_size); | 382 | msg->header.size = htons (buf_size); |
372 | msg->message_id = mh->message_id; | 383 | msg->message_id = mh->message_id; |
@@ -393,12 +404,12 @@ schedule_origin_to_all (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
393 | * returned signed message. | 404 | * returned signed message. |
394 | * FIXME: Also send to local members in this group. | 405 | * FIXME: Also send to local members in this group. |
395 | */ | 406 | */ |
396 | orig->message_cb (orig->cls, msg); | 407 | orig->message_cb (orig->cls, (const struct GNUNET_MessageHeader *) msg); |
397 | 408 | ||
398 | if (GNUNET_NO == ret) | 409 | if (GNUNET_NO == ret) |
399 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 410 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
400 | (GNUNET_TIME_UNIT_SECONDS, 1), | 411 | (GNUNET_TIME_UNIT_SECONDS, 1), |
401 | schedule_origin_to_all, mh); | 412 | schedule_origin_to_all, orig); |
402 | 413 | ||
403 | } | 414 | } |
404 | 415 | ||
@@ -421,6 +432,7 @@ GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin, | |||
421 | void *notify_cls) | 432 | void *notify_cls) |
422 | { | 433 | { |
423 | struct GNUNET_MULTICAST_OriginMessageHandle *mh = &origin->msg_handle; | 434 | struct GNUNET_MULTICAST_OriginMessageHandle *mh = &origin->msg_handle; |
435 | mh->origin = origin; | ||
424 | mh->message_id = message_id; | 436 | mh->message_id = message_id; |
425 | mh->group_generation = group_generation; | 437 | mh->group_generation = group_generation; |
426 | mh->notify = notify; | 438 | mh->notify = notify; |
@@ -441,7 +453,7 @@ GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin, | |||
441 | void | 453 | void |
442 | GNUNET_MULTICAST_origin_to_all_resume (struct GNUNET_MULTICAST_OriginMessageHandle *mh) | 454 | GNUNET_MULTICAST_origin_to_all_resume (struct GNUNET_MULTICAST_OriginMessageHandle *mh) |
443 | { | 455 | { |
444 | 456 | GNUNET_SCHEDULER_add_now (schedule_origin_to_all, mh->origin); | |
445 | } | 457 | } |
446 | 458 | ||
447 | 459 | ||