diff options
author | Martin Willi <martin@strongswan.org> | 2007-07-27 10:17:50 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2007-07-27 10:17:50 +0000 |
commit | 99652427e97e8f62c70fd126a4327d9071258d7b (patch) | |
tree | bdc36b42dec837931b2eb24979f73b697c67430a /src | |
parent | 539a55a44189e57694e65cf75f5e1040a7fdd37d (diff) | |
download | strongswan-99652427e97e8f62c70fd126a4327d9071258d7b.tar.bz2 strongswan-99652427e97e8f62c70fd126a4327d9071258d7b.tar.xz |
properly shutdown of clients
Diffstat (limited to 'src')
-rw-r--r-- | src/dumm/dumm.c | 18 | ||||
-rw-r--r-- | src/dumm/guest.c | 5 | ||||
-rw-r--r-- | src/dumm/main.c | 5 |
3 files changed, 22 insertions, 6 deletions
diff --git a/src/dumm/dumm.c b/src/dumm/dumm.c index b8f0e0f2c..6432e74a7 100644 --- a/src/dumm/dumm.c +++ b/src/dumm/dumm.c @@ -24,6 +24,7 @@ typedef struct private_dumm_t private_dumm_t; struct private_dumm_t { dumm_t public; linked_list_t *guests; + bool destroying; }; static guest_t* create_guest(private_dumm_t *this, char *name, char *master, int mem) @@ -48,6 +49,11 @@ static iterator_t* create_guest_iterator(private_dumm_t *this) */ static void sigchild_handler(private_dumm_t *this, siginfo_t *info) { + if (this->destroying) + { + return; + } + switch (info->si_code) { case CLD_EXITED: @@ -77,6 +83,17 @@ static void sigchild_handler(private_dumm_t *this, siginfo_t *info) static void destroy(private_dumm_t *this) { + iterator_t *iterator; + guest_t *guest; + + iterator = this->guests->create_iterator(this->guests, TRUE); + while (iterator->iterate(iterator, (void**)&guest)) + { + guest->stop(guest); + } + iterator->destroy(iterator); + + this->destroying = TRUE; this->guests->destroy_offset(this->guests, offsetof(guest_t, destroy)); free(this); } @@ -110,6 +127,7 @@ dumm_t *dumm_create() return NULL; } + this->destroying = FALSE; this->guests = linked_list_create(); return &this->public; } diff --git a/src/dumm/guest.c b/src/dumm/guest.c index 59e501478..784891835 100644 --- a/src/dumm/guest.c +++ b/src/dumm/guest.c @@ -227,10 +227,10 @@ static void stop(private_guest_t *this) { if (this->state != GUEST_STOPPED) { + this->state = GUEST_STOPPING; this->ifaces->destroy_offset(this->ifaces, offsetof(iface_t, destroy)); this->ifaces = linked_list_create(); kill(this->pid, SIGINT); - this->state = GUEST_STOPPING; while (this->state == GUEST_STOPPING) { sched_yield(); @@ -243,6 +243,8 @@ static void stop(private_guest_t *this) */ static void sigchild(private_guest_t *this) { + DESTROY_IF(this->mconsole); + this->mconsole = NULL; this->state = GUEST_STOPPED; this->pid = 0; } @@ -341,7 +343,6 @@ static void destroy(private_guest_t *this) { stop(this); umount_unionfs(this->name); - DESTROY_IF(this->mconsole); free(this->name); free(this->master); free(this); diff --git a/src/dumm/main.c b/src/dumm/main.c index e4fc6602a..8d4c3e688 100644 --- a/src/dumm/main.c +++ b/src/dumm/main.c @@ -395,10 +395,7 @@ void signal_action(int sig, siginfo_t *info, void *ucontext) } else { - dumm->destroy(dumm); - clear_history(); - printf("\n"); - exit(0); + printf("\nuse 'quit'\ndumm# "); } } |