Add ProgramUniprocess to redbean (#364)

This commit is contained in:
Paul Kulchenko 2022-03-07 18:15:44 -08:00 committed by GitHub
parent 1e3c5e10ad
commit abac6f729c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -930,6 +930,10 @@ FUNCTIONS
someone with a slow internet connection who's downloading big
files unhappy.
ProgramUniprocess([bool]) → bool
Same as the -u flag if called from .init.lua. Can be used to
configure the uniprocess mode. The current value is returned.
Slurp(filename:str) → str
Reads file data from local file system.

View file

@ -5015,6 +5015,18 @@ static int LuaProgramSslTicketLifetime(lua_State *L) {
return LuaProgramInt(L, ProgramSslTicketLifetime);
}
static int LuaProgramUniprocess(lua_State *L) {
OnlyCallFromInitLua(L, "ProgramUniprocess");
if (!lua_isboolean(L, 1) && !lua_isnoneornil(L, 1))
return luaL_argerror(L, 1, "invalid uniprocess mode; boolean expected");
lua_pushboolean(L, uniprocess);
if (!IsWindows()) { // uniprocess can't be disabled on Windows yet
if (lua_isboolean(L, 1)) uniprocess = lua_toboolean(L, 1);
}
return 1;
}
static dontinline int LuaProgramString(lua_State *L, void P(const char *)) {
P(luaL_checkstring(L, 1));
return 0;
@ -5644,6 +5656,7 @@ static const luaL_Reg kLuaFuncs[] = {
{"ProgramSslTicketLifetime", LuaProgramSslTicketLifetime}, //
{"ProgramTimeout", LuaProgramTimeout}, //
{"ProgramUid", LuaProgramUid}, //
{"ProgramUniprocess", LuaProgramUniprocess}, //
{"Route", LuaRoute}, //
{"RouteHost", LuaRouteHost}, //
{"RoutePath", LuaRoutePath}, //