fixed a fd leak on static file serving

This commit is contained in:
roberto@oneoric64
2011-12-06 09:29:41 +01:00
parent cf7df391ad
commit 82f83e610f
5 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -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
+1
View File
@@ -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;
}
-2
View File
@@ -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 *);
+2
View File
@@ -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") )) {
+2
View File
@@ -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);
}