treewide: Remove trailing whitespace
[sliver-openvswitch.git] / lib / vconn.c
index f4b3169..ec0ac4e 100644 (file)
 #include "poll-loop.h"
 #include "random.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_vconn
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(vconn)
+
 /* State of an active vconn.*/
 enum vconn_state {
     /* This is the ordinary progression of states. */
@@ -127,7 +127,7 @@ vconn_usage(bool active, bool passive, bool bootstrap OVS_UNUSED)
     /* Really this should be implemented via callbacks into the vconn
      * providers, but that seems too heavy-weight to bother with at the
      * moment. */
-    
+
     printf("\n");
     if (active) {
         printf("Active OpenFlow connection methods:\n");
@@ -278,14 +278,16 @@ vconn_open_block(const char *name, int min_version, struct vconn **vconnp)
     fatal_signal_run();
 
     error = vconn_open(name, min_version, &vconn);
-    while (error == EAGAIN) {
-        vconn_run(vconn);
-        vconn_run_wait(vconn);
-        vconn_connect_wait(vconn);
-        poll_block();
-        error = vconn_connect(vconn);
+    if (!error) {
+        while ((error == vconn_connect(vconn)) == EAGAIN) {
+            vconn_run(vconn);
+            vconn_run_wait(vconn);
+            vconn_connect_wait(vconn);
+            poll_block();
+        }
         assert(error != EINPROGRESS);
     }
+
     if (error) {
         vconn_close(vconn);
         *vconnp = NULL;
@@ -316,38 +318,38 @@ vconn_get_name(const struct vconn *vconn)
 /* Returns the IP address of the peer, or 0 if the peer is not connected over
  * an IP-based protocol or if its IP address is not yet known. */
 uint32_t
-vconn_get_remote_ip(const struct vconn *vconn) 
+vconn_get_remote_ip(const struct vconn *vconn)
 {
     return vconn->remote_ip;
 }
 
-/* Returns the transport port of the peer, or 0 if the connection does not 
+/* Returns the transport port of the peer, or 0 if the connection does not
  * contain a port or if the port is not yet known. */
 uint16_t
-vconn_get_remote_port(const struct vconn *vconn) 
+vconn_get_remote_port(const struct vconn *vconn)
 {
     return vconn->remote_port;
 }
 
-/* Returns the IP address used to connect to the peer, or 0 if the 
- * connection is not an IP-based protocol or if its IP address is not 
+/* Returns the IP address used to connect to the peer, or 0 if the
+ * connection is not an IP-based protocol or if its IP address is not
  * yet known. */
 uint32_t
-vconn_get_local_ip(const struct vconn *vconn) 
+vconn_get_local_ip(const struct vconn *vconn)
 {
     return vconn->local_ip;
 }
 
-/* Returns the transport port used to connect to the peer, or 0 if the 
+/* Returns the transport port used to connect to the peer, or 0 if the
  * connection does not contain a port or if the port is not yet known. */
 uint16_t
-vconn_get_local_port(const struct vconn *vconn) 
+vconn_get_local_port(const struct vconn *vconn)
 {
     return vconn->local_port;
 }
 
 static void
-vcs_connecting(struct vconn *vconn) 
+vcs_connecting(struct vconn *vconn)
 {
     int retval = (vconn->class->connect)(vconn);
     assert(retval != EINPROGRESS);
@@ -459,10 +461,10 @@ vcs_send_error(struct vconn *vconn)
     }
 }
 
-/* Tries to complete the connection on 'vconn', which must be an active
- * vconn.  If 'vconn''s connection is complete, returns 0 if the connection
- * was successful or a positive errno value if it failed.  If the
- * connection is still in progress, returns EAGAIN. */
+/* Tries to complete the connection on 'vconn'. If 'vconn''s connection is
+ * complete, returns 0 if the connection was successful or a positive errno
+ * value if it failed.  If the connection is still in progress, returns
+ * EAGAIN. */
 int
 vconn_connect(struct vconn *vconn)
 {
@@ -502,11 +504,11 @@ vconn_connect(struct vconn *vconn)
     return EAGAIN;
 }
 
-/* Tries to receive an OpenFlow message from 'vconn', which must be an active
- * vconn.  If successful, stores the received message into '*msgp' and returns
- * 0.  The caller is responsible for destroying the message with
- * ofpbuf_delete().  On failure, returns a positive errno value and stores a
- * null pointer into '*msgp'.  On normal connection close, returns EOF.
+/* Tries to receive an OpenFlow message from 'vconn'.  If successful, stores
+ * the received message into '*msgp' and returns 0.  The caller is responsible
+ * for destroying the message with ofpbuf_delete().  On failure, returns a
+ * positive errno value and stores a null pointer into '*msgp'.  On normal
+ * connection close, returns EOF.
  *
  * vconn_recv will not block waiting for a packet to arrive.  If no packets
  * have been received, it returns EAGAIN immediately. */
@@ -563,11 +565,10 @@ do_recv(struct vconn *vconn, struct ofpbuf **msgp)
     return retval;
 }
 
-/* Tries to queue 'msg' for transmission on 'vconn', which must be an active
- * vconn.  If successful, returns 0, in which case ownership of 'msg' is
- * transferred to the vconn.  Success does not guarantee that 'msg' has been or
- * ever will be delivered to the peer, only that it has been queued for
- * transmission.
+/* Tries to queue 'msg' for transmission on 'vconn'.  If successful, returns 0,
+ * in which case ownership of 'msg' is transferred to the vconn.  Success does
+ * not guarantee that 'msg' has been or ever will be delivered to the peer,
+ * only that it has been queued for transmission.
  *
  * Returns a positive errno value on failure, in which case the caller
  * retains ownership of 'msg'.
@@ -912,13 +913,13 @@ vconn_set_remote_port(struct vconn *vconn, uint16_t port)
     vconn->remote_port = port;
 }
 
-void 
+void
 vconn_set_local_ip(struct vconn *vconn, uint32_t ip)
 {
     vconn->local_ip = ip;
 }
 
-void 
+void
 vconn_set_local_port(struct vconn *vconn, uint16_t port)
 {
     vconn->local_port = port;