From: Ben Pfaff Date: Wed, 8 Oct 2008 21:24:18 +0000 (-0700) Subject: Make rconn_disconnect() a no-op if already disconnected. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd13e4cbc5f056a83e1e1542e0b34c0eb0ec08d1;p=openvswitch Make rconn_disconnect() a no-op if already disconnected. --- diff --git a/lib/rconn.c b/lib/rconn.c index 81954955..e5f377b9 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -227,18 +227,20 @@ rconn_connect_unreliably(struct rconn *rc, void rconn_disconnect(struct rconn *rc) { - if (rc->vconn) { - vconn_close(rc->vconn); - rc->vconn = NULL; - } - free(rc->name); - rc->name = xstrdup("void"); - rc->reliable = false; + if (rc->state != S_VOID) { + if (rc->vconn) { + vconn_close(rc->vconn); + rc->vconn = NULL; + } + free(rc->name); + rc->name = xstrdup("void"); + rc->reliable = false; - rc->backoff = 0; - rc->backoff_deadline = TIME_MIN; + rc->backoff = 0; + rc->backoff_deadline = TIME_MIN; - state_transition(rc, S_VOID); + state_transition(rc, S_VOID); + } } /* Disconnects 'rc' and frees the underlying storage. */