Make improvements to redbean

The following Lua APIs have been added:

  - IsDaemon() → bool
  - ProgramPidPath(str)

The following Lua hooks have been added:

  - OnClientConnection(ip:int,port:int,serverip:int,serverport:int) → bool
  - OnProcessCreate(pid:int,ip:int,port:int,serverip:int,serverport:int)
  - OnProcessDestroy(pid:int)
  - OnServerStart()
  - OnServerStop()
  - OnWorkerStart()
  - OnWorkerStop()

redbean now does a better job at applying gzip on the fly from the local
filesystem, using a streaming chunked api with constant memory, which is
useful for doing things like serving a 4gb text file off NFS, and having
it start transmitting in milliseconds. redbean will also compute entropy
on the beginnings of files to determine if compression is profitable.

This change pays off technical debts relating to memory, such as relying
on exit() to free() allocations. That's now mostly fixed so it should be
easier now to spot memory leaks in malloc traces.

This change also fixes bugs and makes improvements to our SSL support.
Uniprocess mode failed handshakes are no longer an issue. Token Alpn is
offered so curl -v looks less weird. Hybrid SSL certificate loading is
now smarter about naming conflicts. Self-signed CA root anchors will no
longer be delivered to the client during the handshake.
This commit is contained in:
Justine Tunney 2021-07-10 15:02:03 -07:00
parent 98c674d915
commit 8c4cce043c
25 changed files with 22326 additions and 359 deletions

View file

@ -7,6 +7,10 @@ extern size_t kHyperionSize;
extern char kHyperion[];
extern uint8_t kHyperionZip[];
extern size_t kMobySize;
extern char kMoby[];
extern uint8_t kMobyZip[];
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_TESTLIB_HYPERION_H_ */

32
libc/testlib/moby.S Normal file
View file

@ -0,0 +1,32 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/macros.internal.h"
.rodata
// Nontrivial NUL-terminated string test vector.
.align 1
kMoby:
0: .incbin "libc/testlib/moby.txt"
1: .byte 0
.endobj kMoby,globl
.align 8
kMobySize:
.quad 1b-0b
.endobj kMobySize,globl

12
libc/testlib/moby.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef COSMOPOLITAN_LIBC_TESTLIB_MOBY_H_
#define COSMOPOLITAN_LIBC_TESTLIB_MOBY_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern size_t kMobySize;
extern char kMoby[];
extern uint8_t kMobyZip[];
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_TESTLIB_MOBY_H_ */

21257
libc/testlib/moby.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -13,22 +13,25 @@ LIBC_TESTLIB_A = o/$(MODE)/libc/testlib/testlib.a
LIBC_TESTLIB_A_CHECKS = $(LIBC_TESTLIB_A).pkg
LIBC_TESTLIB_A_ASSETS = \
libc/testlib/blocktronics.txt \
libc/testlib/hyperion.txt \
libc/testlib/blocktronics.txt
libc/testlib/moby.txt
LIBC_TESTLIB_A_HDRS = \
libc/testlib/bench.h \
libc/testlib/ezbench.h \
libc/testlib/blocktronics.h \
libc/testlib/ezbench.h \
libc/testlib/hyperion.h \
libc/testlib/moby.h \
libc/testlib/testlib.h
LIBC_TESTLIB_A_SRCS_S = \
libc/testlib/bench.S \
libc/testlib/blocktronics.S \
libc/testlib/combo.S \
libc/testlib/fixture.S \
libc/testlib/blocktronics.S \
libc/testlib/hyperion.S \
libc/testlib/moby.S \
libc/testlib/testcase.S \
libc/testlib/thrashcodecache.S \
libc/testlib/thunks/assert_eq.S \
@ -44,32 +47,32 @@ LIBC_TESTLIB_A_SRCS_S = \
LIBC_TESTLIB_A_SRCS_C = \
libc/testlib/almostequallongdouble.c \
libc/testlib/hexequals.c \
libc/testlib/benchrunner.c \
libc/testlib/binequals.c \
libc/testlib/clearxmmregisters.c \
libc/testlib/formatbool.c \
libc/testlib/formatrange.c \
libc/testlib/globals.c \
libc/testlib/incrementfailed.c \
libc/testlib/formatfloat.c \
libc/testlib/comborunner.c \
libc/testlib/contains.c \
libc/testlib/endswith.c \
libc/testlib/ezbenchcontrol.c \
libc/testlib/ezbenchreport.c \
libc/testlib/fixturerunner.c \
libc/testlib/formatbinaryasglyphs.c \
libc/testlib/formatbinaryashex.c \
libc/testlib/formatbool.c \
libc/testlib/formatfloat.c \
libc/testlib/formatint.c \
libc/testlib/formatrange.c \
libc/testlib/formatstr.c \
libc/testlib/globals.c \
libc/testlib/hexequals.c \
libc/testlib/incrementfailed.c \
libc/testlib/shoulddebugbreak.c \
libc/testlib/showerror.c \
libc/testlib/showerror_.c \
libc/testlib/strequals.c \
libc/testlib/startswith.c \
libc/testlib/endswith.c \
libc/testlib/contains.c \
libc/testlib/strcaseequals.c \
libc/testlib/benchrunner.c \
libc/testlib/testrunner.c \
libc/testlib/comborunner.c \
libc/testlib/fixturerunner.c \
libc/testlib/ezbenchreport.c \
libc/testlib/ezbenchcontrol.c
libc/testlib/strequals.c \
libc/testlib/testrunner.c
LIBC_TESTLIB_A_SRCS = \
$(LIBC_TESTLIB_A_SRCS_S) \