diff --git a/src/unix-manager.c b/src/unix-manager.c index 9893553f42..9fb5bd7935 100644 --- a/src/unix-manager.c +++ b/src/unix-manager.c @@ -628,6 +628,13 @@ static int UnixMain(UnixCommand * this) UnixClient *uclient; UnixClient *tclient; + if (suricata_ctl_flags & SURICATA_STOP) { + TAILQ_FOREACH_SAFE (uclient, &this->clients, next, tclient) { + UnixCommandClose(this, uclient->fd); + } + return 1; + } + /* Wait activity on the socket */ FD_ZERO(&select_set); FD_SET(this->socket, &select_set); @@ -649,13 +656,6 @@ static int UnixMain(UnixCommand * this) return 0; } - if (suricata_ctl_flags & SURICATA_STOP) { - TAILQ_FOREACH_SAFE(uclient, &this->clients, next, tclient) { - UnixCommandClose(this, uclient->fd); - } - return 1; - } - /* timeout: continue */ if (ret == 0) { return 1;