Skip to content

Commit

Permalink
proxy: fix leak in config reload
Browse files Browse the repository at this point in the history
- config reload loads the code from disk, then dumps it into an internal
  binary blob
- that binary blob is loaded from memory into each worker thread
- that temporary blob wasn't being freed

if you have large initial lua and reload every second for hours on end
you'd leak a few megs of ram
  • Loading branch information
dormando committed Mar 10, 2024
1 parent 6576382 commit 4e3ac00
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions proxy_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ int proxy_load_config(void *arg) {
db->buf = malloc(db->size);
lua_dump(L, _dump_helper, db, 0);
// 0 means no error.
if (ctx->proxy_code) {
struct _dumpbuf *old = ctx->proxy_code;
free(old->buf);
free(old);
ctx->proxy_code = NULL;
}
ctx->proxy_code = db;

// now we complete the data load by calling the function.
Expand Down

0 comments on commit 4e3ac00

Please sign in to comment.