mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-11-21 19:02:53 +00:00
various fixes for sendfile() and rack plugin
This commit is contained in:
@@ -366,7 +366,7 @@ PyObject *uwsgi_mount_loader(void *arg1) {
|
||||
}
|
||||
|
||||
|
||||
/* this is the dynamic loader, it loads app ireading nformation from a wsgi_request */
|
||||
/* this is the dynamic loader, it loads app reading information from a wsgi_request */
|
||||
PyObject *uwsgi_dyn_loader(void *arg1) {
|
||||
|
||||
PyObject *callable = NULL;
|
||||
|
||||
@@ -102,15 +102,15 @@ VALUE rb_uwsgi_io_new(VALUE class, VALUE wr) {
|
||||
return self;
|
||||
}
|
||||
|
||||
if (wsgi_req->post_cl > (size_t) uwsgi.post_buffering_bufsize) {
|
||||
uwsgi_log("using file for http body storage %d\n", wsgi_req->post_cl);
|
||||
if (wsgi_req->post_cl > (size_t) uwsgi.post_buffering) {
|
||||
//uwsgi_log("using file for http body storage %d\n", wsgi_req->post_cl);
|
||||
//RUBY_GVL_UNLOCK
|
||||
uwsgi_read_whole_body(wsgi_req, wsgi_req->post_buffering_buf, uwsgi.post_buffering_bufsize);
|
||||
//RUBY_GVL_LOCK
|
||||
}
|
||||
else {
|
||||
//RUBY_GVL_UNLOCK
|
||||
uwsgi_log("using memory for http body storage %d\n", wsgi_req->post_cl);
|
||||
//uwsgi_log("using memory for http body storage %d\n", wsgi_req->post_cl);
|
||||
ptr = wsgi_req->post_buffering_buf;
|
||||
while(post_remains > 0) {
|
||||
if (uwsgi.shared->options[UWSGI_OPTION_HARAKIRI] > 0) {
|
||||
@@ -612,12 +612,13 @@ int uwsgi_rack_request(struct wsgi_request *wsgi_req) {
|
||||
if (rb_respond_to( body, rb_intern("to_path") )) {
|
||||
VALUE sendfile_path = rb_funcall( body, rb_intern("to_path"), 0);
|
||||
wsgi_req->sendfile_fd = open(RSTRING_PTR(sendfile_path), O_RDONLY);
|
||||
uwsgi_log("sendfile_fd_size = %d\n", wsgi_req->sendfile_fd_size);
|
||||
//RUBY_GVL_UNLOCK
|
||||
wsgi_req->response_size = uwsgi_sendfile(wsgi_req);
|
||||
while(wsgi_req->response_size < wsgi_req->sendfile_fd_size) {
|
||||
uwsgi_log("sendfile_fd_size = %d\n", wsgi_req->sendfile_fd_size);
|
||||
wsgi_req->response_size += uwsgi_sendfile(wsgi_req);
|
||||
if (wsgi_req->response_size > 0) {
|
||||
while(wsgi_req->response_size < wsgi_req->sendfile_fd_size) {
|
||||
uwsgi_log("sendfile_fd_size = %d\n", wsgi_req->sendfile_fd_size);
|
||||
wsgi_req->response_size += uwsgi_sendfile(wsgi_req);
|
||||
}
|
||||
}
|
||||
//RUBY_GVL_LOCK;
|
||||
rb_gc_unregister_address(&sendfile_path);
|
||||
|
||||
+1
-3
@@ -11,8 +11,6 @@ ssize_t uwsgi_sendfile(struct wsgi_request *wsgi_req) {
|
||||
struct stat stat_buf;
|
||||
ssize_t sst = 0;
|
||||
|
||||
//UWSGI_RELEASE_GIL
|
||||
|
||||
if (!wsgi_req->sendfile_fd_size) {
|
||||
|
||||
if (fstat(fd, &stat_buf)) {
|
||||
@@ -32,7 +30,6 @@ ssize_t uwsgi_sendfile(struct wsgi_request *wsgi_req) {
|
||||
}
|
||||
|
||||
end:
|
||||
//UWSGI_GET_GIL
|
||||
return sst;
|
||||
}
|
||||
|
||||
@@ -73,6 +70,7 @@ ssize_t uwsgi_do_sendfile(int sockfd, int filefd, size_t filesize, size_t chunk,
|
||||
}
|
||||
|
||||
if (sf_ret) {
|
||||
uwsgi_log("sf_len = %d\n", sf_len);
|
||||
uwsgi_error("sendfile()");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -493,6 +493,18 @@ polling:
|
||||
return -1;
|
||||
}
|
||||
|
||||
// in Linux, new sockets do not inherit attributes
|
||||
#ifndef __linux__
|
||||
/* re-set blocking socket */
|
||||
int arg = uwsgi.sockets[i].arg ;
|
||||
arg &= (~O_NONBLOCK);
|
||||
if (fcntl(wsgi_req->poll.fd, F_SETFL, arg) < 0) {
|
||||
uwsgi_error("fcntl()");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (uwsgi.close_on_exec) {
|
||||
fcntl(wsgi_req->poll.fd, F_SETFD, FD_CLOEXEC);
|
||||
}
|
||||
|
||||
@@ -1066,15 +1066,14 @@ options_parsed:
|
||||
|
||||
|
||||
// put listening socket i non-blocking state
|
||||
int arg;
|
||||
for (i = 0; i < uwsgi.sockets_cnt; i++) {
|
||||
arg = fcntl(uwsgi.sockets[i].fd, F_GETFL, NULL);
|
||||
if (arg < 0) {
|
||||
uwsgi.sockets[i].arg = fcntl(uwsgi.sockets[i].fd, F_GETFL, NULL);
|
||||
if (uwsgi.sockets[i].arg < 0) {
|
||||
uwsgi_error("fcntl()");
|
||||
exit(1);
|
||||
}
|
||||
arg |= O_NONBLOCK;
|
||||
if (fcntl(uwsgi.sockets[i].fd, F_SETFL, arg) < 0) {
|
||||
uwsgi.sockets[i].arg |= O_NONBLOCK;
|
||||
if (fcntl(uwsgi.sockets[i].fd, F_SETFL, uwsgi.sockets[i].arg) < 0) {
|
||||
uwsgi_error("fcntl()");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user