[ovs-dev] [RefactorInBand 2/5] in-band: Avoid magic number in refresh_remotes().

Ben Pfaff blp at nicira.com
Tue Apr 20 21:15:36 UTC 2010


The initial value of min_refresh() can only matter if there are no remotes,
in which case there is nothing to refresh anyhow.  So avoid the magic
number "10" as the initial minimum, since it has no real significance.

Suggested-by: Justin Pettit <jpettit at nicira.com>
---
 ofproto/in-band.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/ofproto/in-band.c b/ofproto/in-band.c
index 12ae8f3..d918d71 100644
--- a/ofproto/in-band.c
+++ b/ofproto/in-band.c
@@ -313,24 +313,23 @@ refresh_remotes(struct in_band *ib)
 {
     struct in_band_remote *r;
     bool any_changes;
-    int min_refresh;
 
     if (time_now() < ib->next_remote_refresh) {
         return false;
     }
 
     any_changes = false;
-    min_refresh = 10;
+    ib->next_remote_refresh = TIME_MAX;
     for (r = ib->remotes; r < &ib->remotes[ib->n_remotes]; r++) {
         uint8_t old_remote_mac[ETH_ADDR_LEN];
-        int refresh_interval;
+        time_t next_refresh;
 
         /* Save old MAC. */
         memcpy(old_remote_mac, r->remote_mac, ETH_ADDR_LEN);
 
         /* Refresh remote information. */
-        refresh_interval = refresh_remote(ib, r);
-        min_refresh = MIN(min_refresh, refresh_interval);
+        next_refresh = refresh_remote(ib, r) + time_now();
+        ib->next_remote_refresh = MIN(ib->next_remote_refresh, next_refresh);
 
         /* If the MAC changed, log the changes. */
         if (!eth_addr_equals(r->remote_mac, old_remote_mac)) {
@@ -345,7 +344,6 @@ refresh_remotes(struct in_band *ib)
             }
         }
     }
-    ib->next_remote_refresh = time_now() + min_refresh;
 
     return any_changes;
 }
-- 
1.6.6.1





More information about the dev mailing list