[mod_magnet] adjust hot path for more inlining
@@ -2372,7 +2372,7 @@ static handler_t magnet_attract(request_st * const r, plugin_data * const p, scr
/* pcall will destroy the func value, duplicate it */ /* (sp += 1) */
lua_pushvalue(L, func_ndx);
- {
+
int errfunc = push_traceback(L, 0);
int ret = lua_pcall(L, 0, 1, errfunc);
lua_remove(L, errfunc);
@@ -2381,23 +2381,22 @@ static handler_t magnet_attract(request_st * const r, plugin_data * const p, scr
lua_pushglobaltable(L); /* (sp += 1) */
magnet_setfenv_mainfn(L, 1); /* (sp -= 1) */
+ handler_t result = HANDLER_GO_ON;
if (0 != ret) {
log_error(r->conf.errh, __FILE__, __LINE__,
"lua_pcall(): %s", lua_tostring(L, -1));
lua_pop(L, 1); /* pop error msg */
/* only the function and lighty table should remain on the stack */
force_assert(lua_gettop(L) == 2);
- magnet_reset_lighty_table(L);
if (p->conf.stage != -1) { /* skip for response-start */
r->http_status = 500;
r->handler_module = NULL;
}
- return HANDLER_FINISHED;
- }
+ result = HANDLER_FINISHED;
}
-
+ else {
/* we should have the function, the lighty table and the return value on the stack */
/*force_assert(lua_gettop(L) == 3);*/
@@ -2413,15 +2412,11 @@ static handler_t magnet_attract(request_st * const r, plugin_data * const p, scr
"lua_pcall(): unexpected non-integer return type: %s",
luaL_typename(L, -1));
}
-
lua_pop(L, 1); /* pop return value */
/*force_assert(lua_istable(sc->L, -1));*/
magnet_copy_response_header(L, r);
- {
- handler_t result = HANDLER_GO_ON;
-
if (lua_return_value >= 200) {
r->http_status = lua_return_value;
r->resp_body_finished = 1;
@@ -2460,10 +2455,10 @@ static handler_t magnet_attract(request_st * const r, plugin_data * const p, scr
}
}
+ }
magnet_reset_lighty_table(L);
return result;
}
-}
static handler_t magnet_attract_array(request_st * const r, plugin_data * const p, int stage) {
mod_magnet_patch_config(r, p);
