Skip to content

Commit

Permalink
added --freebind option (Linux only)
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto@dexter committed Jul 22, 2011
1 parent d590a18 commit 43d89b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions socket.c
Expand Up @@ -500,6 +500,17 @@ int bind_to_tcp(char *socket_name, int listen_queue, char *tcp_port) {
uwsgi_nuclear_blast();
}

#ifdef __linux__
#ifdef IP_FREEBIND
if (uwsgi.freebind) {
if (setsockopt(serverfd, SOL_IP, IP_FREEBIND, (const void *) &uwsgi.freebind, sizeof(int)) < 0) {
uwsgi_error("setsockopt()");
uwsgi_nuclear_blast();
}
}
#endif
#endif

if (uwsgi.reuse_port) {
#ifdef SO_REUSEPORT
if (setsockopt(serverfd, SOL_SOCKET, SO_REUSEPORT, (const void *) &uwsgi.reuse_port, sizeof(int)) < 0) {
Expand Down
3 changes: 3 additions & 0 deletions uwsgi.c
Expand Up @@ -57,6 +57,9 @@ static struct option long_base_options[] = {
{"abstract-socket", no_argument, 0, 'a'},
{"chmod-socket", optional_argument, 0, 'C'},
{"chown-socket", required_argument, 0, LONG_ARGS_CHOWN_SOCKET},
#ifdef __linux__
{"freebind", no_argument, &uwsgi.freebind, 1},
#endif
{"map-socket", required_argument, 0, LONG_ARGS_MAP_SOCKET},
{"chmod", optional_argument, 0, 'C'},
#ifdef UWSGI_THREADING
Expand Down
4 changes: 4 additions & 0 deletions uwsgi.h
Expand Up @@ -1095,6 +1095,10 @@ struct uwsgi_server {
struct timeval start_tv;

int abstract_socket;
#ifdef __linux__
int freebind;
#endif

int chmod_socket;
char *chown_socket;
mode_t chmod_socket_value;
Expand Down

0 comments on commit 43d89b2

Please sign in to comment.