diff --git a/src/lua/ipc.cc b/src/lua/ipc.cc
index 86799b5372308ed746b56fa97bd4fcd2eabbcf28..fd7516d7cc19d720fe1a8b93d7d55859559df9c4 100644
--- a/src/lua/ipc.cc
+++ b/src/lua/ipc.cc
@@ -149,13 +149,21 @@ lbox_ipc_channel_put(struct lua_State *L)
 	lua_pushnumber(L, rid);
 	lua_pushvalue(L, 2);
 	lua_settable(L, -4);
-	lua_settop(L, top);
 
 
-	if (ipc_channel_put_timeout(ch, (void *)rid, timeout) == 0)
-		lua_pushboolean(L, 1);
-	else
-		lua_pushboolean(L, 0);
+	int retval;
+	if (ipc_channel_put_timeout(ch, (void *)rid, timeout) == 0) {
+		retval = 1;
+	} else {
+		/* put timeout */
+		retval = 0;
+		lua_pushnumber(L, rid);
+		lua_pushnil(L);
+		lua_settable(L, -4);
+	}
+
+	lua_settop(L, top);
+	lua_pushboolean(L, retval);
 	return 1;
 }