mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-05 05:01:36 +00:00
fixed a fd leak on static file serving
This commit is contained in:
@@ -101,7 +101,7 @@ int uwsgi_cgi_request(struct wsgi_request *wsgi_req) {
|
||||
uwsgi_log("STARTBUF %.*s\n", 8, startbuf);
|
||||
|
||||
if (!memcmp(startbuf, "Status: ", 8)) {
|
||||
wsgi_req->socket->proto_write(wsgi_req, "HTTP/1.1 "
|
||||
// wsgi_req->socket->proto_write(wsgi_req, "HTTP/1.1 "
|
||||
}
|
||||
|
||||
// now wait for fd
|
||||
|
||||
@@ -147,6 +147,7 @@ int psgi_response(struct wsgi_request *wsgi_req, AV *response) {
|
||||
wsgi_req->sendfile_fd = SvIV(fn);
|
||||
SvREFCNT_dec(fn);
|
||||
wsgi_req->response_size += uwsgi_sendfile(wsgi_req);
|
||||
// no need to close here as perl GC will do the close()
|
||||
return UWSGI_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -212,8 +212,6 @@ PyObject *python_call(PyObject *, PyObject *, int, struct wsgi_request *);
|
||||
|
||||
#ifdef UWSGI_SENDFILE
|
||||
PyObject *py_uwsgi_sendfile(PyObject *, PyObject *);
|
||||
ssize_t uwsgi_sendfile(struct wsgi_request *);
|
||||
ssize_t uwsgi_do_sendfile(int, int, size_t, size_t, off_t*, int);
|
||||
#endif
|
||||
|
||||
PyObject *py_uwsgi_write(PyObject *, PyObject *);
|
||||
|
||||
@@ -616,6 +616,8 @@ int uwsgi_rack_request(struct wsgi_request *wsgi_req) {
|
||||
wsgi_req->response_size += uwsgi_sendfile(wsgi_req);
|
||||
}
|
||||
}
|
||||
// we need to close it...
|
||||
close(wsgi_req->sendfile_fd);
|
||||
}
|
||||
}
|
||||
else if (rb_respond_to( body, rb_intern("each") )) {
|
||||
|
||||
@@ -1610,6 +1610,8 @@ int uwsgi_file_serve(struct wsgi_request *wsgi_req, char *document_root, uint16_
|
||||
wsgi_req->header_cnt += 2;
|
||||
wsgi_req->sendfile_fd = open(real_filename, O_RDONLY);
|
||||
wsgi_req->response_size += uwsgi_sendfile(wsgi_req);
|
||||
// here we need to close the sendfile fd (no-GC involved)
|
||||
close(wsgi_req->sendfile_fd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user