Switch from timeout_add with tvtohz to just timeout_add_tv. Now this change
authorclaudio <claudio@openbsd.org>
Mon, 17 Dec 2018 09:17:30 +0000 (09:17 +0000)
committerclaudio <claudio@openbsd.org>
Mon, 17 Dec 2018 09:17:30 +0000 (09:17 +0000)
will reduce the sleep time by one tick which doesn't matter in the common
case. The code never passes a true 0 timeval to timeout_add_tv so the code
will always sleep for at least 1 tick which is good enough.
OK kn@, florian@, visa@, cheloha@

sys/netinet/ip_carp.c

index 03ea414..6d204c3 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ip_carp.c,v 1.335 2018/12/04 12:39:54 claudio Exp $   */
+/*     $OpenBSD: ip_carp.c,v 1.336 2018/12/17 09:17:30 claudio Exp $   */
 
 /*
  * Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -1255,7 +1255,7 @@ carp_send_ad(struct carp_vhost_entry *vhe)
 retry_later:
        sc->cur_vhe = NULL;
        if (advbase != 255 || advskew != 255)
-               timeout_add(&vhe->ad_tmo, tvtohz(&tv));
+               timeout_add_tv(&vhe->ad_tmo, &tv);
 }
 
 /*
@@ -1613,18 +1613,18 @@ carp_setrun(struct carp_vhost_entry *vhe, sa_family_t af)
                        sc->sc_delayed_arp = -1;
                switch (af) {
                case AF_INET:
-                       timeout_add(&vhe->md_tmo, tvtohz(&tv));
+                       timeout_add_tv(&vhe->md_tmo, &tv);
                        break;
 #ifdef INET6
                case AF_INET6:
-                       timeout_add(&vhe->md6_tmo, tvtohz(&tv));
+                       timeout_add_tv(&vhe->md6_tmo, &tv);
                        break;
 #endif /* INET6 */
                default:
                        if (sc->sc_naddrs)
-                               timeout_add(&vhe->md_tmo, tvtohz(&tv));
+                               timeout_add_tv(&vhe->md_tmo, &tv);
                        if (sc->sc_naddrs6)
-                               timeout_add(&vhe->md6_tmo, tvtohz(&tv));
+                               timeout_add_tv(&vhe->md6_tmo, &tv);
                        break;
                }
                break;
@@ -1634,7 +1634,7 @@ carp_setrun(struct carp_vhost_entry *vhe, sa_family_t af)
                        tv.tv_usec = 1 * 1000000 / 256;
                else
                        tv.tv_usec = vhe->advskew * 1000000 / 256;
-               timeout_add(&vhe->ad_tmo, tvtohz(&tv));
+               timeout_add_tv(&vhe->ad_tmo, &tv);
                break;
        }
 }