From 097adf4cb28b82ba20ae66f6fdf0baa8d0d7d608 Mon Sep 17 00:00:00 2001 From: "Wu, Fengguang" Date: Fri, 12 Dec 2008 14:23:45 +0000 Subject: [PATCH] quit on interrupted sleep Quit openconnect if sleep was interrupted by signal(e.g. ^C). Signed-off-by: Wu Fengguang Signed-off-by: David Woodhouse --- cstp.c | 2 ++ mainloop.c | 2 +- openconnect.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cstp.c b/cstp.c index fda4ec4..441869f 100644 --- a/cstp.c +++ b/cstp.c @@ -338,6 +338,8 @@ static int cstp_reconnect(struct openconnect_info *vpninfo) "sleep %ds, remain timeout %ds\n", interval, timeout); sleep(interval); + if (killed) + return 1; timeout -= interval; interval += vpninfo->reconnect_interval; if (interval > RECONNECT_INTERVAL_MAX) diff --git a/mainloop.c b/mainloop.c index fac9ede..c98c7c3 100644 --- a/mainloop.c +++ b/mainloop.c @@ -55,7 +55,7 @@ int queue_new_packet(struct pkt **q, int type, void *buf, int len) return 0; } -static int killed; +int killed; static void handle_sigint(int sig) { diff --git a/openconnect.h b/openconnect.h index f270384..42cd46d 100644 --- a/openconnect.h +++ b/openconnect.h @@ -213,6 +213,8 @@ void queue_packet(struct pkt **q, struct pkt *new); int keepalive_action(struct keepalive_info *ka, int *timeout); int ka_stalled_dpd_time(struct keepalive_info *ka, int *timeout); +extern int killed; + /* xml.c */ int config_lookup_host(struct openconnect_info *vpninfo, const char *host); -- 2.7.4