From 182d7720cfafd6543b86ef82ebad3f5af8a2f70e Mon Sep 17 00:00:00 2001 From: Justine Tunney <jtunney@gmail.com> Date: Sat, 9 Jul 2022 01:18:55 -0700 Subject: [PATCH] Fix GitHub actions Our build was flaking due to ETXTBSY errors running multiple redbean instances in parallel. This is due to the StoreAsset() support which seems to cause enough problems it's worth making a *breaking change* turning it off by default for now. There's a new -* flag, to restore redbean's old self-modifying behavior. --- test/tool/net/lre_test.lua | 26 ++++++++++++++++++++++++++ tool/net/help.txt | 10 ++++++---- tool/net/redbean.c | 10 +++++++--- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/test/tool/net/lre_test.lua b/test/tool/net/lre_test.lua index f05d7b851..3369d76c3 100644 --- a/test/tool/net/lre_test.lua +++ b/test/tool/net/lre_test.lua @@ -13,6 +13,9 @@ -- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -- PERFORMANCE OF THIS SOFTWARE. +assert(string.match("127.123.231.1", "%d+.%d+.%d+.%d+")) +assert(re.search([[^\d{1,3}(\.\d{1,3}){3}$]], "127.123.231.1")) + m,a,b,c,d = assert(re.search([[^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$]], "127.0.0.1")) assert(m == "127.0.0.1") assert(a == "127") @@ -38,3 +41,26 @@ assert(d == "1") p,e = re.compile("[{") assert(e:errno() == re.EBRACK) assert(e:doc() == "Missing ']'") + +---------------------------------------------------------------------------------------------------- +-- BENCHMARKS + +function ReCompileSearch() + assert(re.search([[^\d{1,3}(\.\d{1,3}){3}$]], "127.123.231.1")) +end + +preg = assert(re.compile[[^\d{1,3}(\.\d{1,3}){3}$]]) +function ReSearch() + assert(preg:search("127.123.231.1")) +end + +function Match() + assert(string.match("127.123.231.1", "%d+.%d+.%d+.%d+")) +end + +-- 6120 re.search() +-- 425 re.Regex:search() +-- 196 string.match() +print("--", Benchmark(ReCompileSearch), "re.search()") +print("--", Benchmark(ReSearch), "re.Regex:search()") +print("--", Benchmark(Match), "string.match()") diff --git a/tool/net/help.txt b/tool/net/help.txt index a57b2949f..10669b4be 100644 --- a/tool/net/help.txt +++ b/tool/net/help.txt @@ -55,6 +55,7 @@ FLAGS -f log worker function calls -B only use stronger cryptography -X disable ssl server and client support + -* permit self-modification of executable -J disable non-ssl server and client support -% hasten startup by not generating an rsa key -s increase silence [repeatable] @@ -996,10 +997,11 @@ FUNCTIONS then consider using ServeAsset which can serve directly off disk. StoreAsset(path:str,data:str[,mode:int]) - Stores asset to executable's ZIP central directory. This currently - happens in an append-only fashion and is still largely in the - proof-of-concept stages. Currently only supported on Linux, XNU, - and FreeBSD. + Stores asset to executable's ZIP central directory. This + currently happens in an append-only fashion and is still + largely in the proof-of-concept stages. Currently only + supported on Linux, XNU, and FreeBSD. In order to use this + feature, the -* flag must be passed. Log(level:int,message:str) Emits message string to log, if level is less than or equal to diff --git a/tool/net/redbean.c b/tool/net/redbean.c index 705880e6f..3bab4c1ef 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -186,8 +186,8 @@ STATIC_YOINK("ShowCrashReportsEarly"); // letters not used: EINOQYnoqwxy // digits not used: 0123456789 -// puncts not used: !"#$&'()*+,-./;<=>@[\]^_`{|}~ -#define GETOPTS "%BJSVXZabdfghijkmsuvzA:C:D:F:G:H:K:L:M:P:R:T:U:W:c:e:l:p:r:t:" +// puncts not used: !"#$&'()+,-./;<=>@[\]^_`{|}~ +#define GETOPTS "*%BJSVXZabdfghijkmsuvzA:C:D:F:G:H:K:L:M:P:R:T:U:W:c:e:l:p:r:t:" static const uint8_t kGzipHeader[] = { 0x1F, // MAGNUM @@ -376,6 +376,7 @@ static bool checkedmethod; static bool sslinitialized; static bool sslfetchverify; static bool hascontenttype; +static bool selfmodifiable; static bool gotcachecontrol; static bool interpretermode; static bool sslclientverify; @@ -7224,6 +7225,7 @@ static void GetOpts(int argc, char *argv[]) { CASE('u', uniprocess = true); CASE('g', loglatency = true); CASE('m', logmessages = true); + CASE('*', selfmodifiable = true); CASE('l', ProgramAddr(optarg)); CASE('H', ProgramHeader(optarg)); CASE('L', ProgramLogPath(optarg)); @@ -7290,10 +7292,12 @@ void RedBean(int argc, char *argv[]) { CHECK_NE(-1, (zfd = open(zpath, O_RDONLY))); CHECK_NE(-1, fstat(zfd, &zst)); OpenZip(true); - MakeExecutableModifiable(); SetDefaults(); LuaStart(); GetOpts(argc, argv); + if (selfmodifiable) { + MakeExecutableModifiable(); + } LuaInit(); oldloglevel = __log_level; if (uniprocess) {