Merge pull request #7 from zhaozg/master
fix mem leaks bug, unref cb data when easy/multi cleanup
This commit is contained in:
commit
0191e5cdec
23
src/lceasy.c
23
src/lceasy.c
@ -39,6 +39,8 @@ lcurl_easy_t *lcurl_geteasy_at(lua_State *L, int i){
|
||||
|
||||
static int lcurl_easy_cleanup(lua_State *L){
|
||||
lcurl_easy_t *p = lcurl_geteasy(L);
|
||||
int i;
|
||||
|
||||
if(p->curl){
|
||||
curl_easy_cleanup(p->curl);
|
||||
p->curl = NULL;
|
||||
@ -48,6 +50,27 @@ static int lcurl_easy_cleanup(lua_State *L){
|
||||
p->storage = lcurl_storage_free(L, p->storage);
|
||||
}
|
||||
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->wr.cb_ref);
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->wr.ud_ref);
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->rd.cb_ref);
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->rd.ud_ref);
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->pr.cb_ref);
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->pr.ud_ref);
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->hd.cb_ref);
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->hd.ud_ref);
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->rbuffer.ref);
|
||||
|
||||
p->wr.cb_ref = p->wr.ud_ref = LUA_NOREF;
|
||||
p->rd.cb_ref = p->rd.ud_ref = LUA_NOREF;
|
||||
p->hd.cb_ref = p->hd.ud_ref = LUA_NOREF;
|
||||
p->pr.cb_ref = p->pr.ud_ref = LUA_NOREF;
|
||||
p->rbuffer.ref = LUA_NOREF;
|
||||
|
||||
for(i = 0; i < LCURL_LIST_COUNT; ++i){
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->lists[i]);
|
||||
p->lists[i] = LUA_NOREF;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -361,8 +361,7 @@ static int lcurl_hpost_free(lua_State *L){
|
||||
}
|
||||
|
||||
if(p->storage != LUA_NOREF){
|
||||
lcurl_storage_free(L, p->storage);
|
||||
p->storage = LUA_NOREF;
|
||||
p->storage = lcurl_storage_free(L, p->storage);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -51,6 +51,9 @@ static int lcurl_multi_cleanup(lua_State *L){
|
||||
p->h_ref = LUA_NOREF;
|
||||
}
|
||||
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->tm.cb_ref);
|
||||
luaL_unref(L, LCURL_LUA_REGISTRY, p->tm.ud_ref);
|
||||
p->tm.cb_ref = p->tm.ud_ref = LUA_NOREF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -430,4 +433,4 @@ void lcurl_multi_initlib(lua_State *L, int nup){
|
||||
lua_pop(L, 1);
|
||||
|
||||
lcurl_util_set_const(L, lcurl_multi_opt);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user