fixed a couple of leaks spotted by Riccardo and added uwsgi.listen_queue()

This commit is contained in:
roberto@lupo
2011-02-21 07:44:37 +01:00
parent 7c9c50c6a9
commit 69586a6134
3 changed files with 20 additions and 6 deletions
+4 -5
View File
@@ -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);
}
}
}
+13 -1
View File
@@ -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, ""},
+3
View File
@@ -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 {