Fix CSTP write stall handling
authorDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 3 Aug 2012 09:11:54 +0000 (10:11 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 3 Aug 2012 09:11:56 +0000 (10:11 +0100)
We were handling the -EAGAIN case as a hard error and tearing down the
connection. Instead, we should just wait for the socket to become writeable.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
cstp.c
www/changelog.xml

diff --git a/cstp.c b/cstp.c
index bb15e9c..0588959 100644 (file)
--- a/cstp.c
+++ b/cstp.c
@@ -803,11 +803,18 @@ int cstp_mainloop(struct openconnect_info *vpninfo, int *timeout)
                ret = cstp_write(vpninfo,
                                 vpninfo->current_ssl_pkt->hdr,
                                 vpninfo->current_ssl_pkt->len + 8);
-               
                if (ret < 0)
                        goto do_reconnect;
-               else if (!ret && ka_stalled_dpd_time(&vpninfo->ssl_times, timeout))
-                       goto peer_dead;
+               else if (!ret) {
+                       /* -EAGAIN: cstp_write() will have added the SSL fd to
+                          ->select_wfds if appropriate, so we can just return
+                          and wait. Unless it's been stalled for so long that
+                          DPD kicks in and we kill the connection. */
+                       if (ka_stalled_dpd_time(&vpninfo->ssl_times, timeout))
+                               goto peer_dead;
+
+                       return work_done;
+               }
 
                if (ret != vpninfo->current_ssl_pkt->len + 8) {
                        vpn_progress(vpninfo, PRG_ERR,
index d439ced..7a83679 100644 (file)
@@ -17,7 +17,7 @@
 <ul>
    <li><b>OpenConnect HEAD</b>
      <ul>
-       <li><i>No changelog entries yet</i></li>
+       <li>Fix handling of write stalls on CSTP (TCP) socket.</li>
      </ul><br/>
   </li>
   <li><b><a href="ftp://ftp.infradead.org/pub/openconnect/openconnect-4.06.tar.gz">OpenConnect v4.06</a></b>