diff --git a/core/legion.c b/core/legion.c index faba8c6a..87f52f22 100644 --- a/core/legion.c +++ b/core/legion.c @@ -924,3 +924,11 @@ next: } } + +int uwsgi_legion_i_am_the_lord(char *name) { + struct uwsgi_legion *legion = uwsgi_legion_get_by_name(name); + if (legion && legion->i_am_the_lord) { + return 1; + } + return 0; +} diff --git a/core/master_utils.c b/core/master_utils.c index fc16a846..1c01708f 100644 --- a/core/master_utils.c +++ b/core/master_utils.c @@ -1154,6 +1154,7 @@ struct uwsgi_stats *uwsgi_master_generate_stats() { } #endif +#ifdef UWSGI_SSL if (uwsgi.legions) { if (uwsgi_stats_comma(us)) @@ -1281,6 +1282,7 @@ struct uwsgi_stats *uwsgi_master_generate_stats() { goto end; } +#endif if (uwsgi_stats_object_close(us)) goto end; diff --git a/plugins/psgi/uwsgi_plmodule.c b/plugins/psgi/uwsgi_plmodule.c index d95ca141..8a34afdd 100644 --- a/plugins/psgi/uwsgi_plmodule.c +++ b/plugins/psgi/uwsgi_plmodule.c @@ -267,6 +267,20 @@ XS(XS_signal_wait) { XSRETURN_YES; } +#ifdef UWSGI_SSL +XS(XS_i_am_the_lord) { + + dXSARGS; + + psgi_check_args(1); + + if (uwsgi_legion_i_am_the_lord(SvPV_nolen(ST(0)))) { + XSRETURN_YES; + } + XSRETURN_NO; +} + +#endif void init_perl_embedded_module() { psgi_xs(reload); @@ -282,5 +296,8 @@ void init_perl_embedded_module() { psgi_xs(signal); psgi_xs(register_signal); psgi_xs(signal_wait); +#ifdef UWSGI_SSL + psgi_xs(i_am_the_lord); +#endif } diff --git a/plugins/python/uwsgi_pymodule.c b/plugins/python/uwsgi_pymodule.c index a85a265c..d22909c7 100644 --- a/plugins/python/uwsgi_pymodule.c +++ b/plugins/python/uwsgi_pymodule.c @@ -440,6 +440,22 @@ PyObject *py_uwsgi_signal_registered(PyObject * self, PyObject * args) { return Py_None; } +PyObject *py_uwsgi_i_am_the_lord(PyObject * self, PyObject * args) { + char *legion_name = NULL; + + if (!PyArg_ParseTuple(args, "s:i_am_the_lord", &legion_name)) { + return NULL; + } + + if (uwsgi_legion_i_am_the_lord(legion_name)) { + Py_INCREF(Py_True); + return Py_True; + } + + Py_INCREF(Py_False); + return Py_False; +} + PyObject *py_uwsgi_register_signal(PyObject * self, PyObject * args) { uint8_t uwsgi_signal; @@ -3213,6 +3229,9 @@ static PyMethodDef uwsgi_advanced_methods[] = { {"cluster", py_uwsgi_cluster, METH_VARARGS, ""}, {"cluster_best_node", py_uwsgi_cluster_best_node, METH_VARARGS, ""}, #endif +#ifdef UWSGI_SSL + {"i_am_the_lord", py_uwsgi_i_am_the_lord, METH_VARARGS, ""}, +#endif #ifdef UWSGI_ASYNC {"async_sleep", py_uwsgi_async_sleep, METH_VARARGS, ""}, {"async_connect", py_uwsgi_async_connect, METH_VARARGS, ""}, diff --git a/plugins/rack/rack_api.c b/plugins/rack/rack_api.c index a3e6b005..cf92280a 100644 --- a/plugins/rack/rack_api.c +++ b/plugins/rack/rack_api.c @@ -45,6 +45,16 @@ VALUE rack_uwsgi_i_am_the_spooler(VALUE *class) { return Qfalse; } +#ifdef UWSGI_SSL +VALUE rack_uwsgi_i_am_the_lord(VALUE *class, VALUE legion_name) { + Check_Type(legion_name, T_STRING); + if (uwsgi_legion_i_am_the_lord(RSTRING_PTR(legion_name))) { + return Qtrue; + } + return Qfalse; +} +#endif + VALUE rack_uwsgi_setprocname(VALUE *class, VALUE rbname) { @@ -918,6 +928,10 @@ void uwsgi_rack_init_api() { uwsgi_rack_api("rpc", uwsgi_ruby_do_rpc, -1); + +#ifdef UWSGI_SSL + uwsgi_rack_api("i_am_the_lord", rack_uwsgi_i_am_the_lord, 1); +#endif if (uwsgi.cache_max_items > 0) { diff --git a/uwsgi.h b/uwsgi.h index aeed0be9..1478c7bd 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -3634,6 +3634,8 @@ int check_hex(char *, int); void uwsgi_uuid(char *); int uwsgi_uuid_cmp(char *, char *); +int uwsgi_legion_i_am_the_lord(char *); + void uwsgi_check_emperor(void); #ifdef UWSGI_AS_SHARED_LIBRARY int uwsgi_init(int, char **, char **);