fixed shared sockets

This commit is contained in:
roberto@precise64
2012-03-14 08:28:25 +01:00
parent a35335a820
commit 734818c995
5 changed files with 8 additions and 2 deletions
+1
View File
@@ -107,6 +107,7 @@ struct uwsgi_gateway_socket *uwsgi_new_gateway_socket(char *name, char *owner) {
memset(uwsgi_sock, 0, sizeof(struct uwsgi_gateway_socket));
uwsgi_sock->fd = -1;
uwsgi_sock->shared = 0;
uwsgi_sock->name = name;
uwsgi_sock->owner = owner;
+1
View File
@@ -17,6 +17,7 @@ static void uwsgi_corerouter_setup_sockets(char *gw_id) {
int shared_socket = atoi(ugs->name+1);
if (shared_socket >= 0) {
ugs->fd = uwsgi_get_shared_socket_fd_by_num(shared_socket);
ugs->shared = 1;
if (ugs->fd == -1) {
uwsgi_log("unable to use shared socket %d\n", shared_socket);
exit(1);
+4 -1
View File
@@ -371,7 +371,10 @@ void uwsgi_fixup_fds(int wid, int muleid, struct uwsgi_gateway *ug) {
ugs = ugs->next;
continue;
}
close(ugs->fd);
// do not close shared sockets !!!
if (!ugs->shared) {
close(ugs->fd);
}
ugs = ugs->next;
}
// fix the communication pipe
+1 -1
View File
@@ -1670,7 +1670,7 @@ int main(int argc, char *argv[], char *envp[]) {
uwsgi_sock->fd = shared_sock->fd;
uwsgi_sock->family = shared_sock->family;
uwsgi_sock->name = shared_sock->name;
uwsgi_log("uwsgi socket %d mapped to shared socket %d (%s)\n", uwsgi_get_socket_num(uwsgi_sock), uwsgi_get_shared_socket_num(shared_sock), shared_sock->name);
uwsgi_log("uwsgi socket %d mapped to shared socket %d (%s) fd %d\n", uwsgi_get_socket_num(uwsgi_sock), uwsgi_get_shared_socket_num(shared_sock), shared_sock->name, uwsgi_sock->fd);
}
uwsgi_sock = uwsgi_sock->next;
+1
View File
@@ -394,6 +394,7 @@ struct uwsgi_gateway_socket {
// this requires SCTP
int sctp;
#endif
int shared;
char *owner;
struct uwsgi_gateway *gateway;