aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-10-27 09:47:07 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-10-27 09:47:07 +0000
commit92ea81543438aebee77ceec02800da3e4da6a421 (patch)
tree5f5075ae7e9cc68881fd94f7f98795b755fbd374 /src/fs/gnunet-service-fs.c
parent4d14bcd5d233c1aeef03b34ec9d4b875a5d7bd2b (diff)
downloadgnunet-92ea81543438aebee77ceec02800da3e4da6a421.tar.gz
gnunet-92ea81543438aebee77ceec02800da3e4da6a421.zip
Refactoring gnunet time
Diffstat (limited to 'src/fs/gnunet-service-fs.c')
-rw-r--r--src/fs/gnunet-service-fs.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 9c1b3f04f..1cd114261 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -928,7 +928,7 @@ update_datastore_delays (struct GNUNET_TIME_Absolute start)
928 928
929 delay = GNUNET_TIME_absolute_get_duration (start); 929 delay = GNUNET_TIME_absolute_get_duration (start);
930 GNUNET_LOAD_update (datastore_get_load, 930 GNUNET_LOAD_update (datastore_get_load,
931 delay.value); 931 delay.rel_value);
932} 932}
933 933
934 934
@@ -1032,7 +1032,7 @@ consider_migration (void *cls,
1032 unsigned int repl; 1032 unsigned int repl;
1033 1033
1034 /* consider 'cp' as a migration target for mb */ 1034 /* consider 'cp' as a migration target for mb */
1035 if (GNUNET_TIME_absolute_get_remaining (cp->migration_blocked).value > 0) 1035 if (GNUNET_TIME_absolute_get_remaining (cp->migration_blocked).rel_value > 0)
1036 return GNUNET_YES; /* peer has requested no migration! */ 1036 return GNUNET_YES; /* peer has requested no migration! */
1037 if (mb != NULL) 1037 if (mb != NULL)
1038 { 1038 {
@@ -1496,7 +1496,7 @@ destroy_pending_request (struct PendingRequest *pr)
1496 pr)) 1496 pr))
1497 { 1497 {
1498 GNUNET_LOAD_update (rt_entry_lifetime, 1498 GNUNET_LOAD_update (rt_entry_lifetime,
1499 GNUNET_TIME_absolute_get_duration (pr->start_time).value); 1499 GNUNET_TIME_absolute_get_duration (pr->start_time).rel_value);
1500 } 1500 }
1501 if (pr->qe != NULL) 1501 if (pr->qe != NULL)
1502 { 1502 {
@@ -2127,7 +2127,7 @@ transmit_to_peer (void *cls,
2127 return 0; 2127 return 0;
2128 } 2128 }
2129 GNUNET_LOAD_update (cp->transmission_delay, 2129 GNUNET_LOAD_update (cp->transmission_delay,
2130 GNUNET_TIME_absolute_get_duration (cp->last_transmission_request_start).value); 2130 GNUNET_TIME_absolute_get_duration (cp->last_transmission_request_start).rel_value);
2131 now = GNUNET_TIME_absolute_get (); 2131 now = GNUNET_TIME_absolute_get ();
2132 msize = 0; 2132 msize = 0;
2133 min_delay = GNUNET_TIME_UNIT_FOREVER_REL; 2133 min_delay = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -2136,7 +2136,7 @@ transmit_to_peer (void *cls,
2136 (pm->msize <= size) ) 2136 (pm->msize <= size) )
2137 { 2137 {
2138 next_pm = pm->next; 2138 next_pm = pm->next;
2139 if (pm->delay_until.value > now.value) 2139 if (pm->delay_until.abs_value > now.abs_value)
2140 { 2140 {
2141 min_delay = GNUNET_TIME_relative_min (min_delay, 2141 min_delay = GNUNET_TIME_relative_min (min_delay,
2142 GNUNET_TIME_absolute_get_remaining (pm->delay_until)); 2142 GNUNET_TIME_absolute_get_remaining (pm->delay_until));
@@ -2783,13 +2783,13 @@ target_peer_select_cb (void *cls,
2783#endif 2783#endif
2784 /* 2b) many other requests to this peer */ 2784 /* 2b) many other requests to this peer */
2785 delay = GNUNET_TIME_absolute_get_duration (cp->last_request_times[cp->last_request_times_off % MAX_QUEUE_PER_PEER]); 2785 delay = GNUNET_TIME_absolute_get_duration (cp->last_request_times[cp->last_request_times_off % MAX_QUEUE_PER_PEER]);
2786 if (delay.value <= cp->avg_delay.value) 2786 if (delay.rel_value <= cp->avg_delay.rel_value)
2787 { 2787 {
2788#if DEBUG_FS 2788#if DEBUG_FS
2789 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2789 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2790 "NOT sending query since we send %u others to this peer in the last %llums\n", 2790 "NOT sending query since we send %u others to this peer in the last %llums\n",
2791 MAX_QUEUE_PER_PEER, 2791 MAX_QUEUE_PER_PEER,
2792 cp->avg_delay.value); 2792 cp->avg_delay.abs_value);
2793#endif 2793#endif
2794 return GNUNET_YES; /* skip */ 2794 return GNUNET_YES; /* skip */
2795 } 2795 }
@@ -2816,7 +2816,7 @@ target_peer_select_cb (void *cls,
2816 score += 1.0; /* likely successful based on hot path */ 2816 score += 1.0; /* likely successful based on hot path */
2817 } 2817 }
2818 /* 3b) include latency */ 2818 /* 3b) include latency */
2819 if (cp->avg_delay.value < 4 * TTL_DECREMENT) 2819 if (cp->avg_delay.rel_value < 4 * TTL_DECREMENT)
2820 score += 1.0; /* likely fast based on latency */ 2820 score += 1.0; /* likely fast based on latency */
2821 /* 3c) include priorities */ 2821 /* 3c) include priorities */
2822 if (cp->avg_priority <= pr->remaining_priority / 2.0) 2822 if (cp->avg_priority <= pr->remaining_priority / 2.0)
@@ -2964,7 +2964,7 @@ forward_request_task (void *cls,
2964 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2964 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2965 "No peer selected for forwarding of query `%s', will try again in %llu ms!\n", 2965 "No peer selected for forwarding of query `%s', will try again in %llu ms!\n",
2966 GNUNET_h2s (&pr->query), 2966 GNUNET_h2s (&pr->query),
2967 delay.value); 2967 delay.abs_value);
2968#endif 2968#endif
2969 pr->task = GNUNET_SCHEDULER_add_delayed (sched, 2969 pr->task = GNUNET_SCHEDULER_add_delayed (sched,
2970 delay, 2970 delay,
@@ -3211,9 +3211,9 @@ struct GNUNET_TIME_Relative art_delay;
3211 if (i < pr->used_targets_off) 3211 if (i < pr->used_targets_off)
3212 { 3212 {
3213 cur_delay = GNUNET_TIME_absolute_get_duration (pr->used_targets[i].last_request_time); 3213 cur_delay = GNUNET_TIME_absolute_get_duration (pr->used_targets[i].last_request_time);
3214 prq->sender->avg_delay.value 3214 prq->sender->avg_delay.rel_value
3215 = (prq->sender->avg_delay.value * 3215 = (prq->sender->avg_delay.rel_value *
3216 (RUNAVG_DELAY_N - 1) + cur_delay.value) / RUNAVG_DELAY_N; 3216 (RUNAVG_DELAY_N - 1) + cur_delay.rel_value) / RUNAVG_DELAY_N;
3217 prq->sender->avg_priority 3217 prq->sender->avg_priority
3218 = (prq->sender->avg_priority * 3218 = (prq->sender->avg_priority *
3219 (RUNAVG_DELAY_N - 1) + pr->priority) / (double) RUNAVG_DELAY_N; 3219 (RUNAVG_DELAY_N - 1) + pr->priority) / (double) RUNAVG_DELAY_N;
@@ -3275,7 +3275,7 @@ struct GNUNET_TIME_Relative art_delay;
3275 key, 3275 key,
3276 pr)); 3276 pr));
3277 GNUNET_LOAD_update (rt_entry_lifetime, 3277 GNUNET_LOAD_update (rt_entry_lifetime,
3278 GNUNET_TIME_absolute_get_duration (pr->start_time).value); 3278 GNUNET_TIME_absolute_get_duration (pr->start_time).rel_value);
3279 break; 3279 break;
3280 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: 3280 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
3281 GNUNET_STATISTICS_update (stats, 3281 GNUNET_STATISTICS_update (stats,
@@ -3395,7 +3395,7 @@ struct GNUNET_TIME_Relative art_delay;
3395 = GNUNET_TIME_relative_to_absolute (art_delay); 3395 = GNUNET_TIME_relative_to_absolute (art_delay);
3396 GNUNET_STATISTICS_update (stats, 3396 GNUNET_STATISTICS_update (stats,
3397 gettext_noop ("cummulative artificial delay introduced (ms)"), 3397 gettext_noop ("cummulative artificial delay introduced (ms)"),
3398 art_delay.value, 3398 art_delay.abs_value,
3399 GNUNET_NO); 3399 GNUNET_NO);
3400#endif 3400#endif
3401 reply->msize = msize; 3401 reply->msize = msize;
@@ -3469,7 +3469,7 @@ put_migration_continuation (void *cls,
3469 delay = GNUNET_TIME_absolute_get_duration (*start); 3469 delay = GNUNET_TIME_absolute_get_duration (*start);
3470 GNUNET_free (start); 3470 GNUNET_free (start);
3471 GNUNET_LOAD_update (datastore_put_load, 3471 GNUNET_LOAD_update (datastore_put_load,
3472 delay.value); 3472 delay.rel_value);
3473 if (GNUNET_OK == success) 3473 if (GNUNET_OK == success)
3474 return; 3474 return;
3475 GNUNET_STATISTICS_update (stats, 3475 GNUNET_STATISTICS_update (stats,
@@ -3594,7 +3594,7 @@ handle_p2p_put (void *cls,
3594 { 3594 {
3595 cp = GNUNET_CONTAINER_multihashmap_get (connected_peers, 3595 cp = GNUNET_CONTAINER_multihashmap_get (connected_peers,
3596 &other->hashPubKey); 3596 &other->hashPubKey);
3597 if (GNUNET_TIME_absolute_get_duration (cp->last_migration_block).value < 5000) 3597 if (GNUNET_TIME_absolute_get_duration (cp->last_migration_block).rel_value < 5000)
3598 return GNUNET_OK; /* already blocked */ 3598 return GNUNET_OK; /* already blocked */
3599 /* We're too busy; send MigrationStop message! */ 3599 /* We're too busy; send MigrationStop message! */
3600 if (GNUNET_YES != active_migration) 3600 if (GNUNET_YES != active_migration)
@@ -4105,7 +4105,7 @@ handle_p2p_get (void *cls,
4105 } 4105 }
4106 if ( (GNUNET_LOAD_get_load (cp->transmission_delay) > 3 * (1 + priority)) || 4106 if ( (GNUNET_LOAD_get_load (cp->transmission_delay) > 3 * (1 + priority)) ||
4107 (GNUNET_LOAD_get_average (cp->transmission_delay) > 4107 (GNUNET_LOAD_get_average (cp->transmission_delay) >
4108 GNUNET_CONSTANTS_MAX_CORK_DELAY.value * 2 + GNUNET_LOAD_get_average (rt_entry_lifetime)) ) 4108 GNUNET_CONSTANTS_MAX_CORK_DELAY.rel_value * 2 + GNUNET_LOAD_get_average (rt_entry_lifetime)) )
4109 { 4109 {
4110 /* don't have BW to send to peer, or would likely take longer than we have for it, 4110 /* don't have BW to send to peer, or would likely take longer than we have for it,
4111 so at best indirect the query */ 4111 so at best indirect the query */
@@ -4161,8 +4161,8 @@ handle_p2p_get (void *cls,
4161 &cdc); 4161 &cdc);
4162 if (cdc.have != NULL) 4162 if (cdc.have != NULL)
4163 { 4163 {
4164 if (cdc.have->start_time.value + cdc.have->ttl >= 4164 if (cdc.have->start_time.abs_value + cdc.have->ttl >=
4165 pr->start_time.value + pr->ttl) 4165 pr->start_time.abs_value + pr->ttl)
4166 { 4166 {
4167 /* existing request has higher TTL, drop new one! */ 4167 /* existing request has higher TTL, drop new one! */
4168 cdc.have->priority += pr->priority; 4168 cdc.have->priority += pr->priority;
@@ -4205,7 +4205,7 @@ handle_p2p_get (void *cls,
4205 4205
4206 pr->hnode = GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, 4206 pr->hnode = GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap,
4207 pr, 4207 pr,
4208 pr->start_time.value + pr->ttl); 4208 pr->start_time.abs_value + pr->ttl);
4209 4209
4210 GNUNET_STATISTICS_update (stats, 4210 GNUNET_STATISTICS_update (stats,
4211 gettext_noop ("# P2P searches received"), 4211 gettext_noop ("# P2P searches received"),