gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r13428 - gnunet/src/dht


From: gnunet
Subject: [GNUnet-SVN] r13428 - gnunet/src/dht
Date: Wed, 27 Oct 2010 12:08:46 +0200

Author: wachs
Date: 2010-10-27 12:08:46 +0200 (Wed, 27 Oct 2010)
New Revision: 13428

Modified:
   gnunet/src/dht/dht_api.c
   gnunet/src/dht/gnunet-dht-driver.c
   gnunet/src/dht/gnunet-service-dht.c
   gnunet/src/dht/test_dht_api.c
Log:
Refactoring gnunet time


Modified: gnunet/src/dht/dht_api.c
===================================================================
--- gnunet/src/dht/dht_api.c    2010-10-27 10:04:42 UTC (rev 13427)
+++ gnunet/src/dht/dht_api.c    2010-10-27 10:08:46 UTC (rev 13428)
@@ -861,14 +861,16 @@
 GNUNET_DHT_set_malicious_getter (struct GNUNET_DHT_Handle *handle,
                                 struct GNUNET_TIME_Relative frequency)
 {
-  if (frequency.value > UINT16_MAX)
+       /*
+  if (frequency.abs_value > UINT16_MAX)
     {
       GNUNET_break (0);
       return;
     }
   send_control_message (handle,
-                       GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET, frequency.value,
+                       GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET, 
frequency.abs_value,
                        NULL, NULL);
+                       */
 }
 
 /**
@@ -882,14 +884,17 @@
 GNUNET_DHT_set_malicious_putter (struct GNUNET_DHT_Handle *handle, 
                                 struct GNUNET_TIME_Relative frequency)
 {
-  if (frequency.value > UINT16_MAX)
+       /*
+  if (frequency.abs_value > UINT16_MAX)
     {
       GNUNET_break (0);
       return;
     }
+
   send_control_message (handle,
-                       GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT, frequency.value,
+                       GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT, 
frequency.abs_value,
                        NULL, NULL);
+                       */
 }
 
 

Modified: gnunet/src/dht/gnunet-dht-driver.c
===================================================================
--- gnunet/src/dht/gnunet-dht-driver.c  2010-10-27 10:04:42 UTC (rev 13427)
+++ gnunet/src/dht/gnunet-dht-driver.c  2010-10-27 10:08:46 UTC (rev 13428)
@@ -1065,7 +1065,7 @@
   test_find_peer->find_peer_context->outstanding--;
   test_find_peer->find_peer_context->total--;
   if ((0 == test_find_peer->find_peer_context->total) &&
-      
(GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).value
 > 60))
+      
(GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value
 > 60))
   {
     GNUNET_SCHEDULER_add_now(sched, &count_new_peers, 
test_find_peer->find_peer_context);
   }
@@ -1101,7 +1101,7 @@
   }
 
   test_find_peer->find_peer_context->outstanding++;
-  if 
(GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).value
 == 0)
+  if 
(GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value
 == 0)
   {
     GNUNET_SCHEDULER_add_now(sched, &decrement_find_peers, test_find_peer);
     return;
@@ -1192,13 +1192,13 @@
       /** Just try to connect the peers, don't worry about callbacks, etc. **/
       GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Peer %s has 0 connections.  
Trying to connect to %s...\n", GNUNET_i2s(&peer_count->peer_id), d2->shortname);
       timeout = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 
DEFAULT_CONNECT_TIMEOUT);
-      if (GNUNET_TIME_relative_to_absolute(timeout).value > 
find_peer_context->endtime.value)
+      if (GNUNET_TIME_relative_to_absolute(timeout).abs_value > 
find_peer_context->endtime.abs_value)
         {
           timeout = 
GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime);
         }
       GNUNET_TESTING_daemons_connect(d1, d2, timeout, 
DEFAULT_RECONNECT_ATTEMPTS, NULL, NULL);
     }
-  if (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).value > 0)
+  if (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value 
> 0)
     return GNUNET_YES;
   else
     return GNUNET_NO;
@@ -1286,13 +1286,13 @@
        *         these are very specialized cases.
        */
       GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Out of %u peers, fewest 
connections is %d\n", 
GNUNET_CONTAINER_heap_get_size(find_peer_context->peer_min_heap), 
peer_count->count);
-      if ((peer_count->count == 0) && 
(GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).value > 0))
+      if ((peer_count->count == 0) && 
(GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0))
         {
           GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Found peer with no 
connections, will choose some peer(s) at random to connect to!\n");
           GNUNET_CONTAINER_heap_iterate (find_peer_context->peer_min_heap, 
&iterate_min_heap_peers, find_peer_context);
           GNUNET_SCHEDULER_add_now(sched, &schedule_churn_find_peer_requests, 
find_peer_context);
         }
-      else if 
((GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).value > 0) && 
(find_peer_context->last_sent != 0))
+      else if 
((GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0) 
&& (find_peer_context->last_sent != 0))
         {
           GNUNET_SCHEDULER_add_now(sched, &schedule_churn_find_peer_requests, 
find_peer_context);
         }
@@ -1909,7 +1909,7 @@
       if ((find_peer_context->last_sent > 8) &&
           (find_peer_context->current_peers - 
find_peer_context->previous_peers > FIND_PEER_THRESHOLD) &&
           (find_peer_context->current_peers < 2 * 
connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) &&
-          
(GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).value > 0))
+          
(GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0))
         {
           GNUNET_SCHEDULER_add_now(sched, &schedule_find_peer_requests, 
find_peer_context);
         }
@@ -2783,7 +2783,7 @@
                                                &temp_config_number))
     all_get_timeout = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 
temp_config_number);
   else
-    all_get_timeout.value = get_timeout.value * num_gets;
+    all_get_timeout.rel_value = get_timeout.rel_value * num_gets;
 
   if (GNUNET_OK ==
         GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "get_delay",
@@ -3011,8 +3011,8 @@
   trial_info.malicious_getters = malicious_getters;
   trial_info.malicious_putters = malicious_putters;
   trial_info.malicious_droppers = malicious_droppers;
-  trial_info.malicious_get_frequency = malicious_get_frequency.value;
-  trial_info.malicious_put_frequency = malicious_put_frequency.value;
+  trial_info.malicious_get_frequency = malicious_get_frequency.rel_value;
+  trial_info.malicious_put_frequency = malicious_put_frequency.rel_value;
   trial_info.stop_closest = stop_closest;
   trial_info.stop_found = stop_found;
   trial_info.strict_kademlia = strict_kademlia;

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2010-10-27 10:04:42 UTC (rev 13427)
+++ gnunet/src/dht/gnunet-service-dht.c 2010-10-27 10:08:46 UTC (rev 13428)
@@ -947,7 +947,7 @@
   for (i = 0; i < MAX_REPLY_TIMES; i++)
   {
     average_time = GNUNET_TIME_relative_add(average_time, reply_times[i]);
-    if (reply_times[i].value == (uint64_t)0)
+    if (reply_times[i].abs_value == (uint64_t)0)
       continue;
     else
       divisor++;
@@ -958,7 +958,7 @@
   }
 
   average_time = GNUNET_TIME_relative_divide(average_time, divisor);
-  fprintf(stderr, "Avg send delay: %u sends is %llu\n", divisor, (long long 
unsigned int)average_time.value);
+  fprintf(stderr, "Avg send delay: %u sends is %llu\n", divisor, (long long 
unsigned int)average_time.abs_value);
   return average_time;
 }
 #endif
@@ -973,9 +973,9 @@
   unsigned int i;
   for (i = 0; i < MAX_REPLY_TIMES; i++)
     {
-      if (reply_times[i].value == max_time.value)
+      if (reply_times[i].rel_value == max_time.rel_value)
         {
-          reply_times[i].value = reply_times[i].value / 2;
+          reply_times[i].rel_value = reply_times[i].rel_value / 2;
           return;
         }
     }
@@ -995,12 +995,12 @@
 
   for (i = 0; i < MAX_REPLY_TIMES; i++)
   {
-    if (reply_times[i].value > max_time.value)
-      max_time.value = reply_times[i].value;
+    if (reply_times[i].rel_value > max_time.rel_value)
+      max_time.rel_value = reply_times[i].rel_value;
   }
 
-  if (max_time.value > MAX_REQUEST_TIME.value)
-    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Max send delay was %llu\n", (long 
long unsigned int)max_time.value);
+  if (max_time.rel_value > MAX_REQUEST_TIME.rel_value)
+    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Max send delay was %llu\n", (long 
long unsigned int)max_time.rel_value);
   return max_time;
 }
 
@@ -3413,7 +3413,7 @@
         }
       if ((pos != NULL) && (pos->client == msg_ctx->client)) /* Seen this 
already */
         {
-          GNUNET_CONTAINER_heap_update_cost(forward_list.minHeap, pos->hnode, 
now.value);
+          GNUNET_CONTAINER_heap_update_cost(forward_list.minHeap, pos->hnode, 
now.abs_value);
           return GNUNET_NO;
         }
     }
@@ -3435,7 +3435,7 @@
       source_info->client = msg_ctx->client;
       now = GNUNET_TIME_absolute_get_forever();
     }
-  source_info->hnode = GNUNET_CONTAINER_heap_insert(forward_list.minHeap, 
source_info, now.value);
+  source_info->hnode = GNUNET_CONTAINER_heap_insert(forward_list.minHeap, 
source_info, now.abs_value);
 #if DEBUG_DHT > 1
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "`%s:%s': Created new forward source info for %s uid 
%llu\n", my_short_id,
@@ -3554,7 +3554,7 @@
       recent_req->uid = message_context->unique_id;
       memcpy(&recent_req->key, &message_context->key, sizeof(GNUNET_HashCode));
       recent_req->remove_task = GNUNET_SCHEDULER_add_delayed(sched, 
DEFAULT_RECENT_REMOVAL, &remove_recent, recent_req);
-      recent_req->heap_node = GNUNET_CONTAINER_heap_insert(recent.minHeap, 
recent_req, GNUNET_TIME_absolute_get().value);
+      recent_req->heap_node = GNUNET_CONTAINER_heap_insert(recent.minHeap, 
recent_req, GNUNET_TIME_absolute_get().abs_value);
       recent_req->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, 
DHT_BLOOM_SIZE, DHT_BLOOM_K);
       GNUNET_CONTAINER_multihashmap_put(recent.hashmap, &unique_hash, 
recent_req, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
     }
@@ -4008,14 +4008,14 @@
   end = GNUNET_TIME_absolute_get();
   time_diff = GNUNET_TIME_absolute_get_difference(find_peer_context.start, 
end);
 
-  if (time_diff.value > FIND_PEER_CALC_INTERVAL.value)
+  if (time_diff.abs_value > FIND_PEER_CALC_INTERVAL.abs_value)
     {
-      multiplier = time_diff.value / FIND_PEER_CALC_INTERVAL.value;
+      multiplier = time_diff.abs_value / FIND_PEER_CALC_INTERVAL.abs_value;
       count_per_interval = find_peer_context.count / multiplier;
     }
   else
     {
-      multiplier = FIND_PEER_CALC_INTERVAL.value / time_diff.value;
+      multiplier = FIND_PEER_CALC_INTERVAL.abs_value / time_diff.abs_value;
       count_per_interval = find_peer_context.count * multiplier;
     }
 #endif
@@ -4049,18 +4049,18 @@
               "FIND PEER");
   if (newly_found_peers < bucket_size)
     {
-      next_send_time.value = (DHT_MAXIMUM_FIND_PEER_INTERVAL.value / 2) +
+      next_send_time.rel_value = (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 
2) +
                               
GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG,
-                                                       
DHT_MAXIMUM_FIND_PEER_INTERVAL.value / 2);
+                                                       
DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2);
     }
   else
     {
-      next_send_time.value = DHT_MINIMUM_FIND_PEER_INTERVAL.value +
+      next_send_time.rel_value = DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value +
                              
GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG,
-                                                      
DHT_MAXIMUM_FIND_PEER_INTERVAL.value - DHT_MINIMUM_FIND_PEER_INTERVAL.value);
+                                                      
DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value - 
DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value);
     }
 
-  GNUNET_assert (next_send_time.value != 0);
+  GNUNET_assert (next_send_time.rel_value != 0);
   find_peer_context.count = 0;
   newly_found_peers = 0;
   find_peer_context.start = GNUNET_TIME_absolute_get();
@@ -4257,7 +4257,7 @@
   struct GNUNET_MessageHeader *enc_msg = (struct GNUNET_MessageHeader 
*)&incoming[1];
   struct DHT_MessageContext *message_context;
 
-  if (get_max_send_delay().value > MAX_REQUEST_TIME.value)
+  if (get_max_send_delay().rel_value > MAX_REQUEST_TIME.rel_value)
   {
     GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Sending of previous replies took 
too long, backing off!\n");
     increment_stats("# route requests dropped due to high load");
@@ -4791,9 +4791,9 @@
   recent.minHeap = 
GNUNET_CONTAINER_heap_create(GNUNET_CONTAINER_HEAP_ORDER_MIN);
   if (GNUNET_YES == do_find_peer)
   {
-    next_send_time.value = DHT_MINIMUM_FIND_PEER_INTERVAL.value +
+    next_send_time.rel_value = DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value +
                            
GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG,
-                                                    
(DHT_MAXIMUM_FIND_PEER_INTERVAL.value / 2) - 
DHT_MINIMUM_FIND_PEER_INTERVAL.value);
+                                                    
(DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2) - 
DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value);
     find_peer_context.start = GNUNET_TIME_absolute_get();
     GNUNET_SCHEDULER_add_delayed (sched,
                                   next_send_time,

Modified: gnunet/src/dht/test_dht_api.c
===================================================================
--- gnunet/src/dht/test_dht_api.c       2010-10-27 10:04:42 UTC (rev 13427)
+++ gnunet/src/dht/test_dht_api.c       2010-10-27 10:08:46 UTC (rev 13428)
@@ -249,7 +249,7 @@
   GNUNET_HashCode hash;
   memset (&hash, 42, sizeof (GNUNET_HashCode));
 
-  if (GNUNET_TIME_absolute_get_remaining(retry_ctx->real_timeout).value > 0)
+  if (GNUNET_TIME_absolute_get_remaining(retry_ctx->real_timeout).rel_value > 
0)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "test_find_peer timed out, retrying!\n");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]