diff options
author | Julius Bünger <buenger@mytum.de> | 2015-01-28 15:55:15 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-01-28 15:55:15 +0000 |
commit | 1910f22e99dc56880c31ddccc17379dc3afa8e0f (patch) | |
tree | c2d6532e9dffa021341140f16acdfccece46b9f3 /src | |
parent | 556fd64ee2523e12066d3f3cb3adcc3cee0443da (diff) | |
download | gnunet-1910f22e99dc56880c31ddccc17379dc3afa8e0f.tar.gz gnunet-1910f22e99dc56880c31ddccc17379dc3afa8e0f.zip |
fixed size problems and removal of channel
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 71a3d55bb..36bfeba24 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -509,6 +509,8 @@ peer_is_live (void *cls, size_t size, void *buf) | |||
509 | struct GNUNET_PeerIdentity *peer; | 509 | struct GNUNET_PeerIdentity *peer; |
510 | struct PeerContext *peer_ctx; | 510 | struct PeerContext *peer_ctx; |
511 | 511 | ||
512 | //if (NULL == buf || | ||
513 | // 0 == size) | ||
512 | // TODO check | 514 | // TODO check |
513 | 515 | ||
514 | peer = (struct GNUNET_PeerIdentity *) cls; | 516 | peer = (struct GNUNET_PeerIdentity *) cls; |
@@ -719,13 +721,15 @@ resize_wrapper () | |||
719 | bigger_size = sampler_size_est_need; | 721 | bigger_size = sampler_size_est_need; |
720 | 722 | ||
721 | // TODO respect the min, max | 723 | // TODO respect the min, max |
722 | if (sampler_size > bigger_size*4) | 724 | if (sampler_size > bigger_size * 4) |
723 | { /* Shrinking */ | 725 | { /* Shrinking */ |
724 | RPS_sampler_resize (sampler_size/2); | 726 | sampler_size = sampler_size / 2; |
727 | RPS_sampler_resize (sampler_size); | ||
725 | } | 728 | } |
726 | else if (sampler_size < bigger_size) | 729 | else if (sampler_size < bigger_size) |
727 | { /* Growing */ | 730 | { /* Growing */ |
728 | RPS_sampler_resize (sampler_size*2); | 731 | sampler_size = sampler_size * 2; |
732 | RPS_sampler_resize (sampler_size); | ||
729 | } | 733 | } |
730 | } | 734 | } |
731 | 735 | ||
@@ -795,7 +799,7 @@ nse_callback (void *cls, struct GNUNET_TIME_Absolute timestamp, | |||
795 | //scale = .01; | 799 | //scale = .01; |
796 | estimate = GNUNET_NSE_log_estimate_to_n (logestimate); | 800 | estimate = GNUNET_NSE_log_estimate_to_n (logestimate); |
797 | // GNUNET_NSE_log_estimate_to_n (logestimate); | 801 | // GNUNET_NSE_log_estimate_to_n (logestimate); |
798 | estimate = pow (estimate, 1.0 / 3); | 802 | estimate = pow (estimate, 1./3); |
799 | // TODO add if std_dev is a number | 803 | // TODO add if std_dev is a number |
800 | // estimate += (std_dev * scale); | 804 | // estimate += (std_dev * scale); |
801 | if ( 0 < estimate ) { | 805 | if ( 0 < estimate ) { |
@@ -1382,22 +1386,25 @@ init_peer_cb (void *cls, | |||
1382 | peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value) | 1386 | peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
1383 | { | 1387 | { |
1384 | struct PeerContext *peer_ctx; | 1388 | struct PeerContext *peer_ctx; |
1389 | const struct GNUNET_CADET_Channel *ch = (const struct GNUNET_CADET_Channel *) cls; | ||
1385 | 1390 | ||
1386 | peer_ctx = (struct PeerContext *) value; | 1391 | peer_ctx = (struct PeerContext *) value; |
1387 | 1392 | ||
1388 | if ( NULL != peer_ctx->mq) | 1393 | if (NULL != peer_ctx->mq) |
1389 | GNUNET_MQ_destroy (peer_ctx->mq); | 1394 | GNUNET_MQ_destroy (peer_ctx->mq); |
1390 | 1395 | ||
1391 | if ( NULL != peer_ctx->is_live_task) | 1396 | if (NULL != peer_ctx->is_live_task) |
1392 | { | 1397 | { |
1393 | GNUNET_CADET_notify_transmit_ready_cancel (peer_ctx->is_live_task); | 1398 | GNUNET_CADET_notify_transmit_ready_cancel (peer_ctx->is_live_task); |
1394 | peer_ctx->is_live_task = NULL; | 1399 | peer_ctx->is_live_task = NULL; |
1395 | } | 1400 | } |
1396 | 1401 | ||
1397 | if ( NULL != peer_ctx->send_channel) | 1402 | if (NULL != peer_ctx->send_channel |
1403 | && ch != peer_ctx->send_channel) | ||
1398 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); | 1404 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); |
1399 | 1405 | ||
1400 | if ( NULL != peer_ctx->recv_channel) | 1406 | if (NULL != peer_ctx->recv_channel |
1407 | && ch != peer_ctx->recv_channel) | ||
1401 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); | 1408 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); |
1402 | 1409 | ||
1403 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key)) | 1410 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key)) |
@@ -1524,7 +1531,8 @@ cleanup_channel (void *cls, | |||
1524 | 1531 | ||
1525 | peer_ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, peer); | 1532 | peer_ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, peer); |
1526 | /* Somwewhat {ab,re}use the iterator function */ | 1533 | /* Somwewhat {ab,re}use the iterator function */ |
1527 | (void) peer_remove_cb (peer, peer, peer_ctx); | 1534 | /* Cast to void is ok, because it's used as void in peer_remove_cb */ |
1535 | (void) peer_remove_cb ((void *) channel, peer, peer_ctx); | ||
1528 | } | 1536 | } |
1529 | 1537 | ||
1530 | 1538 | ||