better plugin loading

This commit is contained in:
roberto@natty32
2011-04-03 08:18:51 +02:00
parent a2b9c44433
commit a26579fcf5
6 changed files with 38 additions and 25 deletions
+32 -22
View File
@@ -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;
}
+1
View File
@@ -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,
+1
View File
@@ -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,
+1
View File
@@ -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,
+2 -1
View File
@@ -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,
+1 -2
View File
@@ -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 *);