diff --git a/master.c b/master.c index d150793b..3b488542 100644 --- a/master.c +++ b/master.c @@ -4,16 +4,15 @@ extern struct uwsgi_server uwsgi; #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 (!getsockopt(fd, IPPROTO_TCP, TCP_INFO, &uwsgi.shared->ti, &tis)) { // a check for older linux kernels - if (!ti.tcpi_sacked) { + if (!uwsgi.shared->ti.tcpi_sacked) { return; } - 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); + if (uwsgi.shared->ti.tcpi_unacked >= uwsgi.shared->ti.tcpi_sacked) { + uwsgi_log_verbose("*** uWSGI listen queue of socket %d full !!! (%d/%d) ***\n", fd, uwsgi.shared->ti.tcpi_unacked, uwsgi.shared->ti.tcpi_sacked); } } } diff --git a/plugins/python/uwsgi_pymodule.c b/plugins/python/uwsgi_pymodule.c index 636859d8..0279ad10 100644 --- a/plugins/python/uwsgi_pymodule.c +++ b/plugins/python/uwsgi_pymodule.c @@ -156,6 +156,15 @@ char *uwsgi_encode_pydict(PyObject * pydict, uint16_t * size) { } +PyObject *py_uwsgi_listen_queue(PyObject * self, PyObject * args) { + +#ifdef __linux__ + return PyInt_FromLong(uwsgi.shared->ti.tcpi_unacked); +#else + return NULL +#endif +} + PyObject *py_uwsgi_close(PyObject * self, PyObject * args) { int fd; @@ -2122,9 +2131,10 @@ PyObject *py_uwsgi_parse_file(PyObject * self, PyObject * args) { } - goto clear; + goto clear2; clear3: + free(buffer); Py_DECREF(zero); clear2: close(fd); @@ -2307,6 +2317,8 @@ static PyMethodDef uwsgi_advanced_methods[] = { {"send", py_uwsgi_send, METH_VARARGS, ""}, {"cl", py_uwsgi_cl, METH_VARARGS, ""}, + {"listen_queue", py_uwsgi_listen_queue, METH_VARARGS, ""}, + {"attach_daemon", py_uwsgi_attach_daemon, METH_VARARGS, ""}, {"register_signal", py_uwsgi_register_signal, METH_VARARGS, ""}, diff --git a/uwsgi.h b/uwsgi.h index 25724049..a6c11c7c 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -1090,6 +1090,9 @@ struct uwsgi_shared { struct uwsgi_daemon daemons[MAX_DAEMONS]; int daemons_cnt; +#ifdef __linux__ + struct tcp_info ti; +#endif }; struct uwsgi_core {