rconn: Push detection of send errors into try_send().
authorBen Pfaff <blp@nicira.com>
Mon, 14 Jul 2008 20:31:56 +0000 (13:31 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 18 Jul 2008 21:07:03 +0000 (14:07 -0700)
Thereby, we correct a bug in do_send(), one of the callers of try_send(),
which was not checking the try_send() return value.

lib/rconn.c

index 066a546..c410e73 100644 (file)
@@ -180,11 +180,8 @@ rconn_run(struct rconn *rc)
         }
         while (rc->txq.n > 0) {
             int error = try_send(rc);
-            if (error == EAGAIN) {
+            if (error) {
                 break;
-            } else if (error) {
-                disconnect(rc, error);
-                return;
             }
         }
     }
@@ -378,6 +375,9 @@ try_send(struct rconn *rc)
     struct buffer *next = rc->txq.head->next;
     retval = vconn_send(rc->vconn, rc->txq.head);
     if (retval) {
+        if (retval != EAGAIN) {
+            disconnect(rc, retval);
+        }
         return retval;
     }
     rc->packets_sent++;