From e66e56b5938dd7d079b972ebe269ee06d4a87660 Mon Sep 17 00:00:00 2001 From: "roberto@fiorenzo" Date: Sat, 25 Sep 2010 08:24:16 +0200 Subject: [PATCH] get_linux_tcp_info() refactoring --- uwsgi.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/uwsgi.c b/uwsgi.c index a9873d37..471bb9dc 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -177,6 +177,19 @@ static struct option long_options[] = { {0, 0, 0, 0} }; +#ifdef __linux__ +void get_linux_tcp_info(int fd) { + struct tcp_info ti; + socklen_t tis = sizeof(struct tcp_info) ; + + if (!getsockopt(fd, IPPROTO_TCP, TCP_INFO, &ti, &tis)) { + if (ti.tcpi_unacked >= ti.tcpi_sacked) { + uwsgi_log_verbose("*** uWSGI listen queue of socket %d full !!! (%d/%d) ***\n", fd, ti.tcpi_unacked, ti.tcpi_sacked); + } + } +} +#endif + void ping(struct uwsgi_server *uwsgi) { struct uwsgi_header uh; @@ -1571,14 +1584,8 @@ int main(int argc, char *argv[], char *envp[]) { #ifdef __linux__ for(i=0;i= ti.tcpi_sacked) { - uwsgi_log_verbose("*** uWSGI listen queue of socket %d full !!! (%d/%d) ***\n", uwsgi.sockets[i].fd, ti.tcpi_unacked, ti.tcpi_sacked); - } - } + get_linux_tcp_info(uwsgi.sockets[i].fd); } #endif