From 7efced1a26b3ff3e4289cfe8f65480044a9d5bcf Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 10 Sep 2013 21:44:53 -0700 Subject: [PATCH] ofproto: New helper any_pending_ops(). This function is trivial now but in an upcoming commit it will need to become slightly more complicated, which makes writing it as a function worthwhile. Until then, this commit simplifies the logic, which was redundant since the 'deletions' hmap always points into the 'pending' list anyway. Signed-off-by: Ben Pfaff Acked-by: Ethan Jackson --- ofproto/ofproto.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 58042c23c..b78b77b20 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1318,6 +1318,12 @@ ofproto_type_wait(const char *datapath_type) } } +static bool +any_pending_ops(const struct ofproto *p) +{ + return !list_is_empty(&p->pending); +} + int ofproto_run(struct ofproto *p) { @@ -1400,7 +1406,7 @@ ofproto_run(struct ofproto *p) case S_EVICT: connmgr_run(p->connmgr, NULL); ofproto_evict(p); - if (list_is_empty(&p->pending) && hmap_is_empty(&p->deletions)) { + if (!any_pending_ops(p)) { p->state = S_OPENFLOW; } break; @@ -1408,7 +1414,7 @@ ofproto_run(struct ofproto *p) case S_FLUSH: connmgr_run(p->connmgr, NULL); ofproto_flush__(p); - if (list_is_empty(&p->pending) && hmap_is_empty(&p->deletions)) { + if (!any_pending_ops(p)) { connmgr_flushed(p->connmgr); p->state = S_OPENFLOW; } @@ -1501,7 +1507,7 @@ ofproto_wait(struct ofproto *p) case S_EVICT: case S_FLUSH: connmgr_wait(p->connmgr, false); - if (list_is_empty(&p->pending) && hmap_is_empty(&p->deletions)) { + if (!any_pending_ops(p)) { poll_immediate_wake(); } break; -- 2.20.1