diff options
| author | Diego Nehab <diego@impa.br> | 2013-09-09 14:23:00 -0300 |
|---|---|---|
| committer | Diego Nehab <diego@impa.br> | 2013-09-09 14:23:00 -0300 |
| commit | 396e9e5ee67dd3169aef6ef734d1f5e6f0ec76a9 (patch) | |
| tree | d1b57413f42ae6d2c8f2e4863c0cbe207e743829 /src | |
| parent | 244e5d34a0bd77a42efbd6a9ecafeff0aec4539e (diff) | |
| download | luasocket-396e9e5ee67dd3169aef6ef734d1f5e6f0ec76a9.tar.gz luasocket-396e9e5ee67dd3169aef6ef734d1f5e6f0ec76a9.tar.bz2 luasocket-396e9e5ee67dd3169aef6ef734d1f5e6f0ec76a9.zip | |
Fixed timeout bug introduced by commit e81a6ff
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/buffer.c b/src/buffer.c index 4ef4e8e..423d804 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -78,9 +78,7 @@ int buffer_meth_send(lua_State *L, p_buffer buf) { | |||
| 78 | const char *data = luaL_checklstring(L, 2, &size); | 78 | const char *data = luaL_checklstring(L, 2, &size); |
| 79 | long start = (long) luaL_optnumber(L, 3, 1); | 79 | long start = (long) luaL_optnumber(L, 3, 1); |
| 80 | long end = (long) luaL_optnumber(L, 4, -1); | 80 | long end = (long) luaL_optnumber(L, 4, -1); |
| 81 | #ifdef LUASOCKET_DEBUG | 81 | timeout_markstart(buf->tm); |
| 82 | p_timeout tm = timeout_markstart(buf->tm); | ||
| 83 | #endif | ||
| 84 | if (start < 0) start = (long) (size+start+1); | 82 | if (start < 0) start = (long) (size+start+1); |
| 85 | if (end < 0) end = (long) (size+end+1); | 83 | if (end < 0) end = (long) (size+end+1); |
| 86 | if (start < 1) start = (long) 1; | 84 | if (start < 1) start = (long) 1; |
| @@ -98,7 +96,7 @@ int buffer_meth_send(lua_State *L, p_buffer buf) { | |||
| 98 | } | 96 | } |
| 99 | #ifdef LUASOCKET_DEBUG | 97 | #ifdef LUASOCKET_DEBUG |
| 100 | /* push time elapsed during operation as the last return value */ | 98 | /* push time elapsed during operation as the last return value */ |
| 101 | lua_pushnumber(L, timeout_gettime() - timeout_getstart(tm)); | 99 | lua_pushnumber(L, timeout_gettime() - timeout_getstart(buf->tm)); |
| 102 | #endif | 100 | #endif |
| 103 | return lua_gettop(L) - top; | 101 | return lua_gettop(L) - top; |
| 104 | } | 102 | } |
| @@ -111,9 +109,7 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) { | |||
| 111 | luaL_Buffer b; | 109 | luaL_Buffer b; |
| 112 | size_t size; | 110 | size_t size; |
| 113 | const char *part = luaL_optlstring(L, 3, "", &size); | 111 | const char *part = luaL_optlstring(L, 3, "", &size); |
| 114 | #ifdef LUASOCKET_DEBUG | 112 | timeout_markstart(buf->tm); |
| 115 | p_timeout tm = timeout_markstart(buf->tm); | ||
| 116 | #endif | ||
| 117 | /* initialize buffer with optional extra prefix | 113 | /* initialize buffer with optional extra prefix |
| 118 | * (useful for concatenating previous partial results) */ | 114 | * (useful for concatenating previous partial results) */ |
| 119 | luaL_buffinit(L, &b); | 115 | luaL_buffinit(L, &b); |
| @@ -149,7 +145,7 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) { | |||
| 149 | } | 145 | } |
| 150 | #ifdef LUASOCKET_DEBUG | 146 | #ifdef LUASOCKET_DEBUG |
| 151 | /* push time elapsed during operation as the last return value */ | 147 | /* push time elapsed during operation as the last return value */ |
| 152 | lua_pushnumber(L, timeout_gettime() - timeout_getstart(tm)); | 148 | lua_pushnumber(L, timeout_gettime() - timeout_getstart(buf->tm)); |
| 153 | #endif | 149 | #endif |
| 154 | return lua_gettop(L) - top; | 150 | return lua_gettop(L) - top; |
| 155 | } | 151 | } |
