Compare commits

...
9 Commits
10 changed files with 70 additions and 33 deletions
+1
View File
@@ -47,3 +47,4 @@ af490b8c30f83bc5fb6f3837a760981474647755 1.0-rc10
1d1702789710ec1c20613d2490b14f70756e67ec 1.1-rc1
901f0cb5de36ea907b26d64ac9ce54605ec531d2 1.1-rc2
ede5c664978bb40e476e8d4a5789562928f28507 1.1-rc3
ef99144291f06822d026e981d5d856cbec14d867 1.1-rc4
+28
View File
@@ -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
@@ -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
+3 -2
View File
@@ -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
@@ -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);
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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++) {
+1 -1
View File
@@ -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
+13
View File
@@ -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);
}
+18 -26
View File
@@ -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},
@@ -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];
@@ -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);
}
}
@@ -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) {
@@ -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) {
+2
View File
@@ -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
+1 -1
View File
@@ -1,6 +1,6 @@
# uWSGI build system
uwsgi_version = '1.1-rc3'
uwsgi_version = '1.1'
import os
import re