diff --git a/src/luasocket/buffer.c b/src/luasocket/buffer.c
index 73f4ffa85e6136682f9a6000f83cac62b17d588d..226f847e005da73d3f557d94f42beba27ec15c2a 100644
--- a/src/luasocket/buffer.c
+++ b/src/luasocket/buffer.c
@@ -80,7 +80,9 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
     const char *data = luaL_checklstring(L, 2, &size);
     long start = (long) luaL_optnumber(L, 3, 1);
     long end = (long) luaL_optnumber(L, 4, -1);
+#ifndef LUASOCKET_DEBUG
     p_timeout tm = timeout_markstart(buf->tm);
+#endif
     if (start < 0) start = (long) (size+start+1);
     if (end < 0) end = (long) (size+end+1);
     if (start < 1) start = (long) 1;
@@ -111,7 +113,9 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
     luaL_Buffer b;
     size_t size;
     const char *part = luaL_optlstring(L, 3, "", &size);
+#ifndef LUASOCKET_DEBUG
     p_timeout tm = timeout_markstart(buf->tm);
+#endif
     /* initialize buffer with optional extra prefix 
      * (useful for concatenating previous partial results) */
     luaL_buffinit(L, &b);