mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-11-21 19:02:53 +00:00
better uwsgi_waitfd for nailed connections
This commit is contained in:
@@ -1162,20 +1162,35 @@ int uwsgi_waitfd(int fd, int timeout) {
|
||||
|
||||
int ret;
|
||||
struct pollfd upoll[1];
|
||||
char oob ;
|
||||
ssize_t rlen;
|
||||
|
||||
upoll[0].fd = fd;
|
||||
upoll[0].events = POLLIN;
|
||||
|
||||
if (!timeout) timeout = uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT];
|
||||
|
||||
timeout = timeout*1000;
|
||||
if (timeout < 0) timeout = -1;
|
||||
|
||||
uwsgi_log("waiting for max %d secs\n", timeout);
|
||||
|
||||
upoll[0].fd = fd;
|
||||
upoll[0].events = POLLIN | POLLPRI;
|
||||
upoll[0].revents = 0;
|
||||
ret = poll(upoll, 1, timeout);
|
||||
|
||||
if (ret < 0) {
|
||||
uwsgi_error("poll()");
|
||||
}
|
||||
else if (ret > 0) {
|
||||
if (upoll[0].revents & POLLPRI) {
|
||||
rlen = recv(fd, &oob, 1, MSG_OOB);
|
||||
uwsgi_log("RECEIVE OOB DATA %d !!!\n", rlen);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
+5
-3
@@ -1,10 +1,12 @@
|
||||
|
||||
import uwsgi
|
||||
|
||||
fd = uwsgi.connect("127.0.0.1:3033")
|
||||
uwsgi.send_message(fd, 0, 4, {"leave_open":"1"})
|
||||
fd = uwsgi.connect("192.168.173.100:3033")
|
||||
for part in uwsgi.send_message(fd, 0, 4, {"leave_open":"1"}, 30):
|
||||
print part
|
||||
|
||||
def application(e,s):
|
||||
|
||||
for part in uwsgi.send_message(fd, 0, 4, e, 0, e['wsgi.input'].fileno(), uwsgi.cl()):
|
||||
for part in uwsgi.send_message(fd, 0, 4, e, 30, e['wsgi.input'].fileno(), uwsgi.cl()):
|
||||
print part
|
||||
yield part
|
||||
|
||||
Reference in New Issue
Block a user