diff --git a/core/master_utils.c b/core/master_utils.c index bf5cba66..b3ff2025 100644 --- a/core/master_utils.c +++ b/core/master_utils.c @@ -77,7 +77,7 @@ void uwsgi_master_cleanup_hooks(void) { int j; // could be an inherited atexit hook - if (uwsgi.mywid > 0) + if (uwsgi.mypid != uwsgi.workers[0].pid) return; uwsgi.status.is_cleaning = 1; diff --git a/core/rpc.c b/core/rpc.c index 15a129bb..897d13d7 100644 --- a/core/rpc.c +++ b/core/rpc.c @@ -22,11 +22,27 @@ int uwsgi_register_rpc(char *name, uint8_t modifier1, uint8_t args, void *func) urpc->modifier1 = modifier1; urpc->args = args; urpc->func = func; + urpc->shared = uwsgi.mywid == 0 ? 1 : 0; uwsgi.shared->rpc_count[uwsgi.mywid]++; ret = 0; - uwsgi_log("registered RPC function %s\n", name); + if (uwsgi.mywid == 0) { + uwsgi_log("registered shared/inherited RPC function \"%s\"\n", name); + } + else { + uwsgi_log("registered RPC function \"%s\" on worker %d\n", name, uwsgi.mywid); + } + } + + // implement cow + if (uwsgi.mywid == 0) { + int i; + for(i=1;i<=uwsgi.numproc;i++) { + uwsgi.shared->rpc_count[i] = uwsgi.shared->rpc_count[0]; + int pos = (i * uwsgi.rpc_max); + memcpy(&uwsgi.rpc_table[pos], uwsgi.rpc_table, sizeof(struct uwsgi_rpc) * uwsgi.rpc_max); + } } uwsgi_unlock(uwsgi.rpc_table_lock); diff --git a/plugins/carbon/carbon.c b/plugins/carbon/carbon.c index 5817bc18..c1841889 100644 --- a/plugins/carbon/carbon.c +++ b/plugins/carbon/carbon.c @@ -141,6 +141,7 @@ static int carbon_write(int fd, char *fmt,...) { static void carbon_push_stats(int retry_cycle, time_t now) { struct carbon_server_list *usl = u_carbon.servers_data; + if (!u_carbon.servers_data) return; int i; int fd; int wok; diff --git a/uwsgi.h b/uwsgi.h index 87193e9b..21511b5d 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -2244,6 +2244,7 @@ struct uwsgi_rpc { void *func; uint8_t args; uint8_t modifier1; + uint8_t shared; }; struct uwsgi_signal_entry {