Support fpm_get_socket_listening_queue on macOS

Using TCP_CONNECTION_INFO socket option.
This commit is contained in:
David CARLIER 2022-04-09 15:08:41 +01:00 committed by Jakub Zelenka
parent 838746bb4b
commit 7be195caa7
No known key found for this signature in database
GPG Key ID: 1C0779DC5C0A9DE4
4 changed files with 39 additions and 1 deletions

1
NEWS
View File

@ -14,6 +14,7 @@ PHP NEWS
. Emit error for invalid port setting. (David Carlier)
. Added extra check for FPM proc dumpable on SELinux based systems.
(David Carlier)
. Added support for listening queue on macOS. (David Carlier)
- Intl:
. Update all grandfathered language tags with preferred values

View File

@ -343,6 +343,19 @@ AC_DEFUN([AC_FPM_LQ],
AC_DEFINE([HAVE_LQ_TCP_INFO], 1, [do we have TCP_INFO?])
fi
AC_MSG_CHECKING([for TCP_CONNECTION_INFO])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/tcp.h>]], [[struct tcp_connection_info ti; int x = TCP_CONNECTION_INFO;]])], [
have_lq=tcp_connection_info
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
])
if test "$have_lq" = "tcp_connection_info"; then
AC_DEFINE([HAVE_LQ_TCP_CONNECTION_INFO], 1, [do we have TCP_CONNECTION_INFO?])
fi
if test "$have_lq" = "no" ; then
AC_MSG_CHECKING([for SO_LISTENQLEN])

View File

@ -70,7 +70,7 @@
# define HAVE_FPM_TRACE 0
#endif
#if defined(HAVE_LQ_TCP_INFO) || defined(HAVE_LQ_SO_LISTENQ)
#if defined(HAVE_LQ_TCP_INFO) || defined(HAVE_LQ_TCP_CONNECTION_INFO) || defined(HAVE_LQ_SO_LISTENQ)
# define HAVE_FPM_LQ 1
#else
# define HAVE_FPM_LQ 0

View File

@ -524,6 +524,30 @@ int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq)
return 0;
}
#elif defined(HAVE_LQ_TCP_CONNECTION_INFO)
#include <netinet/tcp.h>
int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq)
{
struct tcp_connection_info info;
socklen_t len = sizeof(info);
if (0 > getsockopt(sock, IPPROTO_TCP, TCP_CONNECTION_INFO, &info, &len)) {
zlog(ZLOG_SYSERROR, "failed to retrieve TCP_CONNECTION_INFO for socket");
return -1;
}
if (cur_lq) {
*cur_lq = info.tcpi_tfo_syn_data_acked;
}
if (max_lq) {
*max_lq = 0;
}
return 0;
}
#endif
#ifdef HAVE_LQ_SO_LISTENQ