---
 lib/poll-loop.c | 11 +++++++++++
 lib/poll-loop.h |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/lib/poll-loop.c b/lib/poll-loop.c
index e83d989..63c7a42 100644
--- a/lib/poll-loop.c
+++ b/lib/poll-loop.c
@@ -53,6 +53,7 @@ struct poll_loop {
      * wake up immediately, or LLONG_MAX to wait forever. */
     long long int timeout_when; /* In msecs as returned by time_msec(). */
     const char *timeout_where;  /* Where 'timeout_when' was set. */
+    bool waken_by_timer;
 };
 
 static struct poll_loop *poll_loop(void);
@@ -365,11 +366,14 @@ poll_block(void)
                        loop->timeout_when, &elapsed);
     if (retval < 0) {
         static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+        loop->waken_by_timer = false;
         VLOG_ERR_RL(&rl, "poll: %s", ovs_strerror(-retval));
     } else if (!retval) {
+        loop->waken_by_timer = true;
         log_wakeup(loop->timeout_where, NULL, elapsed);
     } else if (get_cpu_usage() > 50 || VLOG_IS_DBG_ENABLED()) {
         i = 0;
+        loop->waken_by_timer = false;
         HMAP_FOR_EACH (node, hmap_node, &loop->poll_nodes) {
             if (pollfds[i].revents) {
                 log_wakeup(node->where, &pollfds[i], 0);
@@ -389,6 +393,13 @@ poll_block(void)
 
     seq_woke();
 }
+
+bool
+poll_block_waken_by_timer(void)
+{
+    return poll_loop()->waken_by_timer;
+}
+
 
 static void
 free_poll_loop(void *loop_)
diff --git a/lib/poll-loop.h b/lib/poll-loop.h
index 01e1aa8..b0a4cff 100644
--- a/lib/poll-loop.h
+++ b/lib/poll-loop.h
@@ -70,6 +70,9 @@ void poll_immediate_wake_at(const char *where);
 /* Wait until an event occurs. */
 void poll_block(void);
 
+/* Return true if the last poll block was waken by timer*/
+bool poll_block_waken_by_timer(void);
+
 #ifdef  __cplusplus
 }
 #endif
-- 
1.9.1

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to