modify plugin api to include worker context for action/option parsing; add per-worker callback for stop_worker
* create main_worker earlier
This commit is contained in:
parent
86e039e6d2
commit
a8efcfcc0e
|
@ -5,10 +5,10 @@
|
|||
|
||||
#include <lualib.h>
|
||||
|
||||
LI_API gboolean li_config_lua_load(lua_State *L, liServer *srv, const gchar *filename, liAction **pact, gboolean allow_setup, liValue *args);
|
||||
LI_API gboolean li_config_lua_load(lua_State *L, liServer *srv, liWorker *wrk, const gchar *filename, liAction **pact, gboolean allow_setup, liValue *args);
|
||||
|
||||
LI_API gboolean li_lua_config_publish_str_hash(liServer *srv, lua_State *L, GHashTable *ht, int (*wrapper)(liServer *srv, lua_State *L, gpointer data));
|
||||
LI_API int li_lua_config_handle_server_action(liServer *srv, lua_State *L, gpointer _sa);
|
||||
LI_API int li_lua_config_handle_server_setup(liServer *srv, lua_State *L, gpointer _ss);
|
||||
LI_API gboolean li_lua_config_publish_str_hash(liServer *srv, liWorker *wrk, lua_State *L, GHashTable *ht, int (*wrapper)(liServer *srv, liWorker *wrk, lua_State *L, gpointer data));
|
||||
LI_API int li_lua_config_handle_server_action(liServer *srv, liWorker *wrk, lua_State *L, gpointer _sa);
|
||||
LI_API int li_lua_config_handle_server_setup(liServer *srv, liWorker *wrk, lua_State *L, gpointer _ss);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
typedef void (*liPluginInitCB) (liServer *srv, liPlugin *p, gpointer userdata);
|
||||
typedef void (*liPluginFreeCB) (liServer *srv, liPlugin *p);
|
||||
typedef gboolean (*liPluginParseOptionCB) (liServer *srv, liPlugin *p, size_t ndx, liValue *val, liOptionValue *oval);
|
||||
typedef gboolean (*liPluginParseOptionPtrCB)(liServer *srv, liPlugin *p, size_t ndx, liValue *val, gpointer *oval);
|
||||
typedef gboolean (*liPluginParseOptionCB) (liServer *srv, liWorker *wrk, liPlugin *p, size_t ndx, liValue *val, liOptionValue *oval);
|
||||
typedef gboolean (*liPluginParseOptionPtrCB)(liServer *srv, liWorker *wrk, liPlugin *p, size_t ndx, liValue *val, gpointer *oval);
|
||||
typedef void (*liPluginFreeOptionPtrCB) (liServer *srv, liPlugin *p, size_t ndx, gpointer oval);
|
||||
typedef liAction*(*liPluginCreateActionCB) (liServer *srv, liPlugin *p, liValue *val, gpointer userdata);
|
||||
typedef liAction*(*liPluginCreateActionCB) (liServer *srv, liWorker *wrk, liPlugin *p, liValue *val, gpointer userdata);
|
||||
typedef gboolean (*liPluginSetupCB) (liServer *srv, liPlugin *p, liValue *val, gpointer userdata);
|
||||
typedef void (*liPluginAngelCB) (liServer *srv, liPlugin *p, gint32 id, GString *data);
|
||||
|
||||
|
@ -46,6 +46,7 @@ struct liPlugin {
|
|||
liPluginHandleVRCloseCB handle_vrclose;
|
||||
|
||||
liPluginServerStateWorker handle_prepare_worker; /**< called in the worker thread context once before running the workers */
|
||||
liPluginServerStateWorker handle_worker_stop;
|
||||
/* server state machine hooks */
|
||||
liPluginServerState handle_prepare, handle_start_listen, handle_stop_listen, handle_start_log, handle_stop_log;
|
||||
|
||||
|
@ -162,9 +163,11 @@ LI_API void li_release_optionptr(liServer *srv, liOptionPtrValue *value);
|
|||
LI_API void li_plugins_prepare_callbacks(liServer *srv);
|
||||
|
||||
/* server state machine callbacks */
|
||||
LI_API void li_plugins_prepare_worker(liWorker *srv); /* blocking callbacks */
|
||||
LI_API void li_plugins_prepare_worker(liWorker *wrk); /* blocking callbacks */
|
||||
LI_API void li_plugins_prepare(liServer *srv); /* "prepare", async */
|
||||
|
||||
LI_API void li_plugins_worker_stop(liWorker *wrk); /* blocking callbacks */
|
||||
|
||||
LI_API void li_plugins_start_listen(liServer *srv); /* "warmup" */
|
||||
LI_API void li_plugins_stop_listen(liServer *srv); /* "prepare suspend", async */
|
||||
LI_API void li_plugins_start_log(liServer *srv); /* "run" */
|
||||
|
@ -175,11 +178,11 @@ LI_API void li_plugins_handle_vrclose(liVRequest *vr);
|
|||
|
||||
/* Needed for config frontends */
|
||||
/** For parsing 'somemod.option = "somevalue"', free value after call */
|
||||
LI_API liAction* li_option_action(liServer *srv, const gchar *name, liValue *val);
|
||||
LI_API liAction* li_option_action(liServer *srv, liWorker *wrk, const gchar *name, liValue *val);
|
||||
/** For parsing 'somemod.action value', e.g. 'rewrite "/url" => "/destination"'
|
||||
* free value after call
|
||||
*/
|
||||
LI_API liAction* li_create_action(liServer *srv, const gchar *name, liValue *val);
|
||||
LI_API liAction* li_create_action(liServer *srv, liWorker *wrk, const gchar *name, liValue *val);
|
||||
/** For setup function, e.g. 'listen "127.0.0.1:8080"'; free value after call */
|
||||
LI_API gboolean li_call_setup(liServer *srv, const char *name, liValue *val);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
typedef int (*LuaWrapper)(liServer *srv, lua_State *L, gpointer data);
|
||||
typedef int (*LuaWrapper)(liServer *srv, liWorker *wrk, lua_State *L, gpointer data);
|
||||
|
||||
static liValue* lua_params_to_value(liServer *srv, lua_State *L) {
|
||||
liValue *val, *subval;
|
||||
|
@ -32,14 +32,16 @@ static liValue* lua_params_to_value(liServer *srv, lua_State *L) {
|
|||
}
|
||||
|
||||
/* Creates a table on the lua stack */
|
||||
static void lua_push_publish_hash_metatable(liServer *srv, lua_State *L);
|
||||
static void lua_push_publish_hash_metatable(liServer *srv, liWorker *wrk, lua_State *L);
|
||||
|
||||
static int lua_str_hash_index(lua_State *L) {
|
||||
liServer *srv;
|
||||
liWorker *wrk;
|
||||
GHashTable *ht;
|
||||
LuaWrapper wrapper;
|
||||
|
||||
srv = (liServer*) lua_touserdata(L, lua_upvalueindex(1));
|
||||
wrk = (liWorker*) lua_touserdata(L, lua_upvalueindex(2));
|
||||
lua_pushstring(L, "__ht"); lua_rawget(L, 1);
|
||||
ht = (GHashTable*) lua_touserdata(L, -1); lua_pop(L, 1);
|
||||
lua_pushstring(L, "__wrapper"); lua_rawget(L, 1);
|
||||
|
@ -70,19 +72,21 @@ static int lua_str_hash_index(lua_State *L) {
|
|||
}
|
||||
lua_setfield(L, -2, "__key");
|
||||
|
||||
lua_push_publish_hash_metatable(srv, L);
|
||||
lua_push_publish_hash_metatable(srv, wrk, L);
|
||||
lua_setmetatable(L, -2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lua_str_hash_call(lua_State *L) {
|
||||
liServer *srv;
|
||||
liWorker *wrk;
|
||||
GHashTable *ht;
|
||||
LuaWrapper wrapper;
|
||||
const char *key;
|
||||
gpointer d;
|
||||
|
||||
srv = (liServer*) lua_touserdata(L, lua_upvalueindex(1));
|
||||
wrk = (liWorker*) lua_touserdata(L, lua_upvalueindex(2));
|
||||
lua_pushstring(L, "__ht"); lua_rawget(L, 1);
|
||||
ht = (GHashTable*) lua_touserdata(L, -1); lua_pop(L, 1);
|
||||
lua_pushstring(L, "__wrapper"); lua_rawget(L, 1);
|
||||
|
@ -94,7 +98,7 @@ static int lua_str_hash_call(lua_State *L) {
|
|||
|
||||
if (key && NULL != (d = g_hash_table_lookup(ht, key))) {
|
||||
lua_pop(L, 1);
|
||||
return wrapper(srv, L, d);
|
||||
return wrapper(srv, wrk, L, d);
|
||||
}
|
||||
|
||||
lua_pop(L, lua_gettop(L));
|
||||
|
@ -107,32 +111,34 @@ static int lua_str_hash_call(lua_State *L) {
|
|||
}
|
||||
|
||||
#define LUA_PUBLISH_HASH "GHashTable*"
|
||||
static void lua_push_publish_hash_metatable(liServer *srv, lua_State *L) {
|
||||
static void lua_push_publish_hash_metatable(liServer *srv, liWorker *wrk, lua_State *L) {
|
||||
if (luaL_newmetatable(L, LUA_PUBLISH_HASH)) {
|
||||
lua_pushlightuserdata(L, srv);
|
||||
lua_pushcclosure(L, lua_str_hash_index, 1);
|
||||
lua_pushlightuserdata(L, wrk);
|
||||
lua_pushcclosure(L, lua_str_hash_index, 2);
|
||||
lua_setfield(L, -2, "__index");
|
||||
|
||||
lua_pushlightuserdata(L, srv);
|
||||
lua_pushcclosure(L, lua_str_hash_call, 1);
|
||||
lua_pushlightuserdata(L, wrk);
|
||||
lua_pushcclosure(L, lua_str_hash_call, 2);
|
||||
lua_setfield(L, -2, "__call");
|
||||
}
|
||||
}
|
||||
|
||||
gboolean li_lua_config_publish_str_hash(liServer *srv, lua_State *L, GHashTable *ht, LuaWrapper wrapper) {
|
||||
gboolean li_lua_config_publish_str_hash(liServer *srv, liWorker *wrk, lua_State *L, GHashTable *ht, LuaWrapper wrapper) {
|
||||
lua_newtable(L); /* { } */
|
||||
lua_pushlightuserdata(L, ht);
|
||||
lua_setfield(L, -2, "__ht");
|
||||
lua_pushlightuserdata(L, (void*)(intptr_t)wrapper);
|
||||
lua_setfield(L, -2, "__wrapper");
|
||||
|
||||
lua_push_publish_hash_metatable(srv, L);
|
||||
lua_push_publish_hash_metatable(srv, wrk, L);
|
||||
lua_setmetatable(L, -2);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
int li_lua_config_handle_server_action(liServer *srv, lua_State *L, gpointer _sa) {
|
||||
int li_lua_config_handle_server_action(liServer *srv, liWorker *wrk, lua_State *L, gpointer _sa) {
|
||||
liServerAction *sa = (liServerAction*) _sa;
|
||||
liValue *val;
|
||||
liAction *a;
|
||||
|
@ -144,7 +150,7 @@ int li_lua_config_handle_server_action(liServer *srv, lua_State *L, gpointer _sa
|
|||
if (dolock) li_lua_unlock(srv);
|
||||
|
||||
/* TRACE(srv, "%s", "Creating action"); */
|
||||
a = sa->create_action(srv, sa->p, val, sa->userdata);
|
||||
a = sa->create_action(srv, wrk, sa->p, val, sa->userdata);
|
||||
li_value_free(val);
|
||||
|
||||
if (dolock) li_lua_lock(srv);
|
||||
|
@ -157,11 +163,12 @@ int li_lua_config_handle_server_action(liServer *srv, lua_State *L, gpointer _sa
|
|||
return li_lua_push_action(srv, L, a);
|
||||
}
|
||||
|
||||
int li_lua_config_handle_server_setup(liServer *srv, lua_State *L, gpointer _ss) {
|
||||
int li_lua_config_handle_server_setup(liServer *srv, liWorker *wrk, lua_State *L, gpointer _ss) {
|
||||
liServerSetup *ss = (liServerSetup*) _ss;
|
||||
liValue *val;
|
||||
gboolean res;
|
||||
gboolean dolock = (L == srv->L);
|
||||
UNUSED(wrk);
|
||||
|
||||
lua_checkstack(L, 16);
|
||||
val = lua_params_to_value(srv, L);
|
||||
|
@ -181,7 +188,7 @@ int li_lua_config_handle_server_setup(liServer *srv, lua_State *L, gpointer _ss)
|
|||
return 0;
|
||||
}
|
||||
|
||||
gboolean li_config_lua_load(lua_State *L, liServer *srv, const gchar *filename, liAction **pact, gboolean allow_setup, liValue *args) {
|
||||
gboolean li_config_lua_load(lua_State *L, liServer *srv, liWorker *wrk, const gchar *filename, liAction **pact, gboolean allow_setup, liValue *args) {
|
||||
int errfunc;
|
||||
int lua_stack_top;
|
||||
gboolean dolock = (L == srv->L);
|
||||
|
@ -202,11 +209,11 @@ gboolean li_config_lua_load(lua_State *L, liServer *srv, const gchar *filename,
|
|||
DEBUG(srv, "Loaded config script '%s'", filename);
|
||||
|
||||
if (allow_setup) {
|
||||
li_lua_config_publish_str_hash(srv, L, srv->setups, li_lua_config_handle_server_setup);
|
||||
li_lua_config_publish_str_hash(srv, wrk, L, srv->setups, li_lua_config_handle_server_setup);
|
||||
lua_setfield(L, LUA_GLOBALSINDEX, "setup");
|
||||
}
|
||||
|
||||
li_lua_config_publish_str_hash(srv, L, srv->actions, li_lua_config_handle_server_action);
|
||||
li_lua_config_publish_str_hash(srv, wrk, L, srv->actions, li_lua_config_handle_server_action);
|
||||
lua_setfield(L, LUA_GLOBALSINDEX, "action");
|
||||
|
||||
li_lua_push_lvalues_dict(srv, L);
|
||||
|
|
|
@ -565,7 +565,7 @@
|
|||
}
|
||||
else {
|
||||
/* normal assignment */
|
||||
a = li_option_action(srv, name->data.string->str, val);
|
||||
a = li_option_action(srv, srv->main_worker, name->data.string->str, val);
|
||||
li_value_free(val);
|
||||
|
||||
if (a == NULL) {
|
||||
|
@ -607,7 +607,7 @@
|
|||
a = g_hash_table_lookup(ctx->action_blocks, name->data.string);
|
||||
|
||||
if (a == NULL) {
|
||||
a = li_create_action(srv, name->data.string->str, NULL);
|
||||
a = li_create_action(srv, srv->main_worker, name->data.string->str, NULL);
|
||||
} else {
|
||||
li_action_acquire(a);
|
||||
}
|
||||
|
@ -750,7 +750,7 @@
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!li_config_lua_load(srv->L, srv, val->data.string->str, &a, TRUE, NULL)) {
|
||||
if (!li_config_lua_load(srv->L, srv, srv->main_worker, val->data.string->str, &a, TRUE, NULL)) {
|
||||
ERROR(srv, "include_lua '%s' failed", val->data.string->str);
|
||||
li_value_free(name);
|
||||
li_value_free(val);
|
||||
|
@ -791,7 +791,7 @@
|
|||
}
|
||||
else {
|
||||
al = g_queue_peek_head(ctx->action_list_stack);
|
||||
a = li_create_action(srv, name->data.string->str, val);
|
||||
a = li_create_action(srv, srv->main_worker, name->data.string->str, val);
|
||||
li_value_free(val);
|
||||
|
||||
if (a == NULL) {
|
||||
|
@ -1355,7 +1355,7 @@ gboolean li_config_parse(liServer *srv, const gchar *config_path) {
|
|||
}
|
||||
|
||||
/* append fallback "static" action */
|
||||
a = li_create_action(srv, "static", NULL);
|
||||
a = li_create_action(srv, srv->main_worker, "static", NULL);
|
||||
g_array_append_val(srv->mainaction->data.list, a);
|
||||
|
||||
g_get_current_time(&end);
|
||||
|
|
|
@ -109,7 +109,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
else {
|
||||
#ifdef HAVE_LUA_H
|
||||
li_config_lua_load(srv->L, srv, config_path, &srv->mainaction, TRUE, NULL);
|
||||
li_config_lua_load(srv->L, srv, srv->main_worker, config_path, &srv->mainaction, TRUE, NULL);
|
||||
/* lua config frontend */
|
||||
#else
|
||||
g_print("lua config frontend not available\n");
|
||||
|
|
|
@ -261,8 +261,8 @@ static liServerOption* find_option(liServer *srv, const char *name) {
|
|||
return (liServerOption*) g_hash_table_lookup(srv->options, name);
|
||||
}
|
||||
|
||||
static gboolean li_parse_option(liServer *srv, liServerOption *sopt, const char *name, liValue *val, liOptionSet *mark) {
|
||||
if (!srv || !name || !mark || !sopt) return FALSE;
|
||||
static gboolean li_parse_option(liServer *srv, liWorker *wrk, liServerOption *sopt, const char *name, liValue *val, liOptionSet *mark) {
|
||||
if (!srv || !wrk || !name || !mark || !sopt) return FALSE;
|
||||
|
||||
if (sopt->type != val->type && sopt->type != LI_VALUE_NONE) {
|
||||
ERROR(srv, "Unexpected value type '%s', expected '%s' for option %s",
|
||||
|
@ -284,7 +284,7 @@ static gboolean li_parse_option(liServer *srv, liServerOption *sopt, const char
|
|||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
if (!sopt->parse_option(srv, sopt->p, sopt->module_index, val, &mark->value)) {
|
||||
if (!sopt->parse_option(srv, wrk, sopt->p, sopt->module_index, val, &mark->value)) {
|
||||
/* errors should be logged by parse function */
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -299,11 +299,11 @@ static liServerOptionPtr* find_optionptr(liServer *srv, const char *name) {
|
|||
return (liServerOptionPtr*) g_hash_table_lookup(srv->optionptrs, name);
|
||||
}
|
||||
|
||||
static gboolean li_parse_optionptr(liServer *srv, liServerOptionPtr *sopt, const char *name, liValue *val, liOptionPtrSet *mark) {
|
||||
static gboolean li_parse_optionptr(liServer *srv, liWorker *wrk, liServerOptionPtr *sopt, const char *name, liValue *val, liOptionPtrSet *mark) {
|
||||
liOptionPtrValue *oval;
|
||||
gpointer ptr = NULL;
|
||||
|
||||
if (!srv || !name || !mark || !sopt) return FALSE;
|
||||
if (!srv || !wrk || !name || !mark || !sopt) return FALSE;
|
||||
|
||||
if (sopt->type != val->type && sopt->type != LI_VALUE_NONE) {
|
||||
ERROR(srv, "Unexpected value type '%s', expected '%s' for option %s",
|
||||
|
@ -314,7 +314,7 @@ static gboolean li_parse_optionptr(liServer *srv, liServerOptionPtr *sopt, const
|
|||
if (!sopt->parse_option) {
|
||||
ptr = li_value_extract_ptr(val);
|
||||
} else {
|
||||
if (!sopt->parse_option(srv, sopt->p, sopt->module_index, val, &ptr)) {
|
||||
if (!sopt->parse_option(srv, wrk, sopt->p, sopt->module_index, val, &ptr)) {
|
||||
/* errors should be logged by parse function */
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -379,14 +379,14 @@ void li_release_optionptr(liServer *srv, liOptionPtrValue *value) {
|
|||
g_slice_free(liOptionPtrValue, value);
|
||||
}
|
||||
|
||||
liAction* li_option_action(liServer *srv, const gchar *name, liValue *val) {
|
||||
liAction* li_option_action(liServer *srv, liWorker *wrk, const gchar *name, liValue *val) {
|
||||
liServerOption *sopt;
|
||||
liServerOptionPtr *soptptr;
|
||||
|
||||
if (NULL != (sopt = find_option(srv, name))) {
|
||||
liOptionSet setting;
|
||||
|
||||
if (!li_parse_option(srv, sopt, name, val, &setting)) {
|
||||
if (!li_parse_option(srv, wrk, sopt, name, val, &setting)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ liAction* li_option_action(liServer *srv, const gchar *name, liValue *val) {
|
|||
} else if (NULL != (soptptr = find_optionptr(srv, name))) {
|
||||
liOptionPtrSet setting;
|
||||
|
||||
if (!li_parse_optionptr(srv, soptptr, name, val, &setting)) {
|
||||
if (!li_parse_optionptr(srv, wrk, soptptr, name, val, &setting)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -405,7 +405,7 @@ liAction* li_option_action(liServer *srv, const gchar *name, liValue *val) {
|
|||
}
|
||||
}
|
||||
|
||||
liAction* li_create_action(liServer *srv, const gchar *name, liValue *val) {
|
||||
liAction* li_create_action(liServer *srv, liWorker *wrk, const gchar *name, liValue *val) {
|
||||
liAction *a;
|
||||
liServerAction *sa;
|
||||
|
||||
|
@ -414,7 +414,7 @@ liAction* li_create_action(liServer *srv, const gchar *name, liValue *val) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (NULL == (a = sa->create_action(srv, sa->p, val, sa->userdata))) {
|
||||
if (NULL == (a = sa->create_action(srv, wrk, sa->p, val, sa->userdata))) {
|
||||
ERROR(srv, "Action '%s' creation failed", name);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ void li_plugins_handle_vrclose(liVRequest *vr) {
|
|||
}
|
||||
}
|
||||
|
||||
gboolean li_plugin_set_default_option(liServer *srv, const gchar* name, liValue *val) {
|
||||
gboolean li_plugin_set_default_option(liServer* srv, const gchar* name, liValue* val) {
|
||||
liServerOption *sopt;
|
||||
liServerOptionPtr *soptptr;
|
||||
|
||||
|
@ -479,7 +479,7 @@ gboolean li_plugin_set_default_option(liServer *srv, const gchar* name, liValue
|
|||
liOptionSet setting;
|
||||
|
||||
/* assign new value */
|
||||
if (!li_parse_option(srv, sopt, name, val, &setting)) {
|
||||
if (!li_parse_option(srv, srv->main_worker, sopt, name, val, &setting)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -488,7 +488,7 @@ gboolean li_plugin_set_default_option(liServer *srv, const gchar* name, liValue
|
|||
liOptionPtrSet setting;
|
||||
|
||||
/* assign new value */
|
||||
if (!li_parse_optionptr(srv, soptptr, name, val, &setting)) {
|
||||
if (!li_parse_optionptr(srv, srv->main_worker, soptptr, name, val, &setting)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -521,7 +521,7 @@ static gboolean plugin_load_default_option(liServer *srv, liServerOption *sopt)
|
|||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
if (!sopt->parse_option(srv, sopt->p, sopt->module_index, NULL, &oval)) {
|
||||
if (!sopt->parse_option(srv, srv->main_worker, sopt->p, sopt->module_index, NULL, &oval)) {
|
||||
/* errors should be logged by parse function */
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ static gboolean plugin_load_default_optionptr(liServer *srv, liServerOptionPtr *
|
|||
ptr = NULL;
|
||||
}
|
||||
} else {
|
||||
if (!sopt->parse_option(srv, sopt->p, sopt->module_index, NULL, &ptr)) {
|
||||
if (!sopt->parse_option(srv, srv->main_worker, sopt->p, sopt->module_index, NULL, &ptr)) {
|
||||
/* errors should be logged by parse function */
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -617,6 +617,21 @@ void li_plugins_prepare(liServer* srv) { /* "prepare", async */
|
|||
}
|
||||
}
|
||||
|
||||
void li_plugins_worker_stop(liWorker *wrk) { /* blocking callbacks */
|
||||
GHashTableIter iter;
|
||||
liPlugin *p;
|
||||
gpointer v;
|
||||
liServer *srv = wrk->srv;
|
||||
|
||||
g_hash_table_iter_init(&iter, srv->plugins);
|
||||
while (g_hash_table_iter_next(&iter, NULL, &v)) {
|
||||
p = (liPlugin*) v;
|
||||
if (p->handle_worker_stop) {
|
||||
p->handle_worker_stop(srv, p, wrk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void li_plugins_start_listen(liServer *srv) { /* "warmup" */
|
||||
GHashTableIter iter;
|
||||
liPlugin *p;
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
#include <sched.h>
|
||||
|
||||
static liAction* core_list(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_list(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
liAction *a;
|
||||
guint i;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val) {
|
||||
ERROR(srv, "%s", "need parameter");
|
||||
|
@ -48,10 +48,10 @@ static liAction* core_list(liServer *srv, liPlugin* p, liValue *val, gpointer us
|
|||
return a;
|
||||
}
|
||||
|
||||
static liAction* core_when(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_when(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
liValue *val_cond, *val_act, *val_act_else;
|
||||
liAction *a, *act = NULL, *act_else = NULL;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val) {
|
||||
ERROR(srv, "%s", "need parameter");
|
||||
|
@ -102,7 +102,7 @@ static liAction* core_when(liServer *srv, liPlugin* p, liValue *val, gpointer us
|
|||
return a;
|
||||
}
|
||||
|
||||
static liAction* core_set(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_set(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
liValue *val_val, *val_name;
|
||||
liAction *a;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
@ -125,7 +125,7 @@ static liAction* core_set(liServer *srv, liPlugin* p, liValue *val, gpointer use
|
|||
ERROR(srv, "expected string as first parameter, got %s", li_value_type_string(val_name->type));
|
||||
return NULL;
|
||||
}
|
||||
a = li_option_action(srv, val_name->data.string->str, val_val);
|
||||
a = li_option_action(srv, wrk, val_name->data.string->str, val_val);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
@ -183,8 +183,8 @@ static void core_docroot_free(liServer *srv, gpointer param) {
|
|||
g_string_free(param, TRUE);
|
||||
}
|
||||
|
||||
static liAction* core_docroot(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
static liAction* core_docroot(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
if (!val || val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "%s", "docroot action expects a string parameter");
|
||||
return NULL;
|
||||
|
@ -253,11 +253,11 @@ static void core_alias_free(liServer *srv, gpointer _param) {
|
|||
g_array_free(param, TRUE);
|
||||
}
|
||||
|
||||
static liAction* core_alias(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_alias(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *a = NULL;
|
||||
GArray *vl, *vl1;
|
||||
core_alias_config ac;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "%s", "unexpected or no parameter for alias action");
|
||||
|
@ -393,11 +393,11 @@ static void core_index_free(liServer *srv, gpointer param) {
|
|||
g_array_free(files, TRUE);
|
||||
}
|
||||
|
||||
static liAction* core_index(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_index(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *files;
|
||||
guint i;
|
||||
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "%s", "index action expects a list of strings as parameter");
|
||||
|
@ -613,8 +613,8 @@ static liHandlerResult core_handle_static(liVRequest *vr, gpointer param, gpoint
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_static(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
static liAction* core_static(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "static action doesn't have parameters");
|
||||
return NULL;
|
||||
|
@ -683,8 +683,8 @@ next_round:
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_pathinfo(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
static liAction* core_pathinfo(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "pathinfo action doesn't have parameters");
|
||||
return NULL;
|
||||
|
@ -702,10 +702,10 @@ static liHandlerResult core_handle_status(liVRequest *vr, gpointer param, gpoint
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_status(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_status(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
gpointer ptr;
|
||||
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_NUMBER) {
|
||||
ERROR(srv, "%s", "set_status action expects a number as parameter");
|
||||
|
@ -733,8 +733,8 @@ static liHandlerResult core_handle_log_write(liVRequest *vr, gpointer param, gpo
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_log_write(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
static liAction* core_log_write(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
if (!val || val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "%s", "log.write expects a string parameter");
|
||||
return NULL;
|
||||
|
@ -755,8 +755,8 @@ static liHandlerResult core_handle_blank(liVRequest *vr, gpointer param, gpointe
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_blank(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
static liAction* core_blank(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "'blank' action doesn't have parameters");
|
||||
|
@ -777,8 +777,8 @@ static liHandlerResult core_handle_profile_mem(liVRequest *vr, gpointer param, g
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_profile_mem(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
static liAction* core_profile_mem(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "'profile_mem' action doesn't have parameters");
|
||||
|
@ -905,13 +905,14 @@ static gboolean core_stat_cache_ttl(liServer *srv, liPlugin* p, liValue *val, gp
|
|||
* OPTIONS
|
||||
*/
|
||||
|
||||
static gboolean core_option_log_parse(liServer *srv, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
static gboolean core_option_log_parse(liServer *srv, liWorker *wrk, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
GHashTableIter iter;
|
||||
gpointer k, v;
|
||||
liLogLevel level;
|
||||
GString *path;
|
||||
GString *level_str;
|
||||
GArray *arr = g_array_sized_new(FALSE, TRUE, sizeof(liLog*), 6);
|
||||
UNUSED(wrk);
|
||||
UNUSED(p);
|
||||
UNUSED(ndx);
|
||||
|
||||
|
@ -976,7 +977,8 @@ static void core_option_log_free(liServer *srv, liPlugin *p, size_t ndx, gpointe
|
|||
g_array_free(arr, TRUE);
|
||||
}
|
||||
|
||||
static gboolean core_option_log_timestamp_parse(liServer *srv, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
static gboolean core_option_log_timestamp_parse(liServer *srv, liWorker *wrk, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
UNUSED(wrk);
|
||||
UNUSED(p);
|
||||
UNUSED(ndx);
|
||||
|
||||
|
@ -994,9 +996,10 @@ static void core_option_log_timestamp_free(liServer *srv, liPlugin *p, size_t nd
|
|||
li_log_timestamp_free(srv, oval);
|
||||
}
|
||||
|
||||
static gboolean core_option_static_exclude_exts_parse(liServer *srv, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
static gboolean core_option_static_exclude_exts_parse(liServer *srv, liWorker *wrk, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
GArray *arr;
|
||||
UNUSED(srv);
|
||||
UNUSED(wrk);
|
||||
UNUSED(p);
|
||||
UNUSED(ndx);
|
||||
|
||||
|
@ -1018,9 +1021,10 @@ static gboolean core_option_static_exclude_exts_parse(liServer *srv, liPlugin *p
|
|||
}
|
||||
|
||||
|
||||
static gboolean core_option_mime_types_parse(liServer *srv, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
static gboolean core_option_mime_types_parse(liServer *srv, liWorker *wrk, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
GArray *arr;
|
||||
UNUSED(srv);
|
||||
UNUSED(wrk);
|
||||
UNUSED(p);
|
||||
UNUSED(ndx);
|
||||
|
||||
|
@ -1072,11 +1076,12 @@ static void core_option_mime_types_free(liServer *srv, liPlugin *p, size_t ndx,
|
|||
g_array_free(list, TRUE);
|
||||
}
|
||||
|
||||
static gboolean core_option_etag_use_parse(liServer *srv, liPlugin *p, size_t ndx, liValue *val, liOptionValue *oval) {
|
||||
static gboolean core_option_etag_use_parse(liServer *srv, liWorker *wrk, liPlugin *p, size_t ndx, liValue *val, liOptionValue *oval) {
|
||||
GArray *arr;
|
||||
guint flags = 0;
|
||||
UNUSED(p);
|
||||
UNUSED(ndx);
|
||||
UNUSED(wrk);
|
||||
|
||||
/* default value */
|
||||
if (!val) {
|
||||
|
@ -1130,9 +1135,9 @@ static void core_header_free(liServer *srv, gpointer param) {
|
|||
li_value_list_free(param);
|
||||
}
|
||||
|
||||
static liAction* core_header_add(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_header_add(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *l;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "'header.add' action expects a string tuple as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1167,9 +1172,9 @@ static liHandlerResult core_handle_header_append(liVRequest *vr, gpointer param,
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_header_append(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_header_append(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *l;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "'header.append' action expects a string tuple as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1204,9 +1209,9 @@ static liHandlerResult core_handle_header_overwrite(liVRequest *vr, gpointer par
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_header_overwrite(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_header_overwrite(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *l;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "'header.overwrite' action expects a string tuple as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1243,8 +1248,8 @@ static liHandlerResult core_handle_header_remove(liVRequest *vr, gpointer param,
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_header_remove(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
static liAction* core_header_remove(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "'header.remove' action expects a string as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1264,9 +1269,9 @@ static liHandlerResult core_handle_buffer_out(liVRequest *vr, gpointer param, gp
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_buffer_out(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_buffer_out(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
gint64 limit;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_NUMBER) {
|
||||
ERROR(srv, "'io.buffer_out' action expects an integer as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1297,9 +1302,9 @@ static liHandlerResult core_handle_buffer_in(liVRequest *vr, gpointer param, gpo
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_buffer_in(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_buffer_in(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
gint64 limit;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_NUMBER) {
|
||||
ERROR(srv, "'io.buffer_in' action expects an integer as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1329,13 +1334,13 @@ static liHandlerResult core_handle_throttle_pool(liVRequest *vr, gpointer param,
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_throttle_pool(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_throttle_pool(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GString *name;
|
||||
guint i;
|
||||
liThrottlePool *pool = NULL;
|
||||
gint64 rate;
|
||||
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_STRING && val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "'io.throttle_pool' action expects a string or a string-number tuple as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1423,9 +1428,9 @@ static liHandlerResult core_handle_throttle_connection(liVRequest *vr, gpointer
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_throttle_connection(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* core_throttle_connection(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
liThrottleParam *param;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type == LI_VALUE_LIST && val->data.list->len == 2) {
|
||||
liValue *v1 = g_array_index(val->data.list, liValue*, 0);
|
||||
|
|
|
@ -297,6 +297,9 @@ gboolean li_server_loop_init(liServer *srv) {
|
|||
ev_async_start(srv->loop, &srv->state_ready_watcher);
|
||||
ev_unref(srv->loop); /* don't keep loop alive */
|
||||
|
||||
srv->main_worker = li_worker_new(srv, srv->loop);
|
||||
srv->main_worker->ndx = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -335,8 +338,7 @@ static gboolean li_server_worker_init(liServer *srv) {
|
|||
|
||||
if (srv->worker_count < 1) srv->worker_count = 1;
|
||||
g_array_set_size(srv->workers, srv->worker_count);
|
||||
srv->main_worker = g_array_index(srv->workers, liWorker*, 0) = li_worker_new(srv, loop);
|
||||
srv->main_worker->ndx = 0;
|
||||
g_array_index(srv->workers, liWorker*, 0) = srv->main_worker;
|
||||
for (i = 1; i < srv->worker_count; i++) {
|
||||
liWorker *wrk;
|
||||
if (NULL == (loop = ev_loop_new(srv->loop_flags))) {
|
||||
|
|
|
@ -545,6 +545,8 @@ void li_worker_stop(liWorker *context, liWorker *wrk) {
|
|||
if (context == wrk) {
|
||||
guint i;
|
||||
|
||||
li_plugins_worker_stop(wrk);
|
||||
|
||||
ev_async_stop(wrk->loop, &wrk->li_worker_stop_watcher);
|
||||
ev_async_stop(wrk->loop, &wrk->li_worker_suspend_watcher);
|
||||
ev_async_stop(wrk->loop, &wrk->new_con_watcher);
|
||||
|
|
|
@ -114,7 +114,7 @@ static void access_check_free(liServer *srv, gpointer param) {
|
|||
g_slice_free(access_check_data, acd);
|
||||
}
|
||||
|
||||
static liAction* access_check_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* access_check_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *arr;
|
||||
liValue *v, *ip;
|
||||
guint i, j;
|
||||
|
@ -123,6 +123,7 @@ static liAction* access_check_create(liServer *srv, liPlugin* p, liValue *val, g
|
|||
access_check_data *acd = NULL;
|
||||
|
||||
UNUSED(srv);
|
||||
UNUSED(wrk);
|
||||
UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_LIST || (val->data.list->len != 1 && val->data.list->len != 2)) {
|
||||
|
@ -227,8 +228,8 @@ static liHandlerResult access_deny(liVRequest *vr, gpointer param, gpointer *con
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* access_deny_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
static liAction* access_deny_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(wrk); UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "access.deny doesn't expect any parameters");
|
||||
|
|
|
@ -412,9 +412,10 @@ static void al_option_accesslog_free(liServer *srv, liPlugin *p, size_t ndx, gpo
|
|||
li_log_unref(srv, oval);
|
||||
}
|
||||
|
||||
static gboolean al_option_accesslog_parse(liServer *srv, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
static gboolean al_option_accesslog_parse(liServer *srv, liWorker *wrk, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
liLog *log;
|
||||
|
||||
UNUSED(wrk);
|
||||
UNUSED(p);
|
||||
UNUSED(ndx);
|
||||
|
||||
|
@ -456,9 +457,10 @@ static void al_option_accesslog_format_free(liServer *srv, liPlugin *p, size_t n
|
|||
g_array_free(arr, TRUE);
|
||||
}
|
||||
|
||||
static gboolean al_option_accesslog_format_parse(liServer *srv, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
static gboolean al_option_accesslog_format_parse(liServer *srv, liWorker *wrk, liPlugin *p, size_t ndx, liValue *val, gpointer *oval) {
|
||||
GArray *arr;
|
||||
|
||||
UNUSED(wrk);
|
||||
UNUSED(p);
|
||||
UNUSED(ndx);
|
||||
|
||||
|
|
|
@ -447,18 +447,18 @@ static liAction* auth_generic_create(liServer *srv, liPlugin* p, liValue *val, c
|
|||
}
|
||||
|
||||
|
||||
static liAction* auth_plain_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(userdata);
|
||||
static liAction* auth_plain_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(wrk); UNUSED(userdata);
|
||||
return auth_generic_create(srv, p, val, "auth.plain", auth_backend_plain, FALSE);
|
||||
}
|
||||
|
||||
static liAction* auth_htpasswd_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(userdata);
|
||||
static liAction* auth_htpasswd_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(wrk); UNUSED(userdata);
|
||||
return auth_generic_create(srv, p, val, "auth.htpasswd", auth_backend_htpasswd, FALSE);
|
||||
}
|
||||
|
||||
static liAction* auth_htdigest_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(userdata);
|
||||
static liAction* auth_htdigest_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(wrk); UNUSED(userdata);
|
||||
return auth_generic_create(srv, p, val, "auth.htdigest", auth_backend_htdigest, TRUE);
|
||||
}
|
||||
|
||||
|
@ -486,8 +486,9 @@ static liHandlerResult auth_handle_deny(liVRequest *vr, gpointer param, gpointer
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* auth_deny(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* auth_deny(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv);
|
||||
UNUSED(wrk);
|
||||
UNUSED(p);
|
||||
UNUSED(userdata);
|
||||
|
||||
|
|
|
@ -165,9 +165,9 @@ static void balancer_act_free(liServer *srv, gpointer param) {
|
|||
balancer_free(srv, (balancer*) param);
|
||||
}
|
||||
|
||||
static liAction* balancer_rr(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* balancer_rr(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
balancer *b;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val) {
|
||||
ERROR(srv, "%s", "need parameter");
|
||||
|
|
|
@ -305,9 +305,9 @@ static void cache_etag_free(liServer *srv, gpointer param) {
|
|||
g_slice_free(cache_etag_context, ctx);
|
||||
}
|
||||
|
||||
static liAction* cache_etag_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* cache_etag_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
cache_etag_context *ctx;
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "%s", "cache.disk.etag expects a string as parameter");
|
||||
|
|
|
@ -295,8 +295,8 @@ static liHandlerResult debug_show_connections(liVRequest *vr, gpointer param, gp
|
|||
return (*context) ? LI_HANDLER_WAIT_FOR_EVENT : LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* debug_show_connections_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(p); UNUSED(userdata);
|
||||
static liAction* debug_show_connections_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "debug.show_connections doesn't expect any parameters");
|
||||
|
|
|
@ -666,9 +666,9 @@ static const GString
|
|||
don_outputbuffer = { CONST_STR_LEN("output-buffer"), 0 }
|
||||
;
|
||||
|
||||
static liAction* deflate_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* deflate_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
deflate_config *conf;
|
||||
UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(userdata);
|
||||
|
||||
if (val && val->type != LI_VALUE_HASH) {
|
||||
ERROR(srv, "%s", "deflate expects an optional hash of options");
|
||||
|
|
|
@ -609,13 +609,13 @@ static void dirlist_free(liServer *srv, gpointer param) {
|
|||
g_slice_free(dirlist_data, data);
|
||||
}
|
||||
|
||||
static liAction* dirlist_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* dirlist_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
dirlist_data *data;
|
||||
guint i;
|
||||
guint j;
|
||||
liValue *v, *tmpval;
|
||||
GString *k;
|
||||
UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(userdata);
|
||||
|
||||
if (val && val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "%s", "dirlist expects an optional list of string-value pairs");
|
||||
|
|
|
@ -131,11 +131,11 @@ static void expire_free(liServer *srv, gpointer param) {
|
|||
g_slice_free(expire_rule, param);
|
||||
}
|
||||
|
||||
static liAction* expire_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* expire_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
expire_rule *rule;
|
||||
gchar *str;
|
||||
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "%s", "expire expects a string as parameter");
|
||||
|
|
|
@ -769,10 +769,10 @@ static void fastcgi_free(liServer *srv, gpointer param) {
|
|||
fastcgi_context_release(ctx);
|
||||
}
|
||||
|
||||
static liAction* fastcgi_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* fastcgi_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
fastcgi_context *ctx;
|
||||
|
||||
UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "%s", "fastcgi expects a string as parameter");
|
||||
|
|
|
@ -172,9 +172,9 @@ static liHandlerResult flv(liVRequest *vr, gpointer param, gpointer *context) {
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* flv_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* flv_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
|
||||
UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "flv does not take any parameters");
|
||||
|
|
|
@ -55,8 +55,8 @@ static liHandlerResult fortune_header_handle(liVRequest *vr, gpointer param, gpo
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* fortune_header(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(val); UNUSED(userdata);
|
||||
static liAction* fortune_header(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(wrk); UNUSED(val); UNUSED(userdata);
|
||||
return li_action_new_function(fortune_header_handle, NULL, NULL, p->data);
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,8 @@ static liHandlerResult fortune_page_handle(liVRequest *vr, gpointer param, gpoin
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* fortune_page(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(val); UNUSED(userdata);
|
||||
static liAction* fortune_page(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(wrk); UNUSED(val); UNUSED(userdata);
|
||||
return li_action_new_function(fortune_page_handle, NULL, NULL, p->data);
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ static liHandlerResult lua_handle(liVRequest *vr, gpointer param, gpointer *cont
|
|||
|
||||
li_action_release(vr->wrk->srv, wc->act);
|
||||
wc->act = NULL;
|
||||
if (!li_config_lua_load(vr->wrk->L, vr->wrk->srv, conf->filename->str, &wc->act, FALSE, conf->args) || !wc->act) {
|
||||
if (!li_config_lua_load(vr->wrk->L, vr->wrk->srv, vr->wrk, conf->filename->str, &wc->act, FALSE, conf->args) || !wc->act) {
|
||||
VR_ERROR(vr, "lua.handler: couldn't load '%s'", conf->filename->str);
|
||||
return LI_HANDLER_ERROR;
|
||||
}
|
||||
|
@ -163,11 +163,11 @@ static const GString /* lua option names */
|
|||
lon_ttl = { CONST_STR_LEN("ttl"), 0 }
|
||||
;
|
||||
|
||||
static liAction* lua_handler_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* lua_handler_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
liValue *v_filename = NULL, *v_options = NULL, *v_args = NULL;
|
||||
lua_config *conf;
|
||||
guint ttl = 0;
|
||||
UNUSED(userdata);
|
||||
UNUSED(wrk); UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
if (val->type == LI_VALUE_STRING) {
|
||||
|
@ -288,13 +288,13 @@ static gboolean lua_plugin_handle_setup(liServer *srv, liPlugin *p, liValue *val
|
|||
return res;
|
||||
}
|
||||
|
||||
static liAction* lua_plugin_handle_action(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* lua_plugin_handle_action(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
lua_State *L = srv->L;
|
||||
int lua_ref = GPOINTER_TO_INT(userdata);
|
||||
int nargs, errfunc;
|
||||
liAction *res = NULL;
|
||||
|
||||
UNUSED(p);
|
||||
UNUSED(wrk); UNUSED(p);
|
||||
|
||||
li_lua_lock(srv);
|
||||
|
||||
|
@ -453,10 +453,10 @@ static gboolean lua_plugin_load(liServer *srv, liPlugin *p, GString *filename, l
|
|||
|
||||
DEBUG(srv, "Loaded lua plugin '%s'", filename->str);
|
||||
|
||||
li_lua_config_publish_str_hash(srv, L, srv->setups, li_lua_config_handle_server_setup);
|
||||
li_lua_config_publish_str_hash(srv, srv->main_worker, L, srv->setups, li_lua_config_handle_server_setup);
|
||||
lua_setfield(L, LUA_GLOBALSINDEX, "setup");
|
||||
|
||||
li_lua_config_publish_str_hash(srv, L, srv->actions, li_lua_config_handle_server_action);
|
||||
li_lua_config_publish_str_hash(srv, srv->main_worker, L, srv->actions, li_lua_config_handle_server_action);
|
||||
lua_setfield(L, LUA_GLOBALSINDEX, "action");
|
||||
|
||||
li_lua_push_lvalues_dict(srv, L);
|
||||
|
|
|
@ -188,8 +188,8 @@ static liHandlerResult progress_track(liVRequest *vr, gpointer param, gpointer *
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* progress_track_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(userdata);
|
||||
static liAction* progress_track_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(wrk); UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "progress.show doesn't expect any parameters");
|
||||
|
@ -385,11 +385,12 @@ static void progress_show_free(liServer *srv, gpointer param) {
|
|||
g_slice_free(mod_progress_show_param, param);
|
||||
}
|
||||
|
||||
static liAction* progress_show_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
static liAction* progress_show_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
mod_progress_show_param *psp;
|
||||
mod_progress_format format = PROGRESS_FORMAT_JSON;
|
||||
|
||||
UNUSED(srv);
|
||||
UNUSED(wrk);
|
||||
UNUSED(userdata);
|
||||