[Tarantool-patches] [PATCH 13/20] net.box: rewrite send_and_recv_{iproto, console} in C

Vladimir Davydov vdavydov at tarantool.org
Thu Aug 5 11:37:44 MSK 2021


On Wed, Aug 04, 2021 at 11:18:55PM +0200, Vladislav Shpilevoy wrote:
> > +static int
> > +netbox_send_and_recv_iproto(lua_State *L)
> > +{
> > +	int fd = lua_tointeger(L, 1);
> > +	struct ibuf *send_buf = (struct ibuf *)lua_topointer(L, 2);
> > +	struct ibuf *recv_buf = (struct ibuf *)lua_topointer(L, 3);
> > +	double timeout = (!lua_isnoneornil(L, 4) ?
> > +			  lua_tonumber(L, 4) : TIMEOUT_INFINITY);
> 
> Timeout is never passed to this function. It is always TIMEOUT_INFINITY.
> The same for netbox_send_and_recv_console.

Removed the unused timeout argument in a separate patch and rebased the
rest of the series on top:

>From 6cceb3ecc0f326c212103e6319226d40b2223d31 Mon Sep 17 00:00:00 2001
From: Vladimir Davydov <vdavydov at tarantool.org>
Date: Thu, 5 Aug 2021 10:52:13 +0300
Subject: [PATCH] net.box: remove unused timeout argument from IO methods

Part of #6241

diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c
index 19289e750c98..ee3cfe95a49c 100644
--- a/src/box/lua/net_box.c
+++ b/src/box/lua/net_box.c
@@ -436,7 +436,7 @@ netbox_decode_greeting(lua_State *L)
 }
 
 /**
- * communicate(fd, send_buf, recv_buf, limit_or_boundary, timeout)
+ * communicate(fd, send_buf, recv_buf, limit_or_boundary)
  *  -> errno, error
  *  -> nil, limit/boundary_pos
  *
@@ -467,15 +467,6 @@ netbox_communicate(lua_State *L)
 	else
 		limit = lua_tonumber(L, 4);
 
-	/* timeout */
-	ev_tstamp timeout = TIMEOUT_INFINITY;
-	if (lua_type(L, 5) == LUA_TNUMBER)
-		timeout = lua_tonumber(L, 5);
-	if (timeout < 0) {
-		lua_pushinteger(L, ER_TIMEOUT);
-		lua_pushstring(L, "Timeout exceeded");
-		return 2;
-	}
 	int revents = COIO_READ;
 	while (true) {
 		/* reader serviced first */
@@ -526,18 +517,10 @@ check_limit:
 				goto handle_error;
 		}
 
-		ev_tstamp deadline = ev_monotonic_now(loop()) + timeout;
 		ERROR_INJECT_YIELD(ERRINJ_NETBOX_IO_DELAY);
 		revents = coio_wait(fd, EV_READ | (ibuf_used(send_buf) != 0 ?
-				EV_WRITE : 0), timeout);
+				EV_WRITE : 0), TIMEOUT_INFINITY);
 		luaL_testcancel(L);
-		timeout = deadline - ev_monotonic_now(loop());
-		timeout = MAX(0.0, timeout);
-		if (revents == 0 && timeout == 0.0) {
-			lua_pushinteger(L, ER_TIMEOUT);
-			lua_pushstring(L, "Timeout exceeded");
-			return 2;
-		}
 	}
 handle_error:
 	lua_pushinteger(L, ER_NO_CONNECTION);
diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua
index 242b1c8d9314..3b2d60b39a0d 100644
--- a/src/box/lua/net_box.lua
+++ b/src/box/lua/net_box.lua
@@ -581,12 +581,12 @@ local function create_transport(host, port, user, password, callback,
     end
 
     -- IO (WORKER FIBER) --
-    local function send_and_recv(limit_or_boundary, timeout)
+    local function send_and_recv(limit_or_boundary)
         return communicate(connection:fd(), send_buf, recv_buf,
-                           limit_or_boundary, timeout)
+                           limit_or_boundary)
     end
 
-    local function send_and_recv_iproto(timeout)
+    local function send_and_recv_iproto()
         local data_len = recv_buf.wpos - recv_buf.rpos
         local required
         if data_len < 5 then
@@ -603,17 +603,16 @@ local function create_transport(host, port, user, password, callback,
                 return nil, hdr, body_rpos, body_end
             end
         end
-        local deadline = fiber_clock() + (timeout or TIMEOUT_INFINITY)
-        local err, extra = send_and_recv(required, timeout)
+        local err, extra = send_and_recv(required)
         if err then
             return err, extra
         end
-        return send_and_recv_iproto(max(0, deadline - fiber_clock()))
+        return send_and_recv_iproto()
     end
 
-    local function send_and_recv_console(timeout)
+    local function send_and_recv_console()
         local delim = '\n...\n'
-        local err, delim_pos = send_and_recv(delim, timeout)
+        local err, delim_pos = send_and_recv(delim)
         if err then
             return err, delim_pos
         else


More information about the Tarantool-patches mailing list