diff --git a/src/luasocket/buffer.c b/src/luasocket/buffer.c
index 226f847e005da73d3f557d94f42beba27ec15c2a..9d829c9c78b9b4cf0121e406e371a0a6c136fc59 100644
--- a/src/luasocket/buffer.c
+++ b/src/luasocket/buffer.c
@@ -80,7 +80,7 @@ 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
+#ifdef LUASOCKET_DEBUG
     p_timeout tm = timeout_markstart(buf->tm);
 #endif
     if (start < 0) start = (long) (size+start+1);
@@ -113,7 +113,7 @@ 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
+#ifdef LUASOCKET_DEBUG
     p_timeout tm = timeout_markstart(buf->tm);
 #endif
     /* initialize buffer with optional extra prefix