mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
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:
parent
98c674d915
commit
8c4cce043c
25 changed files with 22326 additions and 359 deletions
14
third_party/dlmalloc/dlmalloc.c
vendored
14
third_party/dlmalloc/dlmalloc.c
vendored
|
@ -578,7 +578,7 @@ static void *tmalloc_large(mstate m, size_t nb) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void *dlmalloc(size_t bytes) {
|
||||
void *dlmalloc_impl(size_t bytes, bool takeaction) {
|
||||
/*
|
||||
Basic algorithm:
|
||||
If a small request (< 256 bytes minus per-chunk overhead):
|
||||
|
@ -708,12 +708,16 @@ void *dlmalloc(size_t bytes) {
|
|||
|
||||
postaction:
|
||||
POSTACTION(g_dlmalloc);
|
||||
return ADDRESS_BIRTH_ACTION(mem);
|
||||
return takeaction ? AddressBirthAction(mem) : mem;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *dlmalloc(size_t bytes) {
|
||||
return dlmalloc_impl(bytes, true);
|
||||
}
|
||||
|
||||
void dlfree(void *mem) {
|
||||
/*
|
||||
Consolidate freed chunks with preceeding or succeeding bordering
|
||||
|
@ -721,7 +725,7 @@ void dlfree(void *mem) {
|
|||
with special cases for top, dv, mmapped chunks, and usage errors.
|
||||
*/
|
||||
if (mem != 0) {
|
||||
mem = ADDRESS_DEATH_ACTION(mem);
|
||||
mem = AddressDeathAction(mem);
|
||||
mchunkptr p = mem2chunk(mem);
|
||||
|
||||
#if FOOTERS
|
||||
|
@ -887,7 +891,7 @@ void *dlmemalign$impl(mstate m, size_t alignment, size_t bytes) {
|
|||
} else {
|
||||
size_t nb = request2size(bytes);
|
||||
size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD;
|
||||
mem = dlmalloc(req);
|
||||
mem = dlmalloc_impl(req, false);
|
||||
if (mem != 0) {
|
||||
mchunkptr p = mem2chunk(mem);
|
||||
if (PREACTION(m)) return 0;
|
||||
|
@ -936,7 +940,7 @@ void *dlmemalign$impl(mstate m, size_t alignment, size_t bytes) {
|
|||
POSTACTION(m);
|
||||
}
|
||||
}
|
||||
return ADDRESS_BIRTH_ACTION(mem);
|
||||
return AddressBirthAction(mem);
|
||||
}
|
||||
|
||||
void *dlmemalign(size_t alignment, size_t bytes) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue