mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-05 21:21:53 +00:00
fixed signal handling in gateways
This commit is contained in:
@@ -59,6 +59,14 @@ void gateway_respawn(int id) {
|
||||
}
|
||||
#endif
|
||||
uwsgi.mypid = getpid();
|
||||
signal(SIGALRM, SIG_IGN);
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
signal(SIGINT, end_me);
|
||||
signal(SIGTERM, end_me);
|
||||
signal(SIGUSR1, SIG_IGN);
|
||||
signal(SIGUSR2, SIG_IGN);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
ug->loop(id);
|
||||
// never here !!! (i hope)
|
||||
exit(1);
|
||||
|
||||
@@ -343,7 +343,8 @@ void fastrouter_loop(int id) {
|
||||
ugs = ugs->next;
|
||||
}
|
||||
|
||||
event_queue_add_fd_read(ufr.queue, uwsgi.gateways[id].internal_subscription_pipe[1]);
|
||||
if (ufr.has_subscription_sockets)
|
||||
event_queue_add_fd_read(ufr.queue, uwsgi.gateways[id].internal_subscription_pipe[1]);
|
||||
|
||||
|
||||
if (!ufr.socket_timeout)
|
||||
@@ -551,7 +552,50 @@ void fastrouter_loop(int id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (interesting_fd == ufr.fr_stats_server) {
|
||||
if (interesting_fd == uwsgi.gateways[id].internal_subscription_pipe[1]) {
|
||||
len = recv(interesting_fd, bbuf, 4096, 0);
|
||||
#ifdef UWSGI_EVENT_USE_PORT
|
||||
event_queue_add_fd_read(ufr.queue, interesting_fd);
|
||||
#endif
|
||||
if (len > 0) {
|
||||
memset(&usr, 0, sizeof(struct uwsgi_subscribe_req));
|
||||
uwsgi_hooked_parse(bbuf + 4, len - 4, fastrouter_manage_subscription, &usr);
|
||||
|
||||
// subscribe request ?
|
||||
if (bbuf[3] == 0) {
|
||||
if (uwsgi_add_subscribe_node(&ufr.subscriptions, &usr, ufr.subscription_regexp) && ufr.i_am_cheap) {
|
||||
struct uwsgi_gateway_socket *ugs = uwsgi.gateway_sockets;
|
||||
while (ugs) {
|
||||
if (!strcmp(ugs->owner, "uWSGI fastrouter") && !ugs->subscription) {
|
||||
event_queue_add_fd_read(ufr.queue, ugs->fd);
|
||||
}
|
||||
ugs = ugs->next;
|
||||
}
|
||||
ufr.i_am_cheap = 0;
|
||||
uwsgi_log("[uwsgi-fastrouter] leaving cheap mode...\n");
|
||||
}
|
||||
}
|
||||
//unsubscribe
|
||||
else {
|
||||
struct uwsgi_subscribe_node *node = uwsgi_get_subscribe_node_by_name(&ufr.subscriptions, usr.key, usr.keylen, usr.address, usr.address_len, ufr.subscription_regexp);
|
||||
if (node && node->len) {
|
||||
if (node->death_mark == 0)
|
||||
uwsgi_log("[uwsgi-fastrouter] %.*s => marking %.*s as failed\n", (int) usr.keylen, usr.key, (int) usr.address_len, usr.address);
|
||||
node->failcnt++;
|
||||
node->death_mark = 1;
|
||||
// check if i can remove the node
|
||||
if (node->reference == 0) {
|
||||
uwsgi_remove_subscribe_node(&ufr.subscriptions, node);
|
||||
}
|
||||
if (ufr.subscriptions == NULL && ufr.cheap && !ufr.i_am_cheap) {
|
||||
fastrouter_go_cheap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (interesting_fd == ufr.fr_stats_server) {
|
||||
fastrouter_send_stats(ufr.fr_stats_server);
|
||||
}
|
||||
else {
|
||||
@@ -1018,6 +1062,9 @@ int fastrouter_opt(int i, char *optarg) {
|
||||
ufr.socket_num = atoi(optarg);
|
||||
}
|
||||
return 1;
|
||||
case LONG_ARGS_FASTROUTER_PROCESSES:
|
||||
ufr.processes = atoi(optarg);
|
||||
return 1;
|
||||
case LONG_ARGS_FASTROUTER_USE_CODE_STRING:
|
||||
cs = uwsgi_str(optarg);
|
||||
cs_code = strchr(cs, ':');
|
||||
|
||||
+2
-1
@@ -498,7 +498,8 @@ void http_loop(int id) {
|
||||
ugs = ugs->next;
|
||||
}
|
||||
|
||||
event_queue_add_fd_read(uhttp_queue, uwsgi.gateways[id].internal_subscription_pipe[1]);
|
||||
if (uhttp.has_subscription_sockets)
|
||||
event_queue_add_fd_read(uhttp_queue, uwsgi.gateways[id].internal_subscription_pipe[1]);
|
||||
|
||||
if (uhttp.pattern) {
|
||||
init_magic_table(magic_table);
|
||||
|
||||
Reference in New Issue
Block a user