aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c3
-rw-r--r--setup.c9
2 files changed, 12 insertions, 0 deletions
diff --git a/main.c b/main.c
index c58bf57..01119f5 100644
--- a/main.c
+++ b/main.c
@@ -124,6 +124,7 @@ const char *android_hook(char **envp)
#endif
extern void setup(int argc, char **argv);
+extern void shutdown_session();
static int monitors;
static void (*callbacks[10])(int fd);
@@ -188,6 +189,8 @@ int main(int argc, char **argv)
for (i = 0; i < monitors; ++i) {
if (pollfds[i].revents & POLLHUP) {
do_plog(LLV_INFO, "Connection is closed\n", pollfds[i].fd);
+ shutdown_session();
+
/* Wait for few seconds to consume late messages. */
sleep(5);
exit(1);
diff --git a/setup.c b/setup.c
index 14e42f8..9056b63 100644
--- a/setup.c
+++ b/setup.c
@@ -53,6 +53,7 @@
#include "privsep.h"
#include "throttle.h"
#include "misc.h"
+#include "handler.h"
static struct localconf localconf;
static struct sainfo sainfo;
@@ -670,3 +671,11 @@ int throttle_host(struct sockaddr *addr, int fail)
{
return 0;
}
+
+void shutdown_session()
+{
+ flushph2();
+ flushph1();
+ isakmp_close();
+ pfkey_close(localconf.sock_pfkey);
+}