Make sure Suricata is in the running state before
you attempt to execute commands on the Unix sockets.
UnixMain is being called in an infinite loop where
TmThreadsCheckFlag(th_v, THV_KILL) is checked for the
deinit phase. However, it may take some time between
the start of Suricata's deinitialization and
the receipt of THV_KILL flag in the Unix thread.
In between this time period, the Unix manager can still
perform select() operation on the Unix socket while
the socket being already deinitialized.
Likely with a longer time span between the initial shutdown
command and actual closing of Unix sockets resulted in
an error of invalid file descriptors.
Ticket: #6272
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);
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;