fix memory leak in http one-shot requests (#2615)
This commit is contained in:
parent
ca92cfd362
commit
efc9a6b047
|
@ -648,10 +648,9 @@ static int http_accumulate_complete(lua_State *L)
|
|||
lua_rawseti(L, cache_table, i);
|
||||
}
|
||||
luaL_pushresult(&b); // data now pushed
|
||||
lhttp_context_t *context = (lhttp_context_t *)luaL_checkudata(L, context_idx, http_context_mt);
|
||||
if (lua_isnoneornil(L, 1)) {
|
||||
// No callback fn so must be sync, meaning just need to stash headers and data in the context
|
||||
lhttp_context_t *context = (lhttp_context_t *)luaL_checkudata(L, context_idx, http_context_mt);
|
||||
|
||||
// steal some completion refs, nothing's going to need them again in a one-shot
|
||||
context_setref(L, context, DataCallback); // pops data
|
||||
lua_rawgeti(L, cache_table, 2); // headers
|
||||
|
@ -660,6 +659,8 @@ static int http_accumulate_complete(lua_State *L)
|
|||
lua_rawgeti(L, cache_table, 2); // headers
|
||||
lua_call(L, 3, 0);
|
||||
}
|
||||
// unset this since it contains a reference to the context and would prevent the context to be garbage collected
|
||||
context_unsetref(L, context,CompleteCallback);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue