mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-10-04 16:08:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f43cd74ad | ||
|
|
6585b7b13d | ||
|
|
e55048b574 | ||
|
|
570dcde654 | ||
|
|
3cb16ee29b | ||
|
|
bb453da5b5 | ||
|
|
1a93b68664 | ||
|
|
2ce2494a50 | ||
|
|
0a1e451289 | ||
|
|
8ef7819080 | ||
|
|
319ad13af2 | ||
|
|
fe28e90ae3 | ||
|
|
f604a0a533 | ||
|
|
4ab78d42a3 |
@@ -46,3 +46,5 @@ af490b8c30f83bc5fb6f3837a760981474647755 1.0-rc10
|
||||
8fe7bb792399cb6e6a24e20551f4149409660363 1.0.1
|
||||
1d1702789710ec1c20613d2490b14f70756e67ec 1.1-rc1
|
||||
901f0cb5de36ea907b26d64ac9ce54605ec531d2 1.1-rc2
|
||||
ede5c664978bb40e476e8d4a5789562928f28507 1.1-rc3
|
||||
ef99144291f06822d026e981d5d856cbec14d867 1.1-rc4
|
||||
|
||||
@@ -59,7 +59,7 @@ void *simple_loop(void *arg1) {
|
||||
sigdelset(&smask, SIGSEGV);
|
||||
#endif
|
||||
pthread_sigmask(SIG_BLOCK, &smask, NULL);
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->init_thread) {
|
||||
uwsgi.p[i]->init_thread(core_id);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ void *zeromq_loop(void *arg1) {
|
||||
sigdelset(&smask, SIGSEGV);
|
||||
#endif
|
||||
pthread_sigmask(SIG_BLOCK, &smask, NULL);
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->init_thread) {
|
||||
uwsgi.p[i]->init_thread(core_id);
|
||||
}
|
||||
|
||||
@@ -230,6 +230,29 @@ void get_linux_tcp_info(int fd) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <linux/sockios.h>
|
||||
|
||||
#ifdef UNBIT
|
||||
#define SIOBKLGQ 0x8908
|
||||
#endif
|
||||
|
||||
#ifdef SIOBKLGQ
|
||||
|
||||
void get_linux_unbit_SIOBKLGQ(int fd) {
|
||||
|
||||
int queue = 0;
|
||||
if (ioctl(fd, SIOBKLGQ, &queue) >= 0) {
|
||||
uwsgi.shared->load = queue;
|
||||
uwsgi.shared->options[UWSGI_OPTION_BACKLOG_STATUS] = queue;
|
||||
if (queue >= uwsgi.listen_queue) {
|
||||
uwsgi_log_verbose("*** uWSGI listen queue of socket %d full !!! (%d/%d) ***\n", fd, queue, uwsgi.listen_queue);
|
||||
uwsgi.shared->options[UWSGI_OPTION_BACKLOG_ERRORS]++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -579,7 +602,7 @@ int master_loop(char **argv, char **environ) {
|
||||
uwsgi.gp[i]->master_cycle();
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->master_cycle) {
|
||||
uwsgi.p[i]->master_cycle();
|
||||
}
|
||||
@@ -918,7 +941,7 @@ int master_loop(char **argv, char **environ) {
|
||||
|
||||
// loop the various udp manager until one returns true
|
||||
udp_managed = 0;
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->manage_udp) {
|
||||
if (uwsgi.p[i]->manage_udp(udp_client_addr, udp_client.sin_port, uwsgi.wsgi_req->buffer, rlen)) {
|
||||
udp_managed = 1;
|
||||
@@ -1191,6 +1214,11 @@ int master_loop(char **argv, char **environ) {
|
||||
if (uwsgi_sock->family == AF_INET) {
|
||||
get_linux_tcp_info(uwsgi_sock->fd);
|
||||
}
|
||||
#ifdef SIOBKLGQ
|
||||
else if (uwsgi_sock->family == AF_UNIX) {
|
||||
get_linux_unbit_SIOBKLGQ(uwsgi_sock->fd);
|
||||
}
|
||||
#endif
|
||||
uwsgi_sock = uwsgi_sock->next;
|
||||
}
|
||||
#endif
|
||||
|
||||
+4
-3
@@ -178,7 +178,7 @@ int uwsgi_cheaper_algo_backlog(void) {
|
||||
|
||||
int i;
|
||||
#ifdef __linux__
|
||||
int backlog = uwsgi.shared->ti.tcpi_unacked;
|
||||
int backlog = uwsgi.shared->options[UWSGI_OPTION_BACKLOG_STATUS];
|
||||
#else
|
||||
int backlog = 0;
|
||||
#endif
|
||||
@@ -478,7 +478,7 @@ int uwsgi_respawn_worker(int wid) {
|
||||
|
||||
if (uwsgi.master_process) {
|
||||
if ((uwsgi.workers[uwsgi.mywid].respawn_count || uwsgi.cheap)) {
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->master_fixup) {
|
||||
uwsgi.p[i]->master_fixup(1);
|
||||
}
|
||||
@@ -671,7 +671,8 @@ void uwsgi_send_stats(int fd) {
|
||||
stats_send("{ \"version\": \"%s\",\n", UWSGI_VERSION);
|
||||
|
||||
#ifdef __linux__
|
||||
stats_send_llu("\"listen_queue\": %llu,\n", uwsgi.shared->ti.tcpi_unacked);
|
||||
stats_send_llu("\"listen_queue\": %llu,\n", (unsigned long long) uwsgi.shared->options[UWSGI_OPTION_BACKLOG_STATUS]);
|
||||
stats_send_llu("\"listen_queue_errors\": %llu,\n", (unsigned long long) uwsgi.shared->options[UWSGI_OPTION_BACKLOG_ERRORS]);
|
||||
#endif
|
||||
|
||||
stats_send_llu("\"load\": %llu,\n", uwsgi.shared->load);
|
||||
|
||||
@@ -48,13 +48,13 @@ void uwsgi_mule(int id) {
|
||||
|
||||
uwsgi_close_all_sockets();
|
||||
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->master_fixup) {
|
||||
uwsgi.p[i]->master_fixup(1);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->post_fork) {
|
||||
uwsgi.p[i]->post_fork();
|
||||
}
|
||||
@@ -62,7 +62,7 @@ void uwsgi_mule(int id) {
|
||||
|
||||
|
||||
if (uwsgi.mules[id-1].patch) {
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->mule) {
|
||||
if (uwsgi.p[i]->mule(uwsgi.mules[id-1].patch) == 1) {
|
||||
// never here
|
||||
@@ -184,7 +184,7 @@ void uwsgi_mule_handler() {
|
||||
}
|
||||
else {
|
||||
int i,found = 0;
|
||||
for(i=0;i<0xff;i++) {
|
||||
for(i=0;i<256;i++) {
|
||||
if (uwsgi.p[i]->mule_msg) {
|
||||
if (uwsgi.p[i]->mule_msg(message, len)) {
|
||||
found = 1;
|
||||
|
||||
@@ -5,7 +5,7 @@ extern struct uwsgi_server uwsgi;
|
||||
static int plugin_already_loaded(const char *plugin) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->name) {
|
||||
if (!strcmp(plugin, uwsgi.p[i]->name)) {
|
||||
#ifdef UWSGI_DEBUG
|
||||
|
||||
@@ -17,7 +17,7 @@ int cheaper_backlog2_algo(void) {
|
||||
|
||||
int i;
|
||||
#ifdef __linux__
|
||||
int backlog = uwsgi.shared->ti.tcpi_unacked;
|
||||
int backlog = uwsgi.shared->options[UWSGI_OPTION_BACKLOG_STATUS];
|
||||
#else
|
||||
int backlog = 0;
|
||||
#endif
|
||||
|
||||
@@ -538,7 +538,7 @@ void fastrouter_loop(int id) {
|
||||
else {
|
||||
delta = min_timeout->key - time(NULL);
|
||||
if (delta <= 0) {
|
||||
expire_timeouts(ufr.timeouts, ufr.fr_table);
|
||||
expire_timeouts();
|
||||
delta = 0;
|
||||
}
|
||||
}
|
||||
@@ -554,7 +554,7 @@ void fastrouter_loop(int id) {
|
||||
}
|
||||
|
||||
if (nevents == 0) {
|
||||
expire_timeouts(ufr.timeouts, ufr.fr_table);
|
||||
expire_timeouts();
|
||||
}
|
||||
|
||||
for (i = 0; i < nevents; i++) {
|
||||
|
||||
@@ -171,7 +171,7 @@ char *uwsgi_encode_pydict(PyObject * pydict, uint16_t * size) {
|
||||
PyObject *py_uwsgi_listen_queue(PyObject * self, PyObject * args) {
|
||||
|
||||
#ifdef __linux__
|
||||
return PyInt_FromLong(uwsgi.shared->ti.tcpi_unacked);
|
||||
return PyInt_FromLong(uwsgi.shared->options[UWSGI_OPTION_BACKLOG_STATUS]);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
@@ -233,6 +233,20 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) {
|
||||
uwsgi_apps[wsgi_req->app_id].exceptions++;
|
||||
PyErr_Print();
|
||||
}
|
||||
if (PyObject_HasAttrString((PyObject *)wsgi_req->async_result, "close")) {
|
||||
PyObject *close_method = PyObject_GetAttrString((PyObject *)wsgi_req->async_result, "close");
|
||||
PyObject *close_method_args = PyTuple_New(0);
|
||||
#ifdef UWSGI_DEBUG
|
||||
uwsgi_log("calling close() for %.*s %p %p\n", wsgi_req->uri_len, wsgi_req->uri, close_method, close_method_args);
|
||||
#endif
|
||||
PyObject *close_method_output = PyEval_CallObject(close_method, close_method_args);
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
}
|
||||
Py_DECREF(close_method_args);
|
||||
Py_XDECREF(close_method_output);
|
||||
Py_DECREF(close_method);
|
||||
}
|
||||
goto clear;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,15 @@ int uwsgi_request_signal(struct wsgi_request *wsgi_req) {
|
||||
|
||||
ssize_t len;
|
||||
uint8_t ret_status = 1;
|
||||
struct uwsgi_header uh;
|
||||
if (uwsgi_signal_send(uwsgi.signal_socket, wsgi_req->uh.modifier2) < 0) {
|
||||
ret_status = 0;
|
||||
}
|
||||
|
||||
wsgi_req->uh.modifier1 = 255;
|
||||
wsgi_req->uh.pktsize = 0;
|
||||
wsgi_req->uh.modifier2 = ret_status;
|
||||
len = write(wsgi_req->poll.fd, wsgi_req, 4);
|
||||
uh.modifier1 = 255;
|
||||
uh.pktsize = 0;
|
||||
uh.modifier2 = ret_status;
|
||||
len = write(wsgi_req->poll.fd, &uh, 4);
|
||||
if (len != 4) {
|
||||
uwsgi_error("write()");
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ int uwsgi_request_spooler(struct wsgi_request *wsgi_req) {
|
||||
|
||||
int i;
|
||||
char spool_filename[1024];
|
||||
struct uwsgi_header uh;
|
||||
|
||||
// get the spooler from the modifier2
|
||||
|
||||
@@ -24,11 +25,11 @@ int uwsgi_request_spooler(struct wsgi_request *wsgi_req) {
|
||||
}
|
||||
|
||||
i = spool_request(uspool, spool_filename, uwsgi.workers[0].requests + 1, wsgi_req->async_id, wsgi_req->buffer, wsgi_req->uh.pktsize, NULL, 0, NULL, 0);
|
||||
wsgi_req->uh.modifier1 = 255;
|
||||
wsgi_req->uh.pktsize = 0;
|
||||
uh.modifier1 = 255;
|
||||
uh.pktsize = 0;
|
||||
if (i > 0) {
|
||||
wsgi_req->uh.modifier2 = 1;
|
||||
if (write(wsgi_req->poll.fd, wsgi_req, 4) != 4) {
|
||||
uh.modifier2 = 1;
|
||||
if (write(wsgi_req->poll.fd, &uh, 4) != 4) {
|
||||
uwsgi_log("disconnected client, remove spool file.\n");
|
||||
/* client disconnect, remove spool file */
|
||||
if (unlink(spool_filename)) {
|
||||
@@ -41,8 +42,8 @@ int uwsgi_request_spooler(struct wsgi_request *wsgi_req) {
|
||||
}
|
||||
else {
|
||||
/* announce a failed spool request */
|
||||
wsgi_req->uh.modifier2 = 0;
|
||||
i = write(wsgi_req->poll.fd, wsgi_req, 4);
|
||||
uh.modifier2 = 0;
|
||||
i = write(wsgi_req->poll.fd, &uh, 4);
|
||||
if (i != 4) {
|
||||
uwsgi_error("write()");
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ pid_t spooler_start(struct uwsgi_spooler *uspool) {
|
||||
uwsgi_fixup_fds(0, 0, NULL);
|
||||
uwsgi_close_all_sockets();
|
||||
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->post_fork) {
|
||||
uwsgi.p[i]->post_fork();
|
||||
}
|
||||
@@ -109,7 +109,7 @@ pid_t spooler_start(struct uwsgi_spooler *uspool) {
|
||||
|
||||
uwsgi.signal_socket = uwsgi.shared->spooler_signal_pipe[1];
|
||||
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->spooler_init) {
|
||||
uwsgi.p[i]->spooler_init();
|
||||
}
|
||||
@@ -508,7 +508,7 @@ void spooler_manage_task(struct uwsgi_spooler *uspool, char *dir, char *task) {
|
||||
}
|
||||
|
||||
int callable_found = 0;
|
||||
for(i=0;i<0xff;i++) {
|
||||
for(i=0;i<256;i++) {
|
||||
if (uwsgi.p[i]->spooler) {
|
||||
time_t now = time(NULL);
|
||||
if(uwsgi.shared->options[UWSGI_OPTION_SPOOLER_HARAKIRI] > 0) {
|
||||
|
||||
@@ -4148,3 +4148,16 @@ void uwsgi_emulate_cow_for_apps(int id) {
|
||||
time_t uwsgi_now() {
|
||||
return time(NULL);
|
||||
}
|
||||
|
||||
void uwsgi_write_pidfile(char *pidfile_name) {
|
||||
uwsgi_log("writing pidfile to %s\n", pidfile_name);
|
||||
FILE *pidfile = fopen(pidfile_name, "w");
|
||||
if (!pidfile) {
|
||||
uwsgi_error_open(pidfile_name);
|
||||
exit(1);
|
||||
}
|
||||
if (fprintf(pidfile, "%d\n", (int) getpid()) < 0) {
|
||||
uwsgi_log("could not write pidfile.\n");
|
||||
}
|
||||
fclose(pidfile);
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
{"lazy", no_argument, 0, "set lazy mode (load apps in workers instead of master)", uwsgi_opt_true, &uwsgi.lazy, 0},
|
||||
{"cheap", no_argument, 0, "set cheap mode (spawn workers only after the first request)", uwsgi_opt_true, &uwsgi.cheap, 0},
|
||||
{"cheaper", required_argument, 0, "set cheaper mode (adaptive process spawning)", uwsgi_opt_set_int, &uwsgi.cheaper_count, UWSGI_OPT_MASTER|UWSGI_OPT_CHEAPER},
|
||||
{"cheaper-algo", required_argument, 0, "choose to algorithm used for adaptive process spawning)", uwsgi_opt_set_str, &uwsgi.requested_cheaper_algo, UWSGI_OPT_MASTER|UWSGI_OPT_CHEAPER},
|
||||
{"cheaper-algo", required_argument, 0, "choose to algorithm used for adaptive process spawning)", uwsgi_opt_set_str, &uwsgi.requested_cheaper_algo, UWSGI_OPT_MASTER},
|
||||
{"cheaper-step", required_argument, 0, "number of additional processes to spawn at each overload", uwsgi_opt_set_int, &uwsgi.cheaper_step, UWSGI_OPT_MASTER|UWSGI_OPT_CHEAPER},
|
||||
{"cheaper-overload", required_argument, 0, "increase workers after specified overload", uwsgi_opt_set_64bit, &uwsgi.cheaper_overload, UWSGI_OPT_MASTER|UWSGI_OPT_CHEAPER},
|
||||
{"idle", required_argument, 0, "set idle mode (put uWSGI in cheap mode after inactivity)", uwsgi_opt_set_int, &uwsgi.idle, 0},
|
||||
@@ -363,7 +363,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
{"check-cache", no_argument, 0, "check for response data in the cache", uwsgi_opt_true, &uwsgi.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},
|
||||
{"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, UWSGI_OPT_IMMEDIATE},
|
||||
{"env", required_argument, 0, "set environment variable", uwsgi_opt_set_env, NULL, 0},
|
||||
{"vacuum", no_argument, 0, "try to remove all of the generated file/sockets", uwsgi_opt_true, &uwsgi.vacuum,0},
|
||||
#ifdef __linux__
|
||||
{"cgroup", required_argument, 0, "put the processes in the specified cgroup", uwsgi_opt_add_string_list, &uwsgi.cgroup,0},
|
||||
@@ -1083,7 +1083,7 @@ void uwsgi_plugins_atexit(void) {
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j<0xFF; j++) {
|
||||
for (j = 0; j<256; j++) {
|
||||
if (uwsgi.p[j]->atexit) {
|
||||
uwsgi.p[j]->atexit();
|
||||
}
|
||||
@@ -1191,8 +1191,6 @@ int main(int argc, char *argv[], char *envp[]) {
|
||||
int i;
|
||||
int rlen;
|
||||
|
||||
FILE *pidfile;
|
||||
|
||||
char *env_reloads;
|
||||
char env_reload_buf[11];
|
||||
|
||||
@@ -1257,7 +1255,7 @@ int main(int argc, char *argv[], char *envp[]) {
|
||||
uwsgi.shared->spooler_frequency = 30;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
uwsgi.p[i] = &unconfigured_plugin;
|
||||
}
|
||||
|
||||
@@ -1494,7 +1492,7 @@ int main(int argc, char *argv[], char *envp[]) {
|
||||
}
|
||||
}
|
||||
if (!magic) {
|
||||
for (j = 0; j < 0xFF; j++) {
|
||||
for (j = 0; j < 256; j++) {
|
||||
if (uwsgi.p[j]->magic) {
|
||||
if (uwsgi.p[j]->magic(NULL, lazy)) {
|
||||
magic = 1;
|
||||
@@ -1621,16 +1619,7 @@ int main(int argc, char *argv[], char *envp[]) {
|
||||
}
|
||||
|
||||
if (uwsgi.pidfile && !uwsgi.is_a_reload) {
|
||||
uwsgi_log("writing pidfile to %s\n", uwsgi.pidfile);
|
||||
pidfile = fopen(uwsgi.pidfile, "w");
|
||||
if (!pidfile) {
|
||||
uwsgi_error_open(uwsgi.pidfile);
|
||||
exit(1);
|
||||
}
|
||||
if (fprintf(pidfile, "%d\n", (int) getpid()) < 0) {
|
||||
uwsgi_log("could not write pidfile.\n");
|
||||
}
|
||||
fclose(pidfile);
|
||||
uwsgi_write_pidfile(uwsgi.pidfile);
|
||||
}
|
||||
|
||||
uwsgi_log_initial("detected binary path: %s\n", uwsgi.binary_path);
|
||||
@@ -1783,16 +1772,7 @@ int uwsgi_start(void *v_argv) {
|
||||
}
|
||||
|
||||
if (uwsgi.pidfile2 && !uwsgi.is_a_reload) {
|
||||
uwsgi_log("writing pidfile2 to %s\n", uwsgi.pidfile2);
|
||||
FILE *pidfile2 = fopen(uwsgi.pidfile2, "w");
|
||||
if (!pidfile2) {
|
||||
uwsgi_error_open(uwsgi.pidfile2);
|
||||
exit(1);
|
||||
}
|
||||
if (fprintf(pidfile2, "%d\n", (int) getpid()) < 0) {
|
||||
uwsgi_log("could not write pidfile2.\n");
|
||||
}
|
||||
fclose(pidfile2);
|
||||
uwsgi_write_pidfile(uwsgi.pidfile2);
|
||||
}
|
||||
|
||||
if (!uwsgi.master_process && !uwsgi.command_mode) {
|
||||
@@ -2220,10 +2200,12 @@ int uwsgi_start(void *v_argv) {
|
||||
if (!getsockname(0, gsa.sa, &socket_type_len)) {
|
||||
if (gsa.sa->sa_family == AF_UNIX) {
|
||||
uwsgi_sock = uwsgi_new_socket(usa.sa_un.sun_path);
|
||||
uwsgi_sock->family = AF_UNIX;
|
||||
uwsgi_log("uwsgi socket %d inherited UNIX address %s fd 0\n", uwsgi_get_socket_num(uwsgi_sock), uwsgi_sock->name);
|
||||
}
|
||||
else {
|
||||
uwsgi_sock = uwsgi_new_socket(uwsgi_concat2("::",""));
|
||||
uwsgi_sock->family = AF_INET;
|
||||
uwsgi_log("uwsgi socket %d inherited INET address %s fd 0\n", uwsgi_get_socket_num(uwsgi_sock), uwsgi_sock->name);
|
||||
}
|
||||
}
|
||||
@@ -2357,7 +2339,7 @@ skipzero:
|
||||
|
||||
// initialize request plugin only if workers or master are available
|
||||
if (uwsgi.sockets || uwsgi.master_process || uwsgi.no_server || uwsgi.command_mode) {
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->init) {
|
||||
uwsgi.p[i]->init();
|
||||
}
|
||||
@@ -2373,7 +2355,7 @@ skipzero:
|
||||
|
||||
// again check for workers/sockets...
|
||||
if (uwsgi.sockets || uwsgi.master_process || uwsgi.no_server || uwsgi.command_mode) {
|
||||
for (i = 0; i < 0xff; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->post_init) {
|
||||
uwsgi.p[i]->post_init();
|
||||
}
|
||||
@@ -2401,7 +2383,7 @@ skipzero:
|
||||
|
||||
// again check for workers/sockets...
|
||||
if (uwsgi.sockets || uwsgi.master_process || uwsgi.no_server || uwsgi.command_mode) {
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->enable_threads)
|
||||
uwsgi.p[i]->enable_threads();
|
||||
}
|
||||
@@ -2606,7 +2588,7 @@ skipzero:
|
||||
}
|
||||
|
||||
// preinit apps (create the language environment)
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->preinit_apps) {
|
||||
uwsgi.p[i]->preinit_apps();
|
||||
}
|
||||
@@ -2640,6 +2622,14 @@ skipzero:
|
||||
masterpid = uwsgi.mypid;
|
||||
|
||||
uwsgi.workers[0].pid = masterpid;
|
||||
|
||||
if (uwsgi.pidfile && !uwsgi.is_a_reload) {
|
||||
uwsgi_write_pidfile(uwsgi.pidfile);
|
||||
}
|
||||
|
||||
if (uwsgi.pidfile2 && !uwsgi.is_a_reload) {
|
||||
uwsgi_write_pidfile(uwsgi.pidfile2);
|
||||
}
|
||||
}
|
||||
|
||||
if (uwsgi.no_server) {
|
||||
@@ -2681,7 +2671,7 @@ skipzero:
|
||||
|
||||
// security in multiuser environment: allow only a subset of modifiers
|
||||
if (uwsgi.allowed_modifiers) {
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (!uwsgi_list_has_num(uwsgi.allowed_modifiers, i)) {
|
||||
uwsgi.p[i]->request = unconfigured_hook;
|
||||
uwsgi.p[i]->after_request = unconfigured_after_hook;
|
||||
@@ -2690,7 +2680,7 @@ skipzero:
|
||||
}
|
||||
|
||||
// master fixup
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->master_fixup) {
|
||||
uwsgi.p[i]->master_fixup(0);
|
||||
}
|
||||
@@ -2891,7 +2881,7 @@ skipzero:
|
||||
uwsgi_init_all_apps();
|
||||
}
|
||||
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->post_fork) {
|
||||
uwsgi.p[i]->post_fork();
|
||||
}
|
||||
@@ -3025,7 +3015,7 @@ skipzero:
|
||||
//initialization done
|
||||
|
||||
// run fixup handler
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->fixup) {
|
||||
uwsgi.p[i]->fixup();
|
||||
}
|
||||
@@ -3091,7 +3081,7 @@ void uwsgi_ignition() {
|
||||
uwsgi_log("[snapshot] process %d is the new worker %d\n", (int) getpid(), uwsgi.mywid);
|
||||
}
|
||||
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->hijack_worker) {
|
||||
uwsgi.p[i]->hijack_worker();
|
||||
}
|
||||
@@ -3197,7 +3187,7 @@ void build_options() {
|
||||
op++;
|
||||
}
|
||||
|
||||
for(i=0;i<0xFF;i++) {
|
||||
for(i=0;i<256;i++) {
|
||||
if (uwsgi.p[i]->options) {
|
||||
options_count += uwsgi_count_options(uwsgi.p[i]->options);
|
||||
}
|
||||
@@ -3220,7 +3210,7 @@ void build_options() {
|
||||
op++;
|
||||
}
|
||||
|
||||
for(i=0;i<0xFF;i++) {
|
||||
for(i=0;i<256;i++) {
|
||||
if (uwsgi.p[i]->options) {
|
||||
int c = uwsgi_count_options(uwsgi.p[i]->options);
|
||||
memcpy(&uwsgi.options[pos], uwsgi.p[i]->options, sizeof(struct uwsgi_option) * c);
|
||||
@@ -3353,7 +3343,7 @@ void uwsgi_init_all_apps() {
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (uwsgi.p[i]->init_apps) {
|
||||
uwsgi.p[i]->init_apps();
|
||||
}
|
||||
@@ -3371,7 +3361,7 @@ void uwsgi_init_all_apps() {
|
||||
what[0] = 0;
|
||||
what++;
|
||||
uwsgi_log("mounting %s on %s\n", what, uwsgi.mounts[i]);
|
||||
for (j = 0; j < 0xFF; j++) {
|
||||
for (j = 0; j < 256; j++) {
|
||||
if (uwsgi.p[j]->mount_app) {
|
||||
if (!uwsgi_startswith(uwsgi.mounts[i], "regexp://", 9)) {
|
||||
if (uwsgi.p[j]->mount_app(uwsgi.mounts[i]+9, what, 1) != -1)
|
||||
@@ -3730,9 +3720,11 @@ void uwsgi_opt_signal(char *opt, char *value, void *foobar) {
|
||||
void uwsgi_opt_log_date(char *opt, char *value, void *foobar) {
|
||||
|
||||
uwsgi.logdate = 1;
|
||||
if (value) {
|
||||
uwsgi.log_strftime = value;
|
||||
}
|
||||
if (value) {
|
||||
if (strcasecmp("true", value) && strcasecmp("1", value) && strcasecmp("on", value) && strcasecmp("yes", value)) {
|
||||
uwsgi.log_strftime = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void uwsgi_opt_chmod_socket(char *opt, char *value, void *foobar) {
|
||||
|
||||
@@ -1529,7 +1529,7 @@ struct uwsgi_server {
|
||||
struct uwsgi_loop loops[MAX_LOOPS];
|
||||
int loops_cnt;
|
||||
|
||||
struct uwsgi_plugin *p[0xFF];
|
||||
struct uwsgi_plugin *p[256];
|
||||
struct uwsgi_plugin *gp[MAX_GENERIC_PLUGINS];
|
||||
int gp_cnt;
|
||||
|
||||
@@ -2753,6 +2753,8 @@ void uwsgi_setup_post_buffering(void);
|
||||
|
||||
struct uwsgi_lock_item *uwsgi_lock_ipcsem_init(char *);
|
||||
|
||||
void uwsgi_write_pidfile(char *);
|
||||
|
||||
#ifdef UWSGI_AS_SHARED_LIBRARY
|
||||
int uwsgi_init(int, char **, char **);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user