From: Ben Pfaff Date: Wed, 23 Feb 2011 20:35:32 +0000 (-0800) Subject: rconn: Clarify rconn_run_wait(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82c2b79de650665f18d847c1771d28430486225e;p=openvswitch rconn: Clarify rconn_run_wait(). At first glance the vconn_wait() call looks risky because this function checked whether rc->vconn is nonnull at the top. In fact it's OK because rc->state will be S_ACTIVE or S_IDLE only if rc->vconn is nonnull, but there's no harm in putting that check inside the block that only runs if rc->vconn is nonnull. Coverity #10714. --- diff --git a/lib/rconn.c b/lib/rconn.c index 61875764..443690b8 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -510,6 +510,9 @@ rconn_run_wait(struct rconn *rc) if (rc->vconn) { vconn_run_wait(rc->vconn); + if ((rc->state & (S_ACTIVE | S_IDLE)) && !list_is_empty(&rc->txq)) { + vconn_wait(rc->vconn, WAIT_SEND); + } } for (i = 0; i < rc->n_monitors; i++) { vconn_run_wait(rc->monitors[i]); @@ -520,10 +523,6 @@ rconn_run_wait(struct rconn *rc) long long int expires = sat_add(rc->state_entered, timeo); poll_timer_wait_until(expires * 1000); } - - if ((rc->state & (S_ACTIVE | S_IDLE)) && !list_is_empty(&rc->txq)) { - vconn_wait(rc->vconn, WAIT_SEND); - } } /* Attempts to receive a packet from 'rc'. If successful, returns the packet;