diff options
author | Alex Wang <alexw@nicira.com> | 2013-10-16 03:32:32 +0000 |
---|---|---|
committer | Ethan Jackson <ethan@nicira.com> | 2013-10-16 18:08:05 -0700 |
commit | 88e4462e611540ce57554dcbb6794df57f7bf7b7 (patch) | |
tree | b5f5d5ebc707c207e9cf076ebd7572cc64685ffb | |
parent | 1a29a798ac5f8b903b8cb552038f31288020b0c1 (diff) | |
download | openvswitch-88e4462e611540ce57554dcbb6794df57f7bf7b7.tar.gz |
bfd: Add bfd_wake_time() function.
This commit adds a new function "bfd_wake_time()" that returns the
next wakeup time associated with the "struct bfd".
Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
-rw-r--r-- | lib/bfd.c | 26 | ||||
-rw-r--r-- | lib/bfd.h | 2 |
2 files changed, 21 insertions, 7 deletions
@@ -446,16 +446,30 @@ bfd_unref(struct bfd *bfd) OVS_EXCLUDED(mutex) void bfd_wait(const struct bfd *bfd) OVS_EXCLUDED(mutex) { - ovs_mutex_lock(&mutex); - if (bfd->flags & FLAG_FINAL) { - poll_immediate_wake(); + poll_timer_wait_until(bfd_wake_time(bfd)); +} + +/* Returns the next wake up time. */ +long long int +bfd_wake_time(const struct bfd *bfd) OVS_EXCLUDED(mutex) +{ + long long int retval; + + if (!bfd) { + return LLONG_MAX; } - poll_timer_wait_until(bfd->next_tx); - if (bfd->state > STATE_DOWN) { - poll_timer_wait_until(bfd->detect_time); + ovs_mutex_lock(&mutex); + if (bfd->flags & FLAG_FINAL) { + retval = 0; + } else { + retval = bfd->next_tx; + if (bfd->state > STATE_DOWN) { + retval = MIN(bfd->detect_time, retval); + } } ovs_mutex_unlock(&mutex); + return retval; } void @@ -49,5 +49,5 @@ void bfd_unref(struct bfd *); bool bfd_forwarding(const struct bfd *); void bfd_get_status(const struct bfd *, struct smap *); void bfd_set_netdev(struct bfd *, const struct netdev *); - +long long int bfd_wake_time(const struct bfd *); #endif /* bfd.h */ |