in-band: Avoid magic number in refresh_remotes().
authorBen Pfaff <blp@nicira.com>
Tue, 20 Apr 2010 20:58:24 +0000 (13:58 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 26 Apr 2010 16:51:10 +0000 (09:51 -0700)
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@nicira.com>
ofproto/in-band.c

index 12ae8f3..d918d71 100644 (file)
@@ -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;
 }