Blame SOURCES/luasocket-3.0-settimeout.patch

93099a
From 396e9e5ee67dd3169aef6ef734d1f5e6f0ec76a9 Mon Sep 17 00:00:00 2001
93099a
From: Diego Nehab <diego@impa.br>
93099a
Date: Mon, 9 Sep 2013 14:23:00 -0300
93099a
Subject: [PATCH] Fixed timeout bug introduced by commit e81a6ff
93099a
93099a
---
93099a
 src/buffer.c | 12 ++++--------
93099a
 1 file changed, 4 insertions(+), 8 deletions(-)
93099a
93099a
diff --git a/src/buffer.c b/src/buffer.c
93099a
index 4ef4e8e..423d804 100644
93099a
--- a/src/buffer.c
93099a
+++ b/src/buffer.c
93099a
@@ -78,9 +78,7 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
93099a
     const char *data = luaL_checklstring(L, 2, &size);
93099a
     long start = (long) luaL_optnumber(L, 3, 1);
93099a
     long end = (long) luaL_optnumber(L, 4, -1);
93099a
-#ifdef LUASOCKET_DEBUG
93099a
-    p_timeout tm = timeout_markstart(buf->tm);
93099a
-#endif
93099a
+    timeout_markstart(buf->tm);
93099a
     if (start < 0) start = (long) (size+start+1);
93099a
     if (end < 0) end = (long) (size+end+1);
93099a
     if (start < 1) start = (long) 1;
93099a
@@ -98,7 +96,7 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
93099a
     }
93099a
 #ifdef LUASOCKET_DEBUG
93099a
     /* push time elapsed during operation as the last return value */
93099a
-    lua_pushnumber(L, timeout_gettime() - timeout_getstart(tm));
93099a
+    lua_pushnumber(L, timeout_gettime() - timeout_getstart(buf->tm));
93099a
 #endif
93099a
     return lua_gettop(L) - top;
93099a
 }
93099a
@@ -111,9 +109,7 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
93099a
     luaL_Buffer b;
93099a
     size_t size;
93099a
     const char *part = luaL_optlstring(L, 3, "", &size);
93099a
-#ifdef LUASOCKET_DEBUG
93099a
-    p_timeout tm = timeout_markstart(buf->tm);
93099a
-#endif
93099a
+    timeout_markstart(buf->tm);
93099a
     /* initialize buffer with optional extra prefix 
93099a
      * (useful for concatenating previous partial results) */
93099a
     luaL_buffinit(L, &b);
93099a
@@ -149,7 +145,7 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
93099a
     }
93099a
 #ifdef LUASOCKET_DEBUG
93099a
     /* push time elapsed during operation as the last return value */
93099a
-    lua_pushnumber(L, timeout_gettime() - timeout_getstart(tm));
93099a
+    lua_pushnumber(L, timeout_gettime() - timeout_getstart(buf->tm));
93099a
 #endif
93099a
     return lua_gettop(L) - top;
93099a
 }