From b2a12377815ae6f02d8ba9ee83468d66d8b7ebad Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Sun, 11 Nov 2012 19:41:00 +0100 Subject: [PATCH] added --undeferred-shared-socket --- core/socket.c | 9 +++++++++ core/uwsgi.c | 6 +++++- uwsgi.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/socket.c b/core/socket.c index 862dc701..bd4fcbde 100644 --- a/core/socket.c +++ b/core/socket.c @@ -1484,6 +1484,10 @@ void uwsgi_setup_shared_sockets() { while (shared_sock) { if (!uwsgi.is_a_reload) { char *tcp_port = strrchr(shared_sock->name, ':'); + int current_defer_accept = uwsgi.no_defer_accept; + if (shared_sock->no_defer) { + uwsgi.no_defer_accept = 1; + } if (tcp_port == NULL) { shared_sock->fd = bind_to_unix(shared_sock->name, uwsgi.listen_queue, uwsgi.chmod_socket, uwsgi.abstract_socket); shared_sock->family = AF_UNIX; @@ -1514,6 +1518,11 @@ void uwsgi_setup_shared_sockets() { uwsgi_log("unable to create shared socket on: %s\n", shared_sock->name); exit(1); } + + if (shared_sock->no_defer) { + uwsgi.no_defer_accept = current_defer_accept; + } + } else { for (i = 3; i < (int) uwsgi.max_fd; i++) { diff --git a/core/uwsgi.c b/core/uwsgi.c index 91fe9c4a..1f130861 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -42,6 +42,7 @@ static struct uwsgi_option uwsgi_base_options[] = { {"protocol", required_argument, 0, "force the specified protocol for default sockets", uwsgi_opt_set_str, &uwsgi.protocol, 0}, {"socket-protocol", required_argument, 0, "force the specified protocol for default sockets", uwsgi_opt_set_str, &uwsgi.protocol, 0}, {"shared-socket", required_argument, 0, "create a shared sacket for advanced jailing or ipc", uwsgi_opt_add_shared_socket, NULL, 0}, + {"undeferred-shared-socket", required_argument, 0, "create a shared sacket for advanced jailing or ipc (undeferred mode)", uwsgi_opt_add_shared_socket, NULL, 0}, {"processes", required_argument, 'p', "spawn the specified number of workers/processes", uwsgi_opt_set_int, &uwsgi.numproc, 0}, {"workers", required_argument, 'p', "spawn the specified number of workers/processes", uwsgi_opt_set_int, &uwsgi.numproc, 0}, {"harakiri", required_argument, 't', "set harakiri timeout", uwsgi_opt_set_dyn, (void *) UWSGI_OPTION_HARAKIRI, 0}, @@ -3294,7 +3295,10 @@ void uwsgi_opt_add_regexp_custom_list(char *opt, char *value, void *list) { #endif void uwsgi_opt_add_shared_socket(char *opt, char *value, void *protocol) { - uwsgi_new_shared_socket(generate_socket_name(value)); + struct uwsgi_socket *us = uwsgi_new_shared_socket(generate_socket_name(value)); + if (!strcmp(opt, "undeferred-shared-socket")) { + us->no_defer = 1; + } } void uwsgi_opt_add_socket(char *opt, char *value, void *protocol) { diff --git a/uwsgi.h b/uwsgi.h index ab8b185e..85c1bbb3 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -641,6 +641,7 @@ struct uwsgi_socket { void *ctx; int queue; + int no_defer; int auto_port; // true if connection must be initialized for each core