flush_ports: flush POSIX message queues properly

On Linux, read() on a message queue descriptor returns the message
queue statistics, not the actual message queue data.  We need to use
mq_receive() to drain the queues instead.

Fixes a problem where a POSIX message queue socket unit with messages
in the queue at shutdown time could result in a hang on reboot/shutdown.
This commit is contained in:
Todd C. Miller
2025-05-08 02:37:45 +09:00
committed by Yu Watanabe
parent 676fb42aae
commit ffb6adb763
3 changed files with 56 additions and 2 deletions
+6 -2
View File
@@ -2188,8 +2188,12 @@ static void flush_ports(Socket *s) {
if (p->fd < 0)
continue;
(void) flush_accept(p->fd);
(void) flush_fd(p->fd);
if (p->type == SOCKET_MQUEUE)
(void) flush_mqueue(p->fd);
else {
(void) flush_accept(p->fd);
(void) flush_fd(p->fd);
}
}
}