fixed socket in non-blocking mode

This commit is contained in:
roberto@mrspurr
2012-04-25 14:18:40 +02:00
parent 82c25f7f8c
commit e5ba01e707
4 changed files with 30 additions and 4 deletions
+4
View File
@@ -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
View File
@@ -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);
+19
View File
@@ -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;
+1
View File
@@ -2465,6 +2465,7 @@ void uwsgi_string_del_list(struct uwsgi_string_list **, struct uwsgi_string_list
void uwsgi_init_all_apps(void);
void uwsgi_socket_nb(int);
void uwsgi_socket_b(int);
void uwsgi_destroy_request(struct wsgi_request *);