<div dir="ltr">Thanks it works. Code looks good too.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 27, 2014 at 2:07 PM, Ben Pfaff <span dir="ltr">&lt;<a href="mailto:blp@nicira.com" target="_blank">blp@nicira.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">rconn_recv() calls vconn_recv(), which will report a connection error and<br>
cause rconn_recv() to disconnect the rconn.  Most rconn users regularly<br>
call rconn_recv(), so that disconnection happens promptly.  However,<br>
the lswitch code only calls rconn_recv() after the connection negotiates an<br>
OpenFlow version, so a connection that failed before negotiation would<br>
never be detected as failed.  This commit fixes the problem by making<br>
rconn_run() also detect and handle connection errors.<br>
<br>
The lswitch code is only used by the test-controller program, so this is<br>
not an important bug fix.<br>
<br>
Reported-by: Vasu Dasari &lt;<a href="mailto:vdasari@gmail.com">vdasari@gmail.com</a>&gt;<br>
Signed-off-by: Ben Pfaff &lt;<a href="mailto:blp@nicira.com">blp@nicira.com</a>&gt;<br>
---<br>
 lib/rconn.c |   10 +++++++++-<br>
 lib/vconn.c |   11 ++++++++++-<br>
 lib/vconn.h |    4 +++-<br>
 3 files changed, 22 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/lib/rconn.c b/lib/rconn.c<br>
index d339365..72688ba 100644<br>
--- a/lib/rconn.c<br>
+++ b/lib/rconn.c<br>
@@ -1,5 +1,5 @@<br>
 /*<br>
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.<br>
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.<br>
  *<br>
  * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);<br>
  * you may not use this file except in compliance with the License.<br>
@@ -592,7 +592,15 @@ rconn_run(struct rconn *rc)<br>
<br>
     ovs_mutex_lock(&amp;rc-&gt;mutex);<br>
     if (rc-&gt;vconn) {<br>
+        int error;<br>
+<br>
         vconn_run(rc-&gt;vconn);<br>
+<br>
+        error = vconn_get_status(rc-&gt;vconn);<br>
+        if (error) {<br>
+            report_error(rc, error);<br>
+            disconnect(rc, error);<br>
+        }<br>
     }<br>
     for (i = 0; i &lt; rc-&gt;n_monitors; ) {<br>
         struct ofpbuf *msg;<br>
diff --git a/lib/vconn.c b/lib/vconn.c<br>
index f0549d5..c1485f0 100644<br>
--- a/lib/vconn.c<br>
+++ b/lib/vconn.c<br>
@@ -1,5 +1,5 @@<br>
 /*<br>
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.<br>
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.<br>
  *<br>
  * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);<br>
  * you may not use this file except in compliance with the License.<br>
@@ -293,6 +293,15 @@ vconn_run_wait(struct vconn *vconn)<br>
     }<br>
 }<br>
<br>
+/* Returns 0 if &#39;vconn&#39; is healthy (connecting or connected), a positive errno<br>
+ * value if the connection died abnormally (connection failed or aborted), or<br>
+ * EOF if the connection was closed in a normal way. */<br>
+int<br>
+vconn_get_status(const struct vconn *vconn)<br>
+{<br>
+    return vconn-&gt;error;<br>
+}<br>
+<br>
 int<br>
 vconn_open_block(const char *name, uint32_t allowed_versions, uint8_t dscp,<br>
                  struct vconn **vconnp)<br>
diff --git a/lib/vconn.h b/lib/vconn.h<br>
index 8678581..f6ba955 100644<br>
--- a/lib/vconn.h<br>
+++ b/lib/vconn.h<br>
@@ -1,5 +1,5 @@<br>
 /*<br>
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.<br>
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.<br>
  *<br>
  * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);<br>
  * you may not use this file except in compliance with the License.<br>
@@ -57,6 +57,8 @@ int vconn_transact_multiple_noreply(struct vconn *, struct list *requests,<br>
 void vconn_run(struct vconn *);<br>
 void vconn_run_wait(struct vconn *);<br>
<br>
+int vconn_get_status(const struct vconn *);<br>
+<br>
 int vconn_open_block(const char *name, uint32_t allowed_versions, uint8_t dscp,<br>
                      struct vconn **);<br>
 int vconn_connect_block(struct vconn *);<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.10.4<br>
<br>
</font></span></blockquote></div><br></div>