Close existing connection and discard compressed packet in cstp_reconnect()
authorDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 12 Aug 2010 23:37:12 +0000 (00:37 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 12 Aug 2010 23:37:12 +0000 (00:37 +0100)
Both callers need to do this, so move it into the function.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
cstp.c

diff --git a/cstp.c b/cstp.c
index 5916a58..6fbe64a 100644 (file)
--- a/cstp.c
+++ b/cstp.c
@@ -403,6 +403,13 @@ int cstp_reconnect(struct openconnect_info *vpninfo)
        int timeout;
        int interval;
 
+       openconnect_close_https(vpninfo);
+
+       /* It's already deflated in the old stream. Extremely
+          non-trivial to reconstitute it; just throw it away */
+       if (vpninfo->current_ssl_pkt == vpninfo->deflate_pkt)
+               vpninfo->current_ssl_pkt = NULL;
+
        timeout = vpninfo->reconnect_timeout;
        interval = vpninfo->reconnect_interval;
 
@@ -626,13 +633,6 @@ int cstp_mainloop(struct openconnect_info *vpninfo, int *timeout)
        peer_dead:
                vpninfo->progress(vpninfo, PRG_ERR, "CSTP Dead Peer Detection detected dead peer!\n");
        do_reconnect:
-               openconnect_close_https(vpninfo);
-
-               /* It's already deflated in the old stream. Extremely
-                  non-trivial to reconstitute it; just throw it away */
-               if (vpninfo->current_ssl_pkt == vpninfo->deflate_pkt)
-                       vpninfo->current_ssl_pkt = NULL;
-
                if (cstp_reconnect(vpninfo)) {
                        vpninfo->progress(vpninfo, PRG_ERR, "Reconnect failed\n");
                        vpninfo->quit_reason = "CSTP reconnect failed";