diff --git a/master.c b/master.c index b4fdde75..661135e3 100644 --- a/master.c +++ b/master.c @@ -8,6 +8,10 @@ void get_linux_tcp_info(int fd) { socklen_t tis = sizeof(struct tcp_info) ; if (!getsockopt(fd, IPPROTO_TCP, TCP_INFO, &ti, &tis)) { + // a check for older linux kernels + if (!ti.tcpi_sacked) { + return 0; + } 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); } diff --git a/uwsgi.c b/uwsgi.c index 229e5dd4..d90c4db9 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -149,6 +149,7 @@ static struct option long_options[] = { {"log-4xx", no_argument, 0, LONG_ARGS_LOG_4xx}, {"log-5xx", no_argument, 0, LONG_ARGS_LOG_5xx}, {"log-big", required_argument, 0, LONG_ARGS_LOG_BIG}, + {"log-sendfile", required_argument, 0, LONG_ARGS_LOG_SENDFILE}, {"chdir", required_argument, 0, LONG_ARGS_CHDIR}, {"chdir2", required_argument, 0, LONG_ARGS_CHDIR2}, {"mount", required_argument, 0, LONG_ARGS_MOUNT}, @@ -2322,6 +2323,9 @@ void manage_opt(int i, char *optarg) { case LONG_ARGS_LOG_BIG: uwsgi.shared->options[UWSGI_OPTION_LOG_BIG] = atoi(optarg); break; + case LONG_ARGS_LOG_SENDFILE: + uwsgi.shared->options[UWSGI_OPTION_LOG_SENDFILE] = 1; + break; case LONG_ARGS_MOUNT: if (uwsgi.mounts_cnt < MAX_MOUNTPOINTS) { uwsgi.mounts[uwsgi.mounts_cnt] = optarg; @@ -2513,6 +2517,7 @@ void manage_opt(int i, char *optarg) { \t--log-4xx\t\t\tlog requests with status code 4xx\n\ \t--log-5xx\t\t\tlog requests with status code 5xx\n\ \t--log-big \t\t\tlog requests bigger than bytes\n\ +\t--log-sendfile\t\t\tlog sendfile() requests\n\ \t--ignore-script-name\t\tdisable uWSGI management of SCRIPT_NAME\n\ \t--no-default-app\t\tdo not fallback unknown SCRIPT_NAME requests\n\ \t--ini \t\t\tpath of ini config file\n\ diff --git a/uwsgi.h b/uwsgi.h index 3036f3e3..149b9901 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -211,6 +211,7 @@ PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t); #define LONG_ARGS_LOG_BIG 17052 #define LONG_ARGS_MOUNT 17053 #define LONG_ARGS_THREADS 17054 +#define LONG_ARGS_LOG_SENDFILE 17055 @@ -269,6 +270,7 @@ PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t); #define UWSGI_OPTION_LOG_4xx 11 #define UWSGI_OPTION_LOG_5xx 12 #define UWSGI_OPTION_LOG_BIG 13 +#define UWSGI_OPTION_LOG_SENDFILE 14 #define UWSGI_MODIFIER_ADMIN_REQUEST 10 #define UWSGI_MODIFIER_SPOOL_REQUEST 17 diff --git a/wsgi_handlers.c b/wsgi_handlers.c index 5d673277..ed15bd20 100644 --- a/wsgi_handlers.c +++ b/wsgi_handlers.c @@ -406,5 +406,8 @@ void uwsgi_after_request_wsgi(struct wsgi_request *wsgi_req) { if (uwsgi.shared->options[UWSGI_OPTION_LOG_BIG]) { if (wsgi_req->response_size >= uwsgi.shared->options[UWSGI_OPTION_LOG_BIG]) { log_request(wsgi_req); return; } } + if (uwsgi.shared->options[UWSGI_OPTION_LOG_SENDFILE]) { + if (wsgi_req->sendfile_fd > -1 && wsgi_req->sendfile_obj == wsgi_req->async_result) { log_request(wsgi_req); return; } + } } }