Legacy callers can invoke openconnect_setup_tun_fd() before DTLS starts. If this happens, don't try to set up the tunnel from the mainloop. Signed-off-by: Kevin Cernekee <cernekee at gmail.com> --- mainloop.c | 5 ----- tun-win32.c | 1 + tun.c | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/mainloop.c b/mainloop.c index 8a830d7..cb45389 100644 --- a/mainloop.c +++ b/mainloop.c @@ -168,7 +168,6 @@ int openconnect_mainloop(struct openconnect_info *vpninfo, { int ret = 0; - vpninfo->tun_is_up = 0; vpninfo->reconnect_timeout = reconnect_timeout; vpninfo->reconnect_interval = reconnect_interval; @@ -206,8 +205,6 @@ int openconnect_mainloop(struct openconnect_info *vpninfo, if (ret) { break; } - - vpninfo->tun_is_up = 1; } ret = vpninfo->proto.udp_mainloop(vpninfo, &timeout); @@ -220,8 +217,6 @@ int openconnect_mainloop(struct openconnect_info *vpninfo, ret = setup_tun_device(vpninfo); if (ret) break; - - vpninfo->tun_is_up = 1; } ret = vpninfo->proto.tcp_mainloop(vpninfo, &timeout); diff --git a/tun-win32.c b/tun-win32.c index a7f2258..41f70de 100644 --- a/tun-win32.c +++ b/tun-win32.c @@ -326,6 +326,7 @@ int openconnect_setup_tun_fd(struct openconnect_info *vpninfo, intptr_t tun_fd) { vpninfo->tun_fh = (HANDLE)tun_fd; vpninfo->tun_rd_overlap.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + vpninfo->tun_is_up = 1; monitor_read_fd(vpninfo, tun); return 0; diff --git a/tun.c b/tun.c index 89dc87b..7d18db0 100644 --- a/tun.c +++ b/tun.c @@ -447,6 +447,7 @@ int openconnect_setup_tun_fd(struct openconnect_info *vpninfo, int tun_fd) unmonitor_read_fd(vpninfo, tun); vpninfo->tun_fd = tun_fd; + vpninfo->tun_is_up = 1; monitor_fd_new(vpninfo, tun); monitor_read_fd(vpninfo, tun); -- 1.9.1