fat Thu, 11 Nov 2010 02:34:47 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=305267
Log:
- add "listen queue len" stat (thx to Andrei Nigmatulin)
Changed paths:
U php/php-src/branches/PHP_5_3/sapi/fpm/config.m4
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_config.h
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_process_ctl.c
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.c
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.h
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.c
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.h
U php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_worker_pool.h
U php/php-src/trunk/sapi/fpm/config.m4
U php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c
U php/php-src/trunk/sapi/fpm/fpm/fpm_config.h
U php/php-src/trunk/sapi/fpm/fpm/fpm_process_ctl.c
U php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.c
U php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.h
U php/php-src/trunk/sapi/fpm/fpm/fpm_status.c
U php/php-src/trunk/sapi/fpm/fpm/fpm_status.h
U php/php-src/trunk/sapi/fpm/fpm/fpm_worker_pool.h
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/config.m4
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/config.m4 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/config.m4 2010-11-11 02:34:47 UTC (rev 305267)
@@ -516,6 +516,39 @@
AC_MSG_RESULT([no])
])
])
+
+AC_DEFUN([AC_FPM_LQ],
+[
+ have_lq=no
+
+ AC_MSG_CHECKING([for TCP_INFO])
+
+ AC_TRY_COMPILE([ #include <netinet/tcp.h> ], [struct tcp_info ti; int x = TCP_INFO;], [
+ have_lq=tcp_info
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+ ])
+
+ if test "$have_lq" = "tcp_info"; then
+ AC_DEFINE([HAVE_LQ_TCP_INFO], 1, [do we have TCP_INFO?])
+ fi
+
+ if test "$have_lq" = "no" ; then
+ AC_MSG_CHECKING([for SO_LISTENQLEN])
+
+ AC_TRY_COMPILE([ #include <sys/socket.h> ], [int x = SO_LISTENQLIMIT; int y = SO_LISTENQLEN;], [
+ have_lq=so_listenq
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+ ])
+
+ if test "$have_lq" = "tcp_info"; then
+ AC_DEFINE([HAVE_LQ_SO_LISTENQ], 1, [do we have SO_LISTENQxxx?])
+ fi
+ fi
+])
dnl }}}
AC_MSG_CHECKING(for FPM build)
@@ -543,6 +576,7 @@
AC_FPM_CLOCK
AC_FPM_TRACE
AC_FPM_BUILTIN_ATOMIC
+ AC_FPM_LQ
PHP_ARG_WITH(fpm-user,,
[ --with-fpm-user[=USER] Set the user for php-fpm to run as. (default: nobody)], nobody, no)
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c 2010-11-11 02:34:47 UTC (rev 305267)
@@ -576,7 +576,7 @@
return -1;
}
fpm_status_update_accepted_conn(wp->shm_status, 0);
- fpm_status_update_activity(wp->shm_status, -1, -1, -1, 1);
+ fpm_status_update_activity(wp->shm_status, -1, -1, -1, 0, -1, 1);
fpm_status_update_max_children_reached(wp->shm_status, 0);
fpm_status_set_pm(wp->shm_status, wp->config->pm);
/* memset(&fpm_status.last_update, 0, sizeof(fpm_status.last_update)); */
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_config.h
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_config.h 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_config.h 2010-11-11 02:34:47 UTC (rev 305267)
@@ -42,3 +42,9 @@
#define HAVE_FPM_TRACE 0
#endif
+#if defined(HAVE_LQ_TCP_INFO) || defined(HAVE_LQ_SO_LISTENQ)
+#define HAVE_FPM_LQ 1
+#else
+#define HAVE_FPM_LQ 0
+#endif
+
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_process_ctl.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_process_ctl.c 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_process_ctl.c 2010-11-11 02:34:47 UTC (rev 305267)
@@ -19,6 +19,7 @@
#include "fpm_request.h"
#include "fpm_worker_pool.h"
#include "fpm_status.h"
+#include "fpm_sockets.h"
#include "zlog.h"
@@ -327,6 +328,7 @@
int idle = 0;
int active = 0;
int children_to_fork;
+ unsigned cur_lq;
if (wp->config == NULL) continue;
@@ -352,7 +354,10 @@
}
/* update status structure for all PMs */
- fpm_status_update_activity(wp->shm_status, idle, active, idle + active, 0);
+ if (0 > fpm_socket_get_listening_queue(wp, &cur_lq, NULL)) {
+ cur_lq = 0;
+ }
+ fpm_status_update_activity(wp->shm_status, idle, active, idle + active, cur_lq, wp->listening_queue_len, 0);
/* the rest is only used by PM_STYLE_DYNAMIC */
if (wp->config->pm != PM_STYLE_DYNAMIC) continue;
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.c 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.c 2010-11-11 02:34:47 UTC (rev 305267)
@@ -344,6 +344,10 @@
break;
}
+ if (0 > fpm_socket_get_listening_queue(wp, NULL, (unsigned *) &wp->listening_queue_len)) {
+ wp->listening_queue_len = -1;
+ }
+
if (wp->listening_socket == -1) {
return -1;
}
@@ -373,3 +377,76 @@
}
/* }}} */
+#if HAVE_FPM_LQ
+
+#ifdef HAVE_LQ_TCP_INFO
+
+#include <netinet/tcp.h>
+
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq)
+{
+ if (wp->listen_address_domain != FPM_AF_INET) {
+ return -1;
+ }
+
+ struct tcp_info info;
+ socklen_t len = sizeof(info);
+
+ if (0 > getsockopt(wp->listening_socket, IPPROTO_TCP, TCP_INFO, &info, &len)) {
+ return -1;
+ }
+
+ /* kernel >= 2.6.24 return non-zero here, that means operation is supported */
+ if (info.tcpi_sacked == 0) {
+ return -1;
+ }
+
+ if (cur_lq) {
+ *cur_lq = info.tcpi_unacked;
+ }
+
+ if (max_lq) {
+ *max_lq = info.tcpi_sacked;
+ }
+
+ return 0;
+}
+
+#endif
+
+#ifdef HAVE_LQ_SO_LISTENQ
+
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq)
+{
+ int val;
+ socklen_t len = sizeof(val);
+
+ if (cur_lq) {
+ if (0 > getsockopt(wp->listening_socket, SOL_SOCKET, SO_LISTENQLEN, &val, &len)) {
+ return -1;
+ }
+
+ *cur_lq = val;
+ }
+
+ if (max_lq) {
+ if (0 > getsockopt(wp->listening_socket, SOL_SOCKET, SO_LISTENQLIMIT, &val, &len)) {
+ return -1;
+ }
+
+ *max_lq = val;
+ }
+
+ return 0;
+}
+
+#endif
+
+#else
+
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq)
+{
+ return -1;
+}
+
+#endif
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.h
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.h 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.h 2010-11-11 02:34:47 UTC (rev 305267)
@@ -21,6 +21,7 @@
enum fpm_address_domain fpm_sockets_domain_from_address(char *addr);
int fpm_sockets_init_main();
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq);
static inline int fd_set_blocked(int fd, int blocked) /* {{{ */
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.c 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.c 2010-11-11 02:34:47 UTC (rev 305267)
@@ -133,7 +133,7 @@
}
/* }}} */
-void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, int clear_last_update) /* {{{ */
+void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, unsigned cur_lq, int max_lq, int clear_last_update) /* {{{ */
{
struct fpm_status_s status;
@@ -146,6 +146,8 @@
status.idle = idle;
status.active = active;
status.total = total;
+ status.cur_lq = cur_lq;
+ status.max_lq = max_lq;
if (clear_last_update) {
memset(&status.last_update, 0, sizeof(status.last_update));
} else {
@@ -164,14 +166,28 @@
}
spprintf(output, 0,
- "accepted conn: %lu\n"
"pool: %s\n"
"process manager: %s\n"
+ "accepted conn: %lu\n"
+#if HAVE_FPM_LQ
+ "listen queue len: %u\n"
+ "max listen queue len: %d\n"
+#endif
"idle processes: %d\n"
"active processes: %d\n"
"total processes: %d\n"
"max children reached: %u\n",
- status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total, status->max_children_reached);
+ fpm_status_pool,
+ status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
+ status->accepted_conn,
+#if HAVE_FPM_LQ
+ status->cur_lq,
+ status->max_lq,
+#endif
+ status->idle,
+ status->active,
+ status->total,
+ status->max_children_reached);
spprintf(content_type, 0, "Content-Type: text/plain");
}
@@ -185,15 +201,29 @@
spprintf(output, 0,
"<table>\n"
- "<tr><th>accepted conn</th><td>%lu</td></tr>\n"
"<tr><th>pool</th><td>%s</td></tr>\n"
"<tr><th>process manager</th><td>%s</td></tr>\n"
+ "<tr><th>accepted conn</th><td>%lu</td></tr>\n"
+#if HAVE_FPM_LQ
+ "<tr><th>listen queue len</th><td>%u</td></tr>\n"
+ "<tr><th>max listen queue len</th><td>%d</td></tr>\n"
+#endif
"<tr><th>idle processes</th><td>%d</td></tr>\n"
"<tr><th>active processes</th><td>%d</td></tr>\n"
"<tr><th>total processes</th><td>%d</td></tr>\n"
"<tr><th>max children reached</th><td>%u</td></tr>\n"
"</table>",
- status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total, status->max_children_reached);
+ fpm_status_pool,
+ status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
+ status->accepted_conn,
+#if HAVE_FPM_LQ
+ status->cur_lq,
+ status->max_lq,
+#endif
+ status->idle,
+ status->active,
+ status->total,
+ status->max_children_reached);
spprintf(content_type, 0, "Content-Type: text/html");
}
@@ -207,15 +237,29 @@
spprintf(output, 0,
"{"
- "\"accepted conn\":%lu,"
"\"pool\":\"%s\","
"\"process manager\":\"%s\","
+ "\"accepted conn\":%lu,"
+#if HAVE_FPM_LQ
+ "\"listen queue len\":%u,"
+ "\"max listen queue len\":%d,"
+#endif
"\"idle processes\":%d,"
"\"active processes\":%d,"
"\"total processes\":%d,"
"\"max children reached\":%u"
"}",
- status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total, status->max_children_reached);
+ fpm_status_pool,
+ status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
+ status->accepted_conn,
+#if HAVE_FPM_LQ
+ status->cur_lq,
+ status->max_lq,
+#endif
+ status->idle,
+ status->active,
+ status->total,
+ status->max_children_reached);
spprintf(content_type, 0, "Content-Type: application/json");
}
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.h
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.h 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.h 2010-11-11 02:34:47 UTC (rev 305267)
@@ -14,13 +14,15 @@
int idle;
int active;
int total;
+ unsigned cur_lq;
+ int max_lq;
unsigned long int accepted_conn;
unsigned int max_children_reached;
struct timeval last_update;
};
int fpm_status_init_child(struct fpm_worker_pool_s *wp);
-void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, int clear_last_update);
+void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, unsigned cur_lq, int max_lq, int clear_last_update);
void fpm_status_update_accepted_conn(struct fpm_shm_s *shm, unsigned long int accepted_conn);
void fpm_status_increment_accepted_conn(struct fpm_shm_s *shm);
void fpm_status_set_pm(struct fpm_shm_s *shm, int pm);
Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_worker_pool.h
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_worker_pool.h 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_worker_pool.h 2010-11-11 02:34:47 UTC (rev 305267)
@@ -25,6 +25,7 @@
char *user, *home; /* for setting env USER and HOME */
enum fpm_address_domain listen_address_domain;
int listening_socket;
+ int listening_queue_len;
int set_uid, set_gid; /* config uid and gid */
int socket_uid, socket_gid, socket_mode;
Modified: php/php-src/trunk/sapi/fpm/config.m4
===================================================================
--- php/php-src/trunk/sapi/fpm/config.m4 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/trunk/sapi/fpm/config.m4 2010-11-11 02:34:47 UTC (rev 305267)
@@ -516,6 +516,39 @@
AC_MSG_RESULT([no])
])
])
+
+AC_DEFUN([AC_FPM_LQ],
+[
+ have_lq=no
+
+ AC_MSG_CHECKING([for TCP_INFO])
+
+ AC_TRY_COMPILE([ #include <netinet/tcp.h> ], [struct tcp_info ti; int x = TCP_INFO;], [
+ have_lq=tcp_info
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+ ])
+
+ if test "$have_lq" = "tcp_info"; then
+ AC_DEFINE([HAVE_LQ_TCP_INFO], 1, [do we have TCP_INFO?])
+ fi
+
+ if test "$have_lq" = "no" ; then
+ AC_MSG_CHECKING([for SO_LISTENQLEN])
+
+ AC_TRY_COMPILE([ #include <sys/socket.h> ], [int x = SO_LISTENQLIMIT; int y = SO_LISTENQLEN;], [
+ have_lq=so_listenq
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+ ])
+
+ if test "$have_lq" = "tcp_info"; then
+ AC_DEFINE([HAVE_LQ_SO_LISTENQ], 1, [do we have SO_LISTENQxxx?])
+ fi
+ fi
+])
dnl }}}
AC_MSG_CHECKING(for FPM build)
@@ -543,6 +576,7 @@
AC_FPM_CLOCK
AC_FPM_TRACE
AC_FPM_BUILTIN_ATOMIC
+ AC_FPM_LQ
PHP_ARG_WITH(fpm-user,,
[ --with-fpm-user[=USER] Set the user for php-fpm to run as. (default: nobody)], nobody, no)
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c 2010-11-11 02:34:47 UTC (rev 305267)
@@ -576,7 +576,7 @@
return -1;
}
fpm_status_update_accepted_conn(wp->shm_status, 0);
- fpm_status_update_activity(wp->shm_status, -1, -1, -1, 1);
+ fpm_status_update_activity(wp->shm_status, -1, -1, -1, 0, -1, 1);
fpm_status_update_max_children_reached(wp->shm_status, 0);
fpm_status_set_pm(wp->shm_status, wp->config->pm);
/* memset(&fpm_status.last_update, 0, sizeof(fpm_status.last_update)); */
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_config.h
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_config.h 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_config.h 2010-11-11 02:34:47 UTC (rev 305267)
@@ -42,3 +42,9 @@
#define HAVE_FPM_TRACE 0
#endif
+#if defined(HAVE_LQ_TCP_INFO) || defined(HAVE_LQ_SO_LISTENQ)
+#define HAVE_FPM_LQ 1
+#else
+#define HAVE_FPM_LQ 0
+#endif
+
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_process_ctl.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_process_ctl.c 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_process_ctl.c 2010-11-11 02:34:47 UTC (rev 305267)
@@ -19,6 +19,7 @@
#include "fpm_request.h"
#include "fpm_worker_pool.h"
#include "fpm_status.h"
+#include "fpm_sockets.h"
#include "zlog.h"
@@ -327,6 +328,7 @@
int idle = 0;
int active = 0;
int children_to_fork;
+ unsigned cur_lq;
if (wp->config == NULL) continue;
@@ -352,7 +354,10 @@
}
/* update status structure for all PMs */
- fpm_status_update_activity(wp->shm_status, idle, active, idle + active, 0);
+ if (0 > fpm_socket_get_listening_queue(wp, &cur_lq, NULL)) {
+ cur_lq = 0;
+ }
+ fpm_status_update_activity(wp->shm_status, idle, active, idle + active, cur_lq, wp->listening_queue_len, 0);
/* the rest is only used by PM_STYLE_DYNAMIC */
if (wp->config->pm != PM_STYLE_DYNAMIC) continue;
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.c 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.c 2010-11-11 02:34:47 UTC (rev 305267)
@@ -344,6 +344,10 @@
break;
}
+ if (0 > fpm_socket_get_listening_queue(wp, NULL, (unsigned *) &wp->listening_queue_len)) {
+ wp->listening_queue_len = -1;
+ }
+
if (wp->listening_socket == -1) {
return -1;
}
@@ -373,3 +377,76 @@
}
/* }}} */
+#if HAVE_FPM_LQ
+
+#ifdef HAVE_LQ_TCP_INFO
+
+#include <netinet/tcp.h>
+
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq)
+{
+ if (wp->listen_address_domain != FPM_AF_INET) {
+ return -1;
+ }
+
+ struct tcp_info info;
+ socklen_t len = sizeof(info);
+
+ if (0 > getsockopt(wp->listening_socket, IPPROTO_TCP, TCP_INFO, &info, &len)) {
+ return -1;
+ }
+
+ /* kernel >= 2.6.24 return non-zero here, that means operation is supported */
+ if (info.tcpi_sacked == 0) {
+ return -1;
+ }
+
+ if (cur_lq) {
+ *cur_lq = info.tcpi_unacked;
+ }
+
+ if (max_lq) {
+ *max_lq = info.tcpi_sacked;
+ }
+
+ return 0;
+}
+
+#endif
+
+#ifdef HAVE_LQ_SO_LISTENQ
+
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq)
+{
+ int val;
+ socklen_t len = sizeof(val);
+
+ if (cur_lq) {
+ if (0 > getsockopt(wp->listening_socket, SOL_SOCKET, SO_LISTENQLEN, &val, &len)) {
+ return -1;
+ }
+
+ *cur_lq = val;
+ }
+
+ if (max_lq) {
+ if (0 > getsockopt(wp->listening_socket, SOL_SOCKET, SO_LISTENQLIMIT, &val, &len)) {
+ return -1;
+ }
+
+ *max_lq = val;
+ }
+
+ return 0;
+}
+
+#endif
+
+#else
+
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq)
+{
+ return -1;
+}
+
+#endif
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.h
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.h 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.h 2010-11-11 02:34:47 UTC (rev 305267)
@@ -21,6 +21,7 @@
enum fpm_address_domain fpm_sockets_domain_from_address(char *addr);
int fpm_sockets_init_main();
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq);
static inline int fd_set_blocked(int fd, int blocked) /* {{{ */
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_status.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_status.c 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_status.c 2010-11-11 02:34:47 UTC (rev 305267)
@@ -133,7 +133,7 @@
}
/* }}} */
-void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, int clear_last_update) /* {{{ */
+void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, unsigned cur_lq, int max_lq, int clear_last_update) /* {{{ */
{
struct fpm_status_s status;
@@ -146,6 +146,8 @@
status.idle = idle;
status.active = active;
status.total = total;
+ status.cur_lq = cur_lq;
+ status.max_lq = max_lq;
if (clear_last_update) {
memset(&status.last_update, 0, sizeof(status.last_update));
} else {
@@ -164,14 +166,28 @@
}
spprintf(output, 0,
- "accepted conn: %lu\n"
"pool: %s\n"
"process manager: %s\n"
+ "accepted conn: %lu\n"
+#if HAVE_FPM_LQ
+ "listen queue len: %u\n"
+ "max listen queue len: %d\n"
+#endif
"idle processes: %d\n"
"active processes: %d\n"
"total processes: %d\n"
"max children reached: %u\n",
- status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total, status->max_children_reached);
+ fpm_status_pool,
+ status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
+ status->accepted_conn,
+#if HAVE_FPM_LQ
+ status->cur_lq,
+ status->max_lq,
+#endif
+ status->idle,
+ status->active,
+ status->total,
+ status->max_children_reached);
spprintf(content_type, 0, "Content-Type: text/plain");
}
@@ -185,15 +201,29 @@
spprintf(output, 0,
"<table>\n"
- "<tr><th>accepted conn</th><td>%lu</td></tr>\n"
"<tr><th>pool</th><td>%s</td></tr>\n"
"<tr><th>process manager</th><td>%s</td></tr>\n"
+ "<tr><th>accepted conn</th><td>%lu</td></tr>\n"
+#if HAVE_FPM_LQ
+ "<tr><th>listen queue len</th><td>%u</td></tr>\n"
+ "<tr><th>max listen queue len</th><td>%d</td></tr>\n"
+#endif
"<tr><th>idle processes</th><td>%d</td></tr>\n"
"<tr><th>active processes</th><td>%d</td></tr>\n"
"<tr><th>total processes</th><td>%d</td></tr>\n"
"<tr><th>max children reached</th><td>%u</td></tr>\n"
"</table>",
- status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total, status->max_children_reached);
+ fpm_status_pool,
+ status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
+ status->accepted_conn,
+#if HAVE_FPM_LQ
+ status->cur_lq,
+ status->max_lq,
+#endif
+ status->idle,
+ status->active,
+ status->total,
+ status->max_children_reached);
spprintf(content_type, 0, "Content-Type: text/html");
}
@@ -207,15 +237,29 @@
spprintf(output, 0,
"{"
- "\"accepted conn\":%lu,"
"\"pool\":\"%s\","
"\"process manager\":\"%s\","
+ "\"accepted conn\":%lu,"
+#if HAVE_FPM_LQ
+ "\"listen queue len\":%u,"
+ "\"max listen queue len\":%d,"
+#endif
"\"idle processes\":%d,"
"\"active processes\":%d,"
"\"total processes\":%d,"
"\"max children reached\":%u"
"}",
- status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total, status->max_children_reached);
+ fpm_status_pool,
+ status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
+ status->accepted_conn,
+#if HAVE_FPM_LQ
+ status->cur_lq,
+ status->max_lq,
+#endif
+ status->idle,
+ status->active,
+ status->total,
+ status->max_children_reached);
spprintf(content_type, 0, "Content-Type: application/json");
}
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_status.h
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_status.h 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_status.h 2010-11-11 02:34:47 UTC (rev 305267)
@@ -14,13 +14,15 @@
int idle;
int active;
int total;
+ unsigned cur_lq;
+ int max_lq;
unsigned long int accepted_conn;
unsigned int max_children_reached;
struct timeval last_update;
};
int fpm_status_init_child(struct fpm_worker_pool_s *wp);
-void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, int clear_last_update);
+void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, unsigned cur_lq, int max_lq, int clear_last_update);
void fpm_status_update_accepted_conn(struct fpm_shm_s *shm, unsigned long int accepted_conn);
void fpm_status_increment_accepted_conn(struct fpm_shm_s *shm);
void fpm_status_set_pm(struct fpm_shm_s *shm, int pm);
Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_worker_pool.h
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_worker_pool.h 2010-11-11 01:43:53 UTC (rev 305266)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_worker_pool.h 2010-11-11 02:34:47 UTC (rev 305267)
@@ -25,6 +25,7 @@
char *user, *home; /* for setting env USER and HOME */
enum fpm_address_domain listen_address_domain;
int listening_socket;
+ int listening_queue_len;
int set_uid, set_gid; /* config uid and gid */
int socket_uid, socket_gid, socket_mode;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php