From fddb099d9f6c25d5500b176d6523818bd683bbae Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 3 Aug 2012 10:11:54 +0100 Subject: [PATCH] Fix CSTP write stall handling 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 --- cstp.c | 13 ++++++++++--- www/changelog.xml | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cstp.c b/cstp.c index bb15e9c..0588959 100644 --- 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, diff --git a/www/changelog.xml b/www/changelog.xml index d439ced..7a83679 100644 --- a/www/changelog.xml +++ b/www/changelog.xml @@ -17,7 +17,7 @@