From: Ben Pfaff Date: Fri, 6 Feb 2009 23:07:38 +0000 (-0800) Subject: vswitchd: Avoid 100% CPU when secchan dies too many times. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bd75a539b725e57dbec8309ccd4febebe1face9;p=openvswitch vswitchd: Avoid 100% CPU when secchan dies too many times. vswitchd restarts secchan when necessary, but it limits the maximum number of tries to avoid wasting CPU when secchan repeatedly dies. Unfortunately, when this happens it also throws vswitchd into a busy-wait by calling process_wait() on the dead secchan process, because it doesn't clear out the process from the bridge structure. This commit clears out the secchan process from the bridge structure, so that we don't attempt to wait on it any longer, and should fix the busy-wait problem. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 4b8a343a..f4f351c0 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -572,6 +572,14 @@ start_secchan(struct bridge *br) char *dp_name; int retval; + /* Clean up vestiges of any previous secchan. */ + rconn_disconnect(br->rconn); + if (br->secchan) { + process_destroy(br->secchan); + br->secchan = NULL; + } + + /* Bail out if we've failed to start secchan too many times. */ if (br->sc_retries >= 5) { VLOG_ERR("%s: restarted secchan maximum number of %d times, disabling", br->name, br->sc_retries); @@ -580,13 +588,6 @@ start_secchan(struct bridge *br) } br->sc_retries++; - /* Clean up vestiges of any previous secchan. */ - rconn_disconnect(br->rconn); - if (br->secchan) { - process_destroy(br->secchan); - br->secchan = NULL; - } - if (!br->controller) { /* Create socketpair for communicating with secchan subprocess. */ if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sockets)) {