mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-01 11:15:57 +00:00
better plugin loading
This commit is contained in:
@@ -2,25 +2,6 @@
|
||||
|
||||
extern struct uwsgi_server uwsgi;
|
||||
|
||||
void embed_plugins() {
|
||||
|
||||
#ifdef UWSGI_EMBED_PLUGIN_PSGI
|
||||
if (uwsgi.plugin_arg_psgi)
|
||||
uwsgi_load_plugin(5, "psgi_plugin.so", uwsgi.plugin_arg_psgi, 0);
|
||||
#endif
|
||||
|
||||
#ifdef UWSGI_EMBED_PLUGIN_LUA
|
||||
if (uwsgi.plugin_arg_lua)
|
||||
uwsgi_load_plugin(6, "lua_plugin.so", uwsgi.plugin_arg_lua, 0);
|
||||
#endif
|
||||
|
||||
#ifdef UWSGI_EMBED_PLUGIN_RACK
|
||||
if (uwsgi.plugin_arg_rack)
|
||||
uwsgi_load_plugin(7, "rack_plugin.so", uwsgi.plugin_arg_rack, 0);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
int uwsgi_load_plugin(int modifier, char *plugin, char *pargs, int absolute) {
|
||||
|
||||
void *plugin_handle;
|
||||
@@ -28,6 +9,38 @@ int uwsgi_load_plugin(int modifier, char *plugin, char *pargs, int absolute) {
|
||||
char *plugin_name;
|
||||
char *plugin_entry_symbol;
|
||||
struct uwsgi_plugin *up;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
if (uwsgi.p[i]->name) {
|
||||
if (!strcmp(plugin, uwsgi.p[i]->name)) {
|
||||
uwsgi_log("%s plugin already available\n", plugin);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (uwsgi.p[i]->alias) {
|
||||
if (!strcmp(plugin, uwsgi.p[i]->alias)) {
|
||||
uwsgi_log("%s plugin already available\n", plugin);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0;i<uwsgi.gp_cnt;i++) {
|
||||
|
||||
if (uwsgi.gp[i]->name) {
|
||||
if (!strcmp(plugin, uwsgi.gp[i]->name)) {
|
||||
uwsgi_log("%s plugin already available\n", plugin);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (uwsgi.gp[i]->alias) {
|
||||
if (!strcmp(plugin, uwsgi.gp[i]->alias)) {
|
||||
uwsgi_log("%s plugin already available\n", plugin);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (absolute) {
|
||||
plugin_name = malloc(strlen(plugin) + 1);
|
||||
@@ -58,7 +71,4 @@ int uwsgi_load_plugin(int modifier, char *plugin, char *pargs, int absolute) {
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -447,6 +447,7 @@ int erlang_opt(int i, char *optarg) {
|
||||
|
||||
struct uwsgi_plugin erlang_plugin = {
|
||||
|
||||
.name = "erlang",
|
||||
.options = erlang_options,
|
||||
.manage_opt = erlang_opt,
|
||||
.init = erlang_init,
|
||||
|
||||
@@ -582,6 +582,7 @@ int fastrouter_opt(int i, char *optarg) {
|
||||
|
||||
struct uwsgi_plugin fastrouter_plugin = {
|
||||
|
||||
.name = "fastrouter",
|
||||
.options = fastrouter_options,
|
||||
.manage_opt = fastrouter_opt,
|
||||
.init = fastrouter_init,
|
||||
|
||||
@@ -934,6 +934,7 @@ int http_opt(int i, char *optarg) {
|
||||
|
||||
struct uwsgi_plugin http_plugin = {
|
||||
|
||||
.name = "http",
|
||||
.options = http_options,
|
||||
.manage_opt = http_opt,
|
||||
.help = http_help,
|
||||
|
||||
@@ -85,7 +85,6 @@ int uwsgi_python_init() {
|
||||
uwsgi_log("Python version: %.*s %s\n", pyversion-Py_GetVersion(), Py_GetVersion(), Py_GetCompiler()+1);
|
||||
|
||||
if (up.home != NULL) {
|
||||
uwsgi_log("Setting PythonHome to %s...\n", up.home);
|
||||
#ifdef PYTHREE
|
||||
wchar_t *wpyhome;
|
||||
wpyhome = malloc((sizeof(wchar_t) * strlen(up.home)) + 2);
|
||||
@@ -99,6 +98,7 @@ int uwsgi_python_init() {
|
||||
#else
|
||||
Py_SetPythonHome(up.home);
|
||||
#endif
|
||||
uwsgi_log("Set PythonHome to %s\n", up.home);
|
||||
}
|
||||
|
||||
#ifdef PYTHREE
|
||||
@@ -1004,6 +1004,7 @@ void uwsgi_python_resume(struct wsgi_request *wsgi_req) {
|
||||
struct uwsgi_plugin python_plugin = {
|
||||
|
||||
.name = "python",
|
||||
.alias = "python",
|
||||
.modifier1 = 0,
|
||||
.init = uwsgi_python_init,
|
||||
.post_fork = uwsgi_python_post_fork,
|
||||
|
||||
@@ -479,6 +479,7 @@ struct uwsgi_server;
|
||||
struct uwsgi_plugin {
|
||||
|
||||
const char *name;
|
||||
const char *alias;
|
||||
uint8_t modifier1;
|
||||
void *data;
|
||||
int (*init) (void);
|
||||
@@ -1378,8 +1379,6 @@ void uwsgi_log_verbose(const char *,...);
|
||||
|
||||
|
||||
int uwsgi_load_plugin(int, char *, char *, int);
|
||||
void embed_plugins(void);
|
||||
|
||||
|
||||
int unconfigured_hook(struct wsgi_request *);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user