[php-src] Issue #9943: FPM improve listen queue status info
| From: | bukka | Date: | Sun, 13 Nov 2022 15:51:24 +0000 |
| Subject: | [php-src] Issue #9943: FPM improve listen queue status info | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242807@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9943
Author: bukka
### Description
Currently
tcp_info structure is used to get information about listen queue that is then
shown in FPM status. It uses tcpi_unacked (or __tcpi_unacked on FreeBSD or
NetBSD) for current listen queue status value and tcpi_sacked (or
__tcpi_sacked on FreeBSD or NetBSD) which is used for max listen queue
and listen queue length. The queue length is however just approximation (at least on
Linux) expecting that maximum is reached which is often not the case on modern Linux kernl (one of
the example is a [bug #76323](https://bugs.php.net/bug.php?id=76323)). In addition this works only
for inet socket but doesn't work for unix domain socket as mentioned in [bug
#80739](https://bugs.php.net/bug.php?id=80739).
The solution for this on Linux is to use netlink with sock_diag. It brings some
challenges (like keeping inode number for the socket) but provides the required info and more. We
could consider using libnl but that might not be a good idea as it would require an explicit non
default dependency so it might not be always available (e.g. when FPM is compiled without it).
The FreeBSD should probably prefer the SO_LISTENQLIMIT, SO_LISTENQLEN and
SO_LISTENINCQLEN (for UDS) to get the required info as those options are specifically
meant to be used for this and tcp_info is quite undocumented there. It also can provide
the info for unix domain socket as mentioned.