mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-05 21:21:53 +00:00
fixed socket in non-blocking mode
This commit is contained in:
@@ -582,6 +582,10 @@ void fastrouter_loop(int id) {
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef __linux__
|
||||
uwsgi_socket_b(new_connection);
|
||||
#endif
|
||||
|
||||
ufr.fr_table[new_connection] = alloc_fr_session();
|
||||
ufr.fr_table[new_connection]->fd = new_connection;
|
||||
ufr.fr_table[new_connection]->instance_fd = -1;
|
||||
|
||||
+6
-4
@@ -592,6 +592,9 @@ void http_loop(int id) {
|
||||
taken = 1;
|
||||
break;
|
||||
}
|
||||
#ifndef __linux__
|
||||
uwsgi_socket_b(new_connection);
|
||||
#endif
|
||||
|
||||
uhttp_table[new_connection] = alloc_uhttp_session();
|
||||
uhttp_table[new_connection]->fd = new_connection;
|
||||
@@ -892,10 +895,9 @@ void http_loop(int id) {
|
||||
break;
|
||||
}
|
||||
|
||||
len = send(uhttp_session->fd, bbuf, len, 0);
|
||||
|
||||
if (len <= 0) {
|
||||
if (len < 0)
|
||||
ssize_t s_len = send(uhttp_session->fd, bbuf, len, 0);
|
||||
if (s_len <= 0) {
|
||||
if (s_len < 0)
|
||||
uwsgi_error("send()");
|
||||
close(uhttp_session->fd);
|
||||
close(uhttp_session->instance_fd);
|
||||
|
||||
@@ -758,6 +758,7 @@ int bind_to_tcp(char *socket_name, int listen_queue, char *tcp_port) {
|
||||
return serverfd;
|
||||
}
|
||||
|
||||
// set non-blocking socket
|
||||
void uwsgi_socket_nb(int fd) {
|
||||
int arg;
|
||||
|
||||
@@ -774,6 +775,24 @@ void uwsgi_socket_nb(int fd) {
|
||||
|
||||
}
|
||||
|
||||
// set blocking socket
|
||||
void uwsgi_socket_b(int fd) {
|
||||
int arg;
|
||||
|
||||
arg = fcntl(fd, F_GETFL, NULL);
|
||||
if (arg < 0) {
|
||||
uwsgi_error("fcntl()");
|
||||
return;
|
||||
}
|
||||
arg &= (~O_NONBLOCK);
|
||||
if (fcntl(fd, F_SETFL, arg) < 0) {
|
||||
uwsgi_error("fcntl()");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int timed_connect(struct pollfd *fdpoll, const struct sockaddr *addr, int addr_size, int timeout, int async) {
|
||||
|
||||
int arg, ret;
|
||||
|
||||
Reference in New Issue
Block a user