From 05272ea0964805cc6e6db71c104d1b48b2aa12f2 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Sun, 7 Sep 2014 11:21:54 +0400 Subject: [PATCH] Fix. Easy cleanup unref wrong reference Fix. Read buffer use size_t as offset Change. Use httpbin.org as test server ```Lua -- Test case for easy:close() form = curl.form() e = curl.easy{httpheader = {}} e:close() form:free() ``` --- src/lceasy.c | 5 ++--- src/lcutils.h | 4 ++-- test/test_pause02.c.lua | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lceasy.c b/src/lceasy.c index 89da432..d47552c 100644 --- a/src/lceasy.c +++ b/src/lceasy.c @@ -87,7 +87,6 @@ static int lcurl_easy_cleanup(lua_State *L){ 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; } @@ -696,7 +695,7 @@ static size_t lcurl_read_callback(lua_State *L, assert(rbuffer->ref == LUA_NOREF); n = lcurl_util_push_cb(L, rd); - lua_pushnumber(L, ret); + lua_pushinteger(L, ret); if(lua_pcall(L, n, LUA_MULTRET, 0)) return CURL_READFUNC_ABORT; if(lua_isnoneornil(L, top + 1)){ @@ -786,7 +785,7 @@ static int lcurl_xferinfo_callback(void *arg, curl_off_t dltotal, curl_off_t dln if(lua_isboolean(L, top + 1)) ret = lua_toboolean(L, top + 1)?0:1; else{ - ret = (size_t)lua_tonumber(L, top + 1); + ret = lua_tointeger(L, top + 1); if(ret == 0) ret = 1; else ret = 0; } } diff --git a/src/lcutils.h b/src/lcutils.h index 7790188..341d28b 100644 --- a/src/lcutils.h +++ b/src/lcutils.h @@ -19,8 +19,8 @@ typedef struct lcurl_callback_tag{ }lcurl_callback_t; typedef struct lcurl_read_buffer_tag{ - int ref; - int off; + int ref; + size_t off; }lcurl_read_buffer_t; int lcurl_storage_init(lua_State *L); diff --git a/test/test_pause02.c.lua b/test/test_pause02.c.lua index ff3e786..50dd6d0 100644 --- a/test/test_pause02.c.lua +++ b/test/test_pause02.c.lua @@ -5,7 +5,8 @@ local curl = require "lcurl" -- i.e. 1 means that CURLPAUSE_CONT will be performed immediately after pause.) local WAIT_COUNT = 32 -local RESOURCE_URL = "http://www.rfc-editor.org/rfc/rfc2543.txt" +local SIZE = 100 * 1024 +local RESOURCE_URL = "http://httpbin.org/bytes/" .. SIZE local State = { PAUSE = 0, -- write function should return CURL_WRITEFUNC_PAUSE