rconn: Clarify rconn_run_wait().
authorBen Pfaff <blp@nicira.com>
Wed, 23 Feb 2011 20:35:32 +0000 (12:35 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 23 Feb 2011 23:14:42 +0000 (15:14 -0800)
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.

lib/rconn.c

index 6187576..443690b 100644 (file)
@@ -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;