diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2014-03-25 07:44:43 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2014-03-25 07:45:18 +0000 |
commit | cc5f305aaba4cefe2227aef2550d565f2f5a8147 (patch) | |
tree | 0be7c2bfb3c9f345db465f04b54ccb4b7bbb4de6 /main/uwsgi | |
parent | 855ad8d21bb69b8db500260c9e4033f3e60f1414 (diff) | |
download | aports-cc5f305aaba4cefe2227aef2550d565f2f5a8147.tar.bz2 aports-cc5f305aaba4cefe2227aef2550d565f2f5a8147.tar.xz |
main/uwsgi: moved from testing
Diffstat (limited to 'main/uwsgi')
13 files changed, 891 insertions, 0 deletions
diff --git a/main/uwsgi/0001-core-socket-common-socket-creation-function-for-bind.patch b/main/uwsgi/0001-core-socket-common-socket-creation-function-for-bind.patch new file mode 100644 index 0000000000..45b861f500 --- /dev/null +++ b/main/uwsgi/0001-core-socket-common-socket-creation-function-for-bind.patch @@ -0,0 +1,91 @@ +From 4d43a66581168674a9db52ac9bf690fa4f106dca Mon Sep 17 00:00:00 2001 +From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> +Date: Wed, 1 Jan 2014 23:36:26 +0200 +Subject: [PATCH 1/5] core/socket: common socket creation function for + bind_to_* + +--- + core/socket.c | 40 +++++++++++++++++----------------------- + 1 file changed, 17 insertions(+), 23 deletions(-) + +diff --git a/core/socket.c b/core/socket.c +index 0696eff..7e47dc0 100644 +--- a/core/socket.c ++++ b/core/socket.c +@@ -76,18 +76,23 @@ char *uwsgi_getsockname(int fd) { + return NULL; + } + ++static int create_server_socket(int domain, int type) { ++ int serverfd = socket(domain, type, 0); ++ if (serverfd < 0) { ++ uwsgi_error("socket()"); ++ uwsgi_nuclear_blast(); ++ } ++ return serverfd; ++} ++ + int bind_to_unix_dgram(char *socket_name) { + + int serverfd; + struct sockaddr_un *uws_addr; + socklen_t len; + +- serverfd = socket(AF_UNIX, SOCK_DGRAM, 0); +- if (serverfd < 0) { +- uwsgi_error("socket()"); +- uwsgi_nuclear_blast(); +- return -1; +- } ++ serverfd = create_server_socket(AF_UNIX, SOCK_DGRAM); ++ if (serverfd < 0) return -1; + + if (unlink(socket_name) != 0 && errno != ENOENT) { + uwsgi_error("error removing unix socket, unlink()"); +@@ -140,12 +145,8 @@ int bind_to_unix(char *socket_name, int listen_queue, int chmod_socket, int abst + } + + memset(uws_addr, 0, sizeof(struct sockaddr_un)); +- serverfd = socket(AF_UNIX, SOCK_STREAM, 0); +- if (serverfd < 0) { +- uwsgi_error("socket()"); +- uwsgi_nuclear_blast(); +- return -1; +- } ++ serverfd = create_server_socket(AF_UNIX, SOCK_STREAM); ++ if (serverfd < 0) return -1; + if (abstract_socket == 0) { + if (unlink(socket_name) != 0 && errno != ENOENT) { + uwsgi_error("unlink()"); +@@ -288,11 +289,8 @@ int bind_to_udp(char *socket_name, int multicast, int broadcast) { + } + + +- serverfd = socket(AF_INET, SOCK_DGRAM, 0); +- if (serverfd < 0) { +- uwsgi_error("socket()"); +- return -1; +- } ++ serverfd = create_server_socket(AF_INET, SOCK_DGRAM); ++ if (serverfd < 0) return -1; + + if (setsockopt(serverfd, SOL_SOCKET, SO_REUSEADDR, (const void *) &reuse, sizeof(int)) < 0) { + uwsgi_error("setsockopt()"); +@@ -667,12 +665,8 @@ int bind_to_tcp(char *socket_name, int listen_queue, char *tcp_port) { + #endif + + +- serverfd = socket(family, SOCK_STREAM, 0); +- if (serverfd < 0) { +- uwsgi_error("socket()"); +- uwsgi_nuclear_blast(); +- return -1; +- } ++ serverfd = create_server_socket(family, SOCK_STREAM); ++ if (serverfd < 0) return -1; + + if (uwsgi.so_sndbuf) { + socklen_t sndbuf = (socklen_t) uwsgi.so_sndbuf; +-- +1.8.4.2 + diff --git a/main/uwsgi/0001-use-portable-pthread-functions-instead-of-the-non-po.patch b/main/uwsgi/0001-use-portable-pthread-functions-instead-of-the-non-po.patch new file mode 100644 index 0000000000..cab800620a --- /dev/null +++ b/main/uwsgi/0001-use-portable-pthread-functions-instead-of-the-non-po.patch @@ -0,0 +1,40 @@ +From 1a09a7264026339d8e0c4899a2f9ff488c0bd97d Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Mon, 10 Feb 2014 12:13:00 +0000 +Subject: [PATCH 1/4] use portable pthread functions instead of the + non-portable + +The pthread functions pthread_mutexattr_setrobust and +pthread_mutex_consistent are in posix nowdays. Use those instead of their +non-portable synonyms. + +Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> +--- + core/lock.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/core/lock.c b/core/lock.c +index d368148..f806b2c 100644 +--- a/core/lock.c ++++ b/core/lock.c +@@ -99,7 +99,7 @@ retry: + exit(1); + } + if (uwsgi_pthread_robust_mutexes_enabled) { +- if (pthread_mutexattr_setrobust_np(&attr, PTHREAD_MUTEX_ROBUST)) { ++ if (pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST)) { + uwsgi_log("unable to make the mutex 'robust'\n"); + exit(1); + } +@@ -161,7 +161,7 @@ void uwsgi_lock_fast(struct uwsgi_lock_item *uli) { + #ifdef EOWNERDEAD + if (pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr) == EOWNERDEAD) { + uwsgi_log("[deadlock-detector] a process holding a robust mutex died. recovering...\n"); +- pthread_mutex_consistent_np((pthread_mutex_t *) uli->lock_ptr); ++ pthread_mutex_consistent((pthread_mutex_t *) uli->lock_ptr); + } + #else + pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr); +-- +1.8.5.3 + diff --git a/main/uwsgi/0002-Check-for-GNU-libc-instead-of-linux-for-use-of-execi.patch b/main/uwsgi/0002-Check-for-GNU-libc-instead-of-linux-for-use-of-execi.patch new file mode 100644 index 0000000000..8ab4d9ffff --- /dev/null +++ b/main/uwsgi/0002-Check-for-GNU-libc-instead-of-linux-for-use-of-execi.patch @@ -0,0 +1,31 @@ +From ab68dc90d3a6e3ae660adb65cf8a020d91eb8f09 Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Mon, 10 Feb 2014 12:17:18 +0000 +Subject: [PATCH 2/4] Check for GNU libc instead of linux for use of execinfo.h + +Since execinfo.h is a GNU extension it makes more sense to check for GNU +than to assume that linux is GNU. + +This is needed for building on linux with musl libc. + +Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> +--- + core/uwsgi.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/core/uwsgi.c b/core/uwsgi.c +index 67b175b..b3b25ae 100644 +--- a/core/uwsgi.c ++++ b/core/uwsgi.c +@@ -1690,7 +1690,7 @@ void uwsgi_plugins_atexit(void) { + + void uwsgi_backtrace(int depth) { + +-#if defined(__linux__) || (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO) ++#if defined(__GLIBC__) || (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO) + + #include <execinfo.h> + +-- +1.8.5.3 + diff --git a/main/uwsgi/0002-core-socket-move-socket-buffer-size-setting-to-creat.patch b/main/uwsgi/0002-core-socket-move-socket-buffer-size-setting-to-creat.patch new file mode 100644 index 0000000000..88cb2b73a4 --- /dev/null +++ b/main/uwsgi/0002-core-socket-move-socket-buffer-size-setting-to-creat.patch @@ -0,0 +1,97 @@ +From 32b71268365456f246d20212e0acf63bfdf9ffe6 Mon Sep 17 00:00:00 2001 +From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> +Date: Wed, 1 Jan 2014 23:46:02 +0200 +Subject: [PATCH 2/5] core/socket: move socket buffer size setting to + create_server_socket + +--- + core/socket.c | 58 ++++++++++++++++++++++------------------------------------ + 1 file changed, 22 insertions(+), 36 deletions(-) + +diff --git a/core/socket.c b/core/socket.c +index 7e47dc0..ee63b98 100644 +--- a/core/socket.c ++++ b/core/socket.c +@@ -81,7 +81,29 @@ static int create_server_socket(int domain, int type) { + if (serverfd < 0) { + uwsgi_error("socket()"); + uwsgi_nuclear_blast(); ++ return -1; ++ } ++ ++ if (type == SOCK_STREAM) { ++ if (uwsgi.so_sndbuf) { ++ socklen_t sndbuf = (socklen_t) uwsgi.so_sndbuf; ++ if (setsockopt(serverfd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(socklen_t)) < 0) { ++ uwsgi_error("SO_SNDBUF setsockopt()"); ++ uwsgi_nuclear_blast(); ++ return -1; ++ } ++ } ++ ++ if (uwsgi.so_rcvbuf) { ++ socklen_t rcvbuf = (socklen_t) uwsgi.so_rcvbuf; ++ if (setsockopt(serverfd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(socklen_t)) < 0) { ++ uwsgi_error("SO_RCVBUF setsockopt()"); ++ uwsgi_nuclear_blast(); ++ return -1; ++ } ++ } + } ++ + return serverfd; + } + +@@ -157,24 +179,6 @@ int bind_to_unix(char *socket_name, int listen_queue, int chmod_socket, int abst + uwsgi_log("setting abstract socket mode (warning: only Linux supports this)\n"); + } + +- if (uwsgi.so_sndbuf) { +- socklen_t sndbuf = (socklen_t) uwsgi.so_sndbuf; +- if (setsockopt(serverfd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(socklen_t)) < 0) { +- uwsgi_error("SO_SNDBUF setsockopt()"); +- uwsgi_nuclear_blast(); +- return -1; +- } +- } +- +- if (uwsgi.so_rcvbuf) { +- socklen_t rcvbuf = (socklen_t) uwsgi.so_rcvbuf; +- if (setsockopt(serverfd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(socklen_t)) < 0) { +- uwsgi_error("SO_RCVBUF setsockopt()"); +- uwsgi_nuclear_blast(); +- return -1; +- } +- } +- + uws_addr->sun_family = AF_UNIX; + if (socket_name[0] == '@') { + memcpy(uws_addr->sun_path + abstract_socket, socket_name + 1, UMIN(strlen(socket_name + 1), 101)); +@@ -668,24 +672,6 @@ int bind_to_tcp(char *socket_name, int listen_queue, char *tcp_port) { + serverfd = create_server_socket(family, SOCK_STREAM); + if (serverfd < 0) return -1; + +- if (uwsgi.so_sndbuf) { +- socklen_t sndbuf = (socklen_t) uwsgi.so_sndbuf; +- if (setsockopt(serverfd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(socklen_t)) < 0) { +- uwsgi_error("SO_SNDBUF setsockopt()"); +- uwsgi_nuclear_blast(); +- return -1; +- } +- } +- +- if (uwsgi.so_rcvbuf) { +- socklen_t rcvbuf = (socklen_t) uwsgi.so_rcvbuf; +- if (setsockopt(serverfd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(socklen_t)) < 0) { +- uwsgi_error("SO_RCVBUF setsockopt()"); +- uwsgi_nuclear_blast(); +- return -1; +- } +- } +- + if (setsockopt(serverfd, SOL_SOCKET, SO_REUSEADDR, (const void *) &reuse, sizeof(int)) < 0) { + uwsgi_error("SO_REUSEADDR setsockopt()"); + uwsgi_nuclear_blast(); +-- +1.8.4.2 + diff --git a/main/uwsgi/0003-always-define-_GNU_SOURCE-for-linux.patch b/main/uwsgi/0003-always-define-_GNU_SOURCE-for-linux.patch new file mode 100644 index 0000000000..5b02cb6ef4 --- /dev/null +++ b/main/uwsgi/0003-always-define-_GNU_SOURCE-for-linux.patch @@ -0,0 +1,64 @@ +From c6ddb3e4ca72f6ec8662f8a18674eb4d861561b8 Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Mon, 10 Feb 2014 13:03:50 +0000 +Subject: [PATCH 3/4] always define _GNU_SOURCE for linux + +We are using various extenstions that the spec say depends on _GNU_SOURCE, +for example unshare, CPU_SET, CPU_ZERO, cpu_set_t. We enable those always +for linux and we never unset it. + +Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> +--- + uwsgi.h | 18 +++++------------- + 1 file changed, 5 insertions(+), 13 deletions(-) + +diff --git a/uwsgi.h b/uwsgi.h +index b3ce4f7..3131a0f 100644 +--- a/uwsgi.h ++++ b/uwsgi.h +@@ -149,29 +149,22 @@ extern "C" { + #endif + #endif + ++#ifdef __linux__ + #ifndef _GNU_SOURCE + #define _GNU_SOURCE + #endif +-#include <stdio.h> +-#ifdef __UCLIBC__ +-#include <sched.h> ++#ifndef __USE_GNU ++#define __USE_GNU ++#endif + #endif +-#undef _GNU_SOURCE + ++#include <stdio.h> + #include <stdlib.h> + #include <stddef.h> + #include <signal.h> + #include <math.h> + + #include <sys/types.h> +-#ifdef __linux__ +-#ifndef _GNU_SOURCE +-#define _GNU_SOURCE +-#endif +-#ifndef __USE_GNU +-#define __USE_GNU +-#endif +-#endif + #include <sys/socket.h> + #include <net/if.h> + #ifdef __linux__ +@@ -179,7 +172,6 @@ extern "C" { + #define MSG_FASTOPEN 0x20000000 + #endif + #endif +-#undef _GNU_SOURCE + #include <netinet/in.h> + + #include <termios.h> +-- +1.8.5.3 + diff --git a/main/uwsgi/0003-core-socket-move-listen-queue-size-checking-to-creat.patch b/main/uwsgi/0003-core-socket-move-listen-queue-size-checking-to-creat.patch new file mode 100644 index 0000000000..c7ed55d04c --- /dev/null +++ b/main/uwsgi/0003-core-socket-move-listen-queue-size-checking-to-creat.patch @@ -0,0 +1,65 @@ +From 51a8f31f17440702b308b15e0c9dd73255cbb572 Mon Sep 17 00:00:00 2001 +From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> +Date: Wed, 1 Jan 2014 23:55:57 +0200 +Subject: [PATCH 3/5] core/socket: move listen queue size checking to + create_server_socket + +--- + core/socket.c | 27 +++++++++------------------ + 1 file changed, 9 insertions(+), 18 deletions(-) + +diff --git a/core/socket.c b/core/socket.c +index ee63b98..3eed477 100644 +--- a/core/socket.c ++++ b/core/socket.c +@@ -102,6 +102,15 @@ static int create_server_socket(int domain, int type) { + return -1; + } + } ++ ++#ifdef __linux__ ++ long somaxconn = uwsgi_num_from_file("/proc/sys/net/core/somaxconn", 1); ++ if (somaxconn > 0 && uwsgi.listen_queue > somaxconn) { ++ uwsgi_log("Listen queue size is greater than the system max net.core.somaxconn (%li).\n", somaxconn); ++ uwsgi_nuclear_blast(); ++ return -1; ++ } ++#endif + } + + return serverfd; +@@ -208,15 +217,6 @@ int bind_to_unix(char *socket_name, int listen_queue, int chmod_socket, int abst + return -1; + } + +-#ifdef __linux__ +- long somaxconn = uwsgi_num_from_file("/proc/sys/net/core/somaxconn", 1); +- if (somaxconn > 0 && uwsgi.listen_queue > somaxconn) { +- uwsgi_log("Listen queue size is greater than the system max net.core.somaxconn (%li).\n", somaxconn); +- uwsgi_nuclear_blast(); +- return -1; +- } +-#endif +- + if (listen(serverfd, listen_queue) != 0) { + uwsgi_error("listen()"); + uwsgi_nuclear_blast(); +@@ -761,15 +761,6 @@ int bind_to_tcp(char *socket_name, int listen_queue, char *tcp_port) { + return -1; + } + +-#ifdef __linux__ +- long somaxconn = uwsgi_num_from_file("/proc/sys/net/core/somaxconn", 1); +- if (somaxconn > 0 && uwsgi.listen_queue > somaxconn) { +- uwsgi_log("Listen queue size is greater than the system max net.core.somaxconn (%li).\n", somaxconn); +- uwsgi_nuclear_blast(); +- return -1; +- } +-#endif +- + if (listen(serverfd, listen_queue) != 0) { + uwsgi_error("listen()"); + uwsgi_nuclear_blast(); +-- +1.8.4.2 + diff --git a/main/uwsgi/0004-core-socket-move-SO_REUSEADDR-setting-to-create_serv.patch b/main/uwsgi/0004-core-socket-move-SO_REUSEADDR-setting-to-create_serv.patch new file mode 100644 index 0000000000..904828b43f --- /dev/null +++ b/main/uwsgi/0004-core-socket-move-SO_REUSEADDR-setting-to-create_serv.patch @@ -0,0 +1,73 @@ +From 4f4f9b93aae55e40dc7f92e19a7e5080a06ce798 Mon Sep 17 00:00:00 2001 +From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> +Date: Thu, 2 Jan 2014 00:05:01 +0200 +Subject: [PATCH 4/5] core/socket: move SO_REUSEADDR setting to + create_server_socket + +--- + core/socket.c | 21 +++++++++------------ + 1 file changed, 9 insertions(+), 12 deletions(-) + +diff --git a/core/socket.c b/core/socket.c +index 3eed477..6d5d7d7 100644 +--- a/core/socket.c ++++ b/core/socket.c +@@ -84,6 +84,15 @@ static int create_server_socket(int domain, int type) { + return -1; + } + ++ if (domain != AF_UNIX) { ++ int reuse = 1; ++ if (setsockopt(serverfd, SOL_SOCKET, SO_REUSEADDR, (const void *) &reuse, sizeof(int)) < 0) { ++ uwsgi_error("SO_REUSEADDR setsockopt()"); ++ uwsgi_nuclear_blast(); ++ return -1; ++ } ++ } ++ + if (type == SOCK_STREAM) { + if (uwsgi.so_sndbuf) { + socklen_t sndbuf = (socklen_t) uwsgi.so_sndbuf; +@@ -248,7 +257,6 @@ int bind_to_udp(char *socket_name, int multicast, int broadcast) { + struct sockaddr_in uws_addr; + char *udp_port; + int bcast = 1; +- int reuse = 1; + + struct ip_mreq mc; + +@@ -296,10 +304,6 @@ int bind_to_udp(char *socket_name, int multicast, int broadcast) { + serverfd = create_server_socket(AF_INET, SOCK_DGRAM); + if (serverfd < 0) return -1; + +- if (setsockopt(serverfd, SOL_SOCKET, SO_REUSEADDR, (const void *) &reuse, sizeof(int)) < 0) { +- uwsgi_error("setsockopt()"); +- } +- + if (multicast) { + // if multicast is enabled remember to bind to INADDR_ANY + uws_addr.sin_addr.s_addr = INADDR_ANY; +@@ -651,7 +655,6 @@ int bind_to_tcp(char *socket_name, int listen_queue, char *tcp_port) { + #else + struct sockaddr_in uws_addr; + #endif +- int reuse = 1; + int family = AF_INET; + socklen_t addr_len = sizeof(struct sockaddr_in); + +@@ -672,12 +675,6 @@ int bind_to_tcp(char *socket_name, int listen_queue, char *tcp_port) { + serverfd = create_server_socket(family, SOCK_STREAM); + if (serverfd < 0) return -1; + +- if (setsockopt(serverfd, SOL_SOCKET, SO_REUSEADDR, (const void *) &reuse, sizeof(int)) < 0) { +- uwsgi_error("SO_REUSEADDR setsockopt()"); +- uwsgi_nuclear_blast(); +- return -1; +- } +- + #ifdef __linux__ + #ifndef IP_FREEBIND + #define IP_FREEBIND 15 +-- +1.8.4.2 + diff --git a/main/uwsgi/0004-define-WAIT_ANY-if-missing.patch b/main/uwsgi/0004-define-WAIT_ANY-if-missing.patch new file mode 100644 index 0000000000..1281752111 --- /dev/null +++ b/main/uwsgi/0004-define-WAIT_ANY-if-missing.patch @@ -0,0 +1,34 @@ +From 393de27d01710718ffedf46cbbe20c5a1d559c9e Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Mon, 10 Feb 2014 13:15:07 +0000 +Subject: [PATCH 4/4] define WAIT_ANY if missing + +POSIX uses -1 and does not define WAIT_ANY so we need to define it if +needed. + +See: +http://pubs.opengroup.org/onlinepubs/9699919799/functions/waitpid.html +http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html + +Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> +--- + uwsgi.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/uwsgi.h b/uwsgi.h +index 3131a0f..7a0d93e 100644 +--- a/uwsgi.h ++++ b/uwsgi.h +@@ -257,6 +257,9 @@ extern int pivot_root(const char *new_root, const char *put_old); + #include <stdint.h> + + #include <sys/wait.h> ++#ifndef WAIT_ANY ++#define WAIT_ANY (-1) ++#endif + + #ifdef __APPLE__ + #ifndef MAC_OS_X_VERSION_MIN_REQUIRED +-- +1.8.5.3 + diff --git a/main/uwsgi/0005-option-for-closing-server-sockets-when-spawning.patch b/main/uwsgi/0005-option-for-closing-server-sockets-when-spawning.patch new file mode 100644 index 0000000000..b91f1d62ed --- /dev/null +++ b/main/uwsgi/0005-option-for-closing-server-sockets-when-spawning.patch @@ -0,0 +1,70 @@ +From de160406dbe358fb599eb8343e82f18252247a19 Mon Sep 17 00:00:00 2001 +From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> +Date: Wed, 1 Jan 2014 03:51:56 +0200 +Subject: [PATCH 5/5] option for closing server sockets when spawning + +If server fd is not closed, it is not possible to restart uwsgi if the +spawned process is still running as it keeps the address/port bound. +--- + core/master_utils.c | 1 + + core/socket.c | 3 +++ + core/uwsgi.c | 3 ++- + uwsgi.h | 2 ++ + 4 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/core/master_utils.c b/core/master_utils.c +index 89151a0..6316209 100644 +--- a/core/master_utils.c ++++ b/core/master_utils.c +@@ -407,6 +407,7 @@ void uwsgi_reload(char **argv) { + /* check fd table (a module can obviosly open some fd on initialization...) */ + uwsgi_log("closing all non-uwsgi socket fds > 2 (max_fd = %d)...\n", (int) uwsgi.max_fd); + for (i = 3; i < (int) uwsgi.max_fd; i++) { ++ fcntl(i, F_SETFD, 0); + + if (uwsgi_fd_is_safe(i)) continue; + +diff --git a/core/socket.c b/core/socket.c +index 6d5d7d7..8b66a47 100644 +--- a/core/socket.c ++++ b/core/socket.c +@@ -84,6 +84,9 @@ static int create_server_socket(int domain, int type) { + return -1; + } + ++ if (uwsgi.close_on_exec2 && fcntl(serverfd, F_SETFD, FD_CLOEXEC) < 0) ++ uwsgi_error("fcntl()"); ++ + if (domain != AF_UNIX) { + int reuse = 1; + if (setsockopt(serverfd, SOL_SOCKET, SO_REUSEADDR, (const void *) &reuse, sizeof(int)) < 0) { +diff --git a/core/uwsgi.c b/core/uwsgi.c +index 51821bc..d3d6538 100644 +--- a/core/uwsgi.c ++++ b/core/uwsgi.c +@@ -871,7 +871,8 @@ static struct uwsgi_option uwsgi_base_options[] = { + {"disable-sendfile", no_argument, 0, "disable sendfile() and rely on boring read()/write()", uwsgi_opt_true, &uwsgi.disable_sendfile, 0}, + + {"check-cache", optional_argument, 0, "check for response data in the specified cache (empty for default cache)", uwsgi_opt_set_str, &uwsgi.use_check_cache, 0}, +- {"close-on-exec", no_argument, 0, "set close-on-exec on sockets (could be required for spawning processes in requests)", uwsgi_opt_true, &uwsgi.close_on_exec, 0}, ++ {"close-on-exec", no_argument, 0, "set close-on-exec on connection sockets (could be required for spawning processes in requests)", uwsgi_opt_true, &uwsgi.close_on_exec, 0}, ++ {"close-on-exec2", no_argument, 0, "set close-on-exec on server sockets (could be required for spawning processes in requests)", uwsgi_opt_true, &uwsgi.close_on_exec2, 0}, + {"mode", required_argument, 0, "set uWSGI custom mode", uwsgi_opt_set_str, &uwsgi.mode, 0}, + {"env", required_argument, 0, "set environment variable", uwsgi_opt_set_env, NULL, 0}, + {"envdir", required_argument, 0, "load a daemontools compatible envdir", uwsgi_opt_add_string_list, &uwsgi.envdirs, 0}, +diff --git a/uwsgi.h b/uwsgi.h +index 29dfc2d..ccb41d4 100644 +--- a/uwsgi.h ++++ b/uwsgi.h +@@ -2516,6 +2516,8 @@ struct uwsgi_server { + void (*gbcw_hook) (void); + + int close_on_exec; ++ int close_on_exec2; ++ + int tcp_nodelay; + + char *loop; +-- +1.8.4.2 + diff --git a/main/uwsgi/APKBUILD b/main/uwsgi/APKBUILD new file mode 100644 index 0000000000..cd3085b896 --- /dev/null +++ b/main/uwsgi/APKBUILD @@ -0,0 +1,106 @@ +# Contributor: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> +# Maintainer: Natanael Copa <ncopa@alpinelinux.org> +pkgname=uwsgi +pkgver=2.0.1 +pkgrel=1 +pkgdesc="uWSGI application container server" +url=http://projects.unbit.it/uwsgi/ +arch=all +license=GPL-2 +makedepends="linux-headers lua5.2-dev python python-dev zeromq-dev paxctl + pcre-dev" +source="http://projects.unbit.it/downloads/uwsgi-${pkgver}.tar.gz + uwsgi.initd uwsgi.confd + + 0001-use-portable-pthread-functions-instead-of-the-non-po.patch + 0002-Check-for-GNU-libc-instead-of-linux-for-use-of-execi.patch + 0003-always-define-_GNU_SOURCE-for-linux.patch + 0004-define-WAIT_ANY-if-missing.patch + musl-fix-python.patch + " + +_plugins="lua python router_uwsgi" +subpackages="" +for _p in $_plugins ; do + subpackages="$subpackages uwsgi-$_p:_$_p" +done + +_builddir=$srcdir/$pkgname-$pkgver +prepare() { + local i + cd "$_builddir" + for i in $source; do + case $i in + *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;; + esac + done +} + +build() { + cd "$_builddir" + + msg "building core" + # ccache seems to trigger some weird bug on musl + CC="gcc" python uwsgiconfig.py --build core || return 1 + + export UWSGICONFIG_LUAPC="lua5.2" + for i in $_plugins; do + msg "building $i plugin" + python uwsgiconfig.py --plugin plugins/$i core || return 1 + done +} + +package() { + cd "$_builddir" + + local bindir=$pkgdir/usr/sbin + install -d "$bindir" + install uwsgi "$bindir" + + local libdir=$pkgdir/usr/lib/uwsgi + install -d "$libdir" + install *_plugin.so "$libdir" + + install -Dm755 "$srcdir"/uwsgi.initd \ + "$pkgdir"/etc/init.d/uwsgi || return 1 + install -Dm644 "$srcdir"/uwsgi.confd \ + "$pkgdir"/etc/conf.d/uwsgi || return 1 + + # disable emutramp/mprotect, this is needed for luajit and cffi + paxctl -czxm "$bindir"/uwsgi +} + +_plugin() { + depends=uwsgi + mkdir -p "$subpkgdir"/usr/lib/uwsgi + mv "$pkgdir/usr/lib/uwsgi/$1_plugin.so" "$subpkgdir/usr/lib/uwsgi" || return 1 +} + +for _p in $_plugins; do + eval "_$_p() { _plugin $_p; }" +done + +md5sums="e7234f16ddfb4fe5d0b5d5fa76dc17e1 uwsgi-2.0.1.tar.gz +23b476a8ad6aab93b162e8eeec50c859 uwsgi.initd +3d6afe6a8c52556d1d6c52384fc38d9a uwsgi.confd +a7f98e2775e9f38a0f16c28332745836 0001-use-portable-pthread-functions-instead-of-the-non-po.patch +b40fe76f34674874815c39a7e611f259 0002-Check-for-GNU-libc-instead-of-linux-for-use-of-execi.patch +43e4edbe50bde1096e8ca03297a1f271 0003-always-define-_GNU_SOURCE-for-linux.patch +1ee8996f7cced9dc88515c69c04dd79a 0004-define-WAIT_ANY-if-missing.patch +87c16f6fe482c9b0eac0d33c51873f45 musl-fix-python.patch" +sha256sums="e84e498c217a793571f803d04fca4f2877dd856e9c5af1e66e645132d70c7cc2 uwsgi-2.0.1.tar.gz +df99bc13609a526432afaeb16661086c73f49394e069a19ccb7423bbd025168f uwsgi.initd +4cb047e311aecd0f498da1d6a4c0947dd6dc7cc98575d54cb2ef150cacf8425c uwsgi.confd +b61bf4da3d022ddfd93a73196300cb86d962f8f6198079d11b727f61c0f8acb4 0001-use-portable-pthread-functions-instead-of-the-non-po.patch +360ede589ad228f31dd06fbf8dc17d86d60e968ae76a61b3ca258a2c5ae6f007 0002-Check-for-GNU-libc-instead-of-linux-for-use-of-execi.patch +6cefd10432900518b3c19ee7f2a20b6b1f722b6d6e7ad43e4c3ad1be3daf43ee 0003-always-define-_GNU_SOURCE-for-linux.patch +82a2c13162387efcafa388038602d783f8a7e71c28d56ab3ac6b94abeba474d3 0004-define-WAIT_ANY-if-missing.patch +3838e8e3926a1f6271bb5aa88d309837a3bcd06cd570c499b72ca549326c682e musl-fix-python.patch" +sha512sums="91d134413beac4d36ad4c1334410bd4d68a1bd53b4700da00e39f17fe01b1059457a102a9835ee09f8971b26597766ec8812afb5219c4774c2c7dbc025bcf617 uwsgi-2.0.1.tar.gz +5d8eadba7c6ee17f86c3dbb6b7c98131ecf9db173156e3196909550954dd09be2191285f46fd4e558f0c47a0cbe7831cde71d3d4c63862d11b819660cc418131 uwsgi.initd +9f00afb2aa574bbc59040f945475712b8c40da0c06eeb5699de5510aa116148e35ab0429fa891084cf0cd7868876d5a80e1601b7c85d0e2e9ea2a1f54cdde619 uwsgi.confd +d105c487d8bd0b496cfac2dad6090f0e420805a83dca514bfbea97c687be26d7a8b9545add0f999cb67eb66818b05995405f9a874b970f53aa38ff5ce3bbdc02 0001-use-portable-pthread-functions-instead-of-the-non-po.patch +f4038ab866f445a94e155f4b73d308959c402e81227401bc7a5fe2165b888a2c8d95141245a2c10b186782934a4103c785769afaf4091fe3fe5524ed3c270fcf 0002-Check-for-GNU-libc-instead-of-linux-for-use-of-execi.patch +fc13550528121a1c8ecd530b38ea63f3802cb6d829ec18e55e485acb592b29bed8afe4d23a5f8b9baf8076a00f72d45e8b48c5c56e8c05299b7a1ea7a0ee2e77 0003-always-define-_GNU_SOURCE-for-linux.patch +deb9fb2f125b80534e8176d32ec7cd85d49225339ccd989cfb463f5b38aa0869841c4bf9a2a97e0ed1c38b999599edb057b9aae17bdad96dad68970362e8bbc3 0004-define-WAIT_ANY-if-missing.patch +de68b16b44e554a79c073c9befa10566796316dbf4c375b4d6b633d80b0282694cca233f0a70f3d6570584324f14276826bbeb8f38b550c00087a05f9ba9227f musl-fix-python.patch" diff --git a/main/uwsgi/musl-fix-python.patch b/main/uwsgi/musl-fix-python.patch new file mode 100644 index 0000000000..b4b8fd240f --- /dev/null +++ b/main/uwsgi/musl-fix-python.patch @@ -0,0 +1,13 @@ +diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h +index 0c5c1c8..5c0dc6d 100644 +--- a/plugins/python/uwsgi_python.h ++++ b/plugins/python/uwsgi_python.h +@@ -1,4 +1,8 @@ + #include <uwsgi.h> ++/* seems like Python.h explicitlyl redefines _GNU_SOURCE */ ++#ifdef _GNU_SOURCE ++#undef _GNU_SOURCE ++#endif + #include <Python.h> + + #include <frameobject.h> diff --git a/main/uwsgi/uwsgi.confd b/main/uwsgi/uwsgi.confd new file mode 100644 index 0000000000..7759361981 --- /dev/null +++ b/main/uwsgi/uwsgi.confd @@ -0,0 +1,63 @@ +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/www-servers/uwsgi/files/uwsgi.confd-r3,v 1.1 2013/03/01 09:50:06 ultrabug Exp $ + +# YOU SHOULD ONLY MODIFY THIS FILE IF YOU USE THE UWSGI EMPEROR MODE! +# IF YOU WANT TO RUN A SINGLE APP INSTANCE, CREATE A COPY AND MODIFY THAT INSTEAD! + +# Path (or name) of UNIX/TCP socket to bind to +# Example : UWSGI_SOCKET=127.0.0.1:1234 +UWSGI_SOCKET= + +# Enable threads? (1 = yes, 0 = no). The default is 0 +# +UWSGI_THREADS=0 + +# The path to your uWSGI application. +# +UWSGI_PROGRAM= + +# The path to your uWSGI xml config file. +# +UWSGI_XML_CONFIG= + +# The number of child processes to spawn. The default is 1. +# +UWSGI_PROCESSES=1 + +# The log file path. If empty, log only errors +# +UWSGI_LOG_FILE= + +# If you want to run your application inside a chroot then specify the +# directory here. Leave this blank otherwise. +# +UWSGI_CHROOT= + +# If you want to run your application from a specific directiory specify +# it here. Leave this blank otherwise. +# +UWSGI_DIR= + +# The user to run your application as. If you do not specify these, +# the application will be run as user root. +# +UWSGI_USER= + +# The group to run your application as. If you do not specify these, +# the application will be run as group root. +# +UWSGI_GROUP= + +# Run the uwsgi emperor which loads vassals dynamically from this PATH +# see http://projects.unbit.it/uwsgi/wiki/Emperor +# The advised Gentoo folder is /etc/uwsgi.d/ +UWSGI_EMPEROR_PATH= + +# The group the emperor should run as. This is different from the UWSGI_GROUP +# as you could want your apps share some sockets with other processes such as +# www servers while preserving your emperor logs from being accessible by them. +UWSGI_EMPEROR_GROUP= + +# Additional options you might want to pass to uWSGI +# +UWSGI_EXTRA_OPTIONS= diff --git a/main/uwsgi/uwsgi.initd b/main/uwsgi/uwsgi.initd new file mode 100644 index 0000000000..0f330d5689 --- /dev/null +++ b/main/uwsgi/uwsgi.initd @@ -0,0 +1,144 @@ +#!/sbin/runscript +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/www-servers/uwsgi/files/uwsgi.initd-r3,v 1.1 2013/03/01 09:50:06 ultrabug Exp $ + +PROGNAME=${SVCNAME#*.} + +UWSGI_EXEC=/usr/sbin/uwsgi +if [ "${SVCNAME}" == "uwsgi" ]; then + PIDPATH=/var/run/uwsgi +else + PIDPATH="/var/run/uwsgi_${PROGNAME}" +fi +PIDFILE="${PIDPATH}/${PROGNAME}.pid" + +extra_started_commands="${opts} reload stats" + +depend() { + need net +} + +start_pre() { + checkpath -d -m 0750 -o "${UWSGI_USER}":"${UWSGI_GROUP}" "${PIDPATH}" +} + +start_emperor() { + local OPTIONS + OPTIONS="--daemonize" + + if [ -n "${UWSGI_LOG_FILE}" ]; then + OPTIONS="${OPTIONS} ${UWSGI_LOG_FILE}" + else + OPTIONS="${OPTIONS} /dev/null --disable-logging" + fi + + [ -z "${UWSGI_DIR}" ] && UWSGI_DIR="/" + [ -z "${UWSGI_USER}" ] && UWSGI_USER="root" + [ -z "${UWSGI_GROUP}" ] && UWSGI_GROUP="root" + + if [ -n "${UWSGI_EXTRA_OPTIONS}" ]; then + OPTIONS="${OPTIONS} ${UWSGI_EXTRA_OPTIONS}" + fi + + ebegin "Starting uWSGI emperor" + cd "${UWSGI_DIR}" && \ + start-stop-daemon --start --user "${UWSGI_USER}" --exec "${UWSGI_EXEC}" \ + --group ${UWSGI_EMPEROR_GROUP:-${UWSGI_GROUP}} \ + -- --emperor "${UWSGI_EMPEROR_PATH}" ${OPTIONS} --pidfile "${PIDFILE}" + return $? +} + +start_app() { + local OPTIONS + OPTIONS="--master --daemonize" + + if [ -n "${UWSGI_LOG_FILE}" ]; then + OPTIONS="${OPTIONS} ${UWSGI_LOG_FILE}" + else + OPTIONS="${OPTIONS} /dev/null --disable-logging" + fi + + [ -z "${UWSGI_DIR}" ] && UWSGI_DIR="/" + [ -z "${UWSGI_USER}" ] && UWSGI_USER="root" + [ -z "${UWSGI_GROUP}" ] && UWSGI_GROUP="root" + + if [ -n "${UWSGI_EXTRA_OPTIONS}" ]; then + OPTIONS="${OPTIONS} ${UWSGI_EXTRA_OPTIONS}" + fi + + if [ "${UWSGI_THREADS}" = "1" ]; then + OPTIONS="${OPTIONS} --enable-threads" + fi + + if [ -n "${UWSGI_SOCKET}" ]; then + OPTIONS="${OPTIONS} --socket ${UWSGI_SOCKET}" + fi + + if [ -n "${UWSGI_PROCESSES}" ]; then + OPTIONS="${OPTIONS} --processes ${UWSGI_PROCESSES}" + fi + + if [ -n "${UWSGI_CHROOT}" ]; then + OPTIONS="${OPTIONS} --chroot ${UWSGI_CHROOT}" + fi + + if [ -n "${UWSGI_PROGRAM}" ]; then + OPTIONS="${OPTIONS} --fileserve-mode ${UWSGI_PROGRAM}" + fi + + if [ -n "${UWSGI_XML_CONFIG}" ]; then + OPTIONS="${OPTIONS} --xmlconfig ${UWSGI_XML_CONFIG}" + fi + + ebegin "Starting uWSGI application ${PROGNAME}" + cd "${UWSGI_DIR}" && \ + start-stop-daemon --start --user "${UWSGI_USER}" --group "${UWSGI_GROUP}" \ + --exec "${UWSGI_EXEC}" -- ${OPTIONS} --pidfile "${PIDFILE}" + return $? +} + +start() { + if [ "${SVCNAME}" == "uwsgi" ]; then + if [ -n "${UWSGI_EMPEROR_PATH}" ]; then + start_emperor + eend $? + else + eerror "You are not supposed to run this script directly unless you" + eerror "want to run in Emperor mode. In that case please set the UWSGI_EMPEROR_PATH." + eerror "Otherwise create a symlink for the uwsgi application you want to run as well as" + eerror "a copy of the configuration file and modify it appropriately like so..." + eerror + eerror " ln -s uwsgi /etc/init.d/uwsgi.trac" + eerror " cp /etc/conf.d/uwsgi /etc/conf.d/uwsgi.trac" + eerror " nano /etc/conf.d/uwsgi.trac" + eerror + return 1 + fi + else + start_app + eend $? + fi +} + +stop() { + if [ -n "${UWSGI_EMPEROR_PATH}" ]; then + ebegin "Stopping uWSGI emperor" + else + ebegin "Stopping uWSGI application ${PROGNAME}" + fi + start-stop-daemon --stop --signal QUIT --pidfile "${PIDFILE}" + eend $? +} + +reload() { + ebegin "Reloading uWSGI" + start-stop-daemon --signal HUP --pidfile "${PIDFILE}" + eend $? +} + +stats() { + ebegin "Logging uWSGI statistics" + start-stop-daemon --signal USR1 --pidfile "${PIDFILE}" + eend $? +} |