From: Ethan Jackson Date: Mon, 22 Aug 2011 19:47:43 +0000 (-0700) Subject: rtnetlink: Notifiers should only run once per poll loop. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e77828b64c604d74dda44be76d57fb1b7c46302;p=openvswitch rtnetlink: Notifiers should only run once per poll loop. rtnetlink_notifier_run() does quite a bit of work, and is likely only to have interesting effects once per poll loop. --- diff --git a/lib/rtnetlink.c b/lib/rtnetlink.c index d15669a0..b6005543 100644 --- a/lib/rtnetlink.c +++ b/lib/rtnetlink.c @@ -37,6 +37,7 @@ static void rtnetlink_report(struct rtnetlink *rtn, void *change); struct rtnetlink { struct nl_sock *notify_sock; /* Rtnetlink socket. */ struct list all_notifiers; /* All rtnetlink notifiers. */ + bool has_run; /* Guard for run and wait functions. */ /* Passed in by rtnetlink_create(). */ int multicast_group; /* Multicast group we listen on. */ @@ -59,6 +60,7 @@ rtnetlink_create(int multicast_group, rtnetlink_parse_func *parse, rtn->multicast_group = multicast_group; rtn->parse = parse; rtn->change = change; + rtn->has_run = false; list_init(&rtn->all_notifiers); return rtn; @@ -135,10 +137,11 @@ rtnetlink_notifier_run(struct rtnetlink *rtn) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - if (!rtn->notify_sock) { + if (!rtn->notify_sock || rtn->has_run) { return; } + rtn->has_run = true; for (;;) { struct ofpbuf *buf; int error; @@ -170,6 +173,7 @@ rtnetlink_notifier_run(struct rtnetlink *rtn) void rtnetlink_notifier_wait(struct rtnetlink *rtn) { + rtn->has_run = false; if (rtn->notify_sock) { nl_sock_wait(rtn->notify_sock, POLLIN); }