X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Frtnetlink.c;h=b600554390ee162d1b0d67e8f4d1dc8ddb76caa9;hb=8758e8a373338e409d7f2863ee91e01060f35628;hp=6ed85abbba2b5e51f35ca969e75f041f6c9ddb1b;hpb=cceb11f5b12d09cc8afc87ca4fd03e941234d439;p=openvswitch diff --git a/lib/rtnetlink.c b/lib/rtnetlink.c index 6ed85abb..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. */ @@ -55,10 +56,11 @@ rtnetlink_create(int multicast_group, rtnetlink_parse_func *parse, struct rtnetlink *rtn; rtn = xzalloc(sizeof *rtn); - rtn->notify_sock = 0; + rtn->notify_sock = NULL; 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); }