Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [PATCH 8/8] netbox: implement perform_request via async version
Date: Mon, 23 Apr 2018 19:47:41 +0300	[thread overview]
Message-ID: <20180423164741.u4q5ge6iuioyyr23@esperanza> (raw)
In-Reply-To: <8562701387bad232860bbb98371f5be067754c97.1523903144.git.v.shpilevoy@tarantool.org>

On Mon, Apr 16, 2018 at 09:39:18PM +0300, Vladislav Shpilevoy wrote:
> When async netbox was introduced, it is not needed to hold a
> special sync implementation - it can be just async call + waiting
> for a response.
> 
> Closes #3107
> ---
>  src/box/lua/net_box.lua | 26 +++++++++-----------------
>  1 file changed, 9 insertions(+), 17 deletions(-)

I'd squash this one with patch 6.

> 
> diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua
> index a2b7b39d2..6b33f70c7 100644
> --- a/src/box/lua/net_box.lua
> +++ b/src/box/lua/net_box.lua
> @@ -437,24 +437,16 @@ local function create_transport(host, port, user, password, callback,
>  
>      --
>      -- Send a request and wait for response.
> +    -- @retval nil, error Error occured.
> +    -- @retval not nil Response object.
>      --
>      local function perform_request(timeout, buffer, method, ...)
>          local request, err =
>              perform_async_request(buffer, method, ...)
>          if not request then
> -            return last_errno or E_NO_CONNECTION, last_error
> +            return nil, err
>          end
> -        request.client = fiber_self()
> -        local id = request.id
> -        local deadline = fiber_clock() + (timeout or TIMEOUT_INFINITY)
> -        repeat
> -            local timeout = max(0, deadline - fiber_clock())
> -            if not state_cond:wait(timeout) then
> -                requests[id] = nil
> -                return E_TIMEOUT, 'Timeout exceeded'
> -            end
> -        until requests[id] == nil -- i.e. completed (beware spurious wakeups)
> -        return request.errno, request.response
> +        return request:wait_result(timeout)
>      end
>  
>      local function dispatch_response_iproto(hdr, body_rpos, body_end)
> @@ -988,9 +980,9 @@ function remote_methods:_request(method, opts, ...)
>          transport.wait_state('active', timeout)
>          timeout = deadline and max(0, deadline - fiber_clock())
>      end
> -    local err, res = transport.perform_request(timeout, buffer, method, ...)
> +    local res, err = transport.perform_request(timeout, buffer, method, ...)
>      if err then
> -        box.error({code = err, reason = res})
> +        box.error.raise(err)
>      end
>      -- Try to wait until a schema is reloaded if needed.
>      -- Regardless of reloading result, the main response is
> @@ -1182,13 +1174,13 @@ function console_methods:eval(line, timeout)
>      end
>      if self.protocol == 'Binary' then
>          local loader = 'return require("console").eval(...)'
> -        err, res = pr(timeout, nil, 'eval', loader, {line})
> +        res, err = pr(timeout, nil, 'eval', loader, {line})
>      else
>          assert(self.protocol == 'Lua console')
> -        err, res = pr(timeout, nil, 'inject', line..'$EOF$\n')
> +        res, err = pr(timeout, nil, 'inject', line..'$EOF$\n')
>      end
>      if err then
> -        box.error({code = err, reason = res})
> +        box.error.raise(err)
>      end
>      return res[1] or res
>  end

  reply	other threads:[~2018-04-23 16:47 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16 18:39 [PATCH 0/8] netbox: introduce fiber-async API Vladislav Shpilevoy
2018-04-16 18:39 ` [PATCH 1/8] lua: fix box.error.raise Vladislav Shpilevoy
2018-04-23 16:19   ` Vladimir Davydov
2018-05-08 15:36   ` [tarantool-patches] " Konstantin Osipov
2018-05-08 17:24     ` [tarantool-patches] " Vladislav Shpilevoy
2018-04-16 18:39 ` [PATCH 2/8] lua: allow to create and error object with no throw Vladislav Shpilevoy
2018-04-23 16:20   ` Vladimir Davydov
2018-05-08 15:37   ` [tarantool-patches] " Konstantin Osipov
2018-04-16 18:39 ` [PATCH 3/8] console: fix a bug in interactive readline usage Vladislav Shpilevoy
2018-04-23 16:20   ` Vladimir Davydov
2018-05-08 15:37   ` [tarantool-patches] " Konstantin Osipov
2018-04-16 18:39 ` [PATCH 4/8] netbox: extend codec with 'decode' methods Vladislav Shpilevoy
2018-04-23 16:42   ` Vladimir Davydov
2018-04-23 18:59     ` [tarantool-patches] " Vladislav Shpilevoy
2018-04-24 13:16       ` Vladimir Davydov
2018-05-08 15:49   ` [tarantool-patches] " Konstantin Osipov
2018-05-08 17:24     ` [tarantool-patches] " Vladislav Shpilevoy
2018-04-16 18:39 ` [PATCH 5/8] test: fix unstable test Vladislav Shpilevoy
2018-04-22  5:32   ` [tarantool-patches] " Kirill Yukhin
2018-05-08 15:50   ` Konstantin Osipov
2018-04-16 18:39 ` [PATCH 6/8] netbox: introduce fiber-async API Vladislav Shpilevoy
2018-04-23 12:31   ` [tarantool-patches] " Alexander Turenko
2018-04-23 18:59     ` Vladislav Shpilevoy
2018-04-23 16:44   ` Vladimir Davydov
2018-04-23 18:59     ` [tarantool-patches] " Vladislav Shpilevoy
2018-04-24 13:05       ` Vladimir Davydov
2018-04-16 18:39 ` [PATCH 7/8] netbox: remove schema_version from requests Vladislav Shpilevoy
2018-05-08 16:06   ` [tarantool-patches] " Konstantin Osipov
2018-05-08 17:24     ` [tarantool-patches] " Vladislav Shpilevoy
2018-04-16 18:39 ` [PATCH 8/8] netbox: implement perform_request via async version Vladislav Shpilevoy
2018-04-23 16:47   ` Vladimir Davydov [this message]
2018-04-23 19:00     ` [tarantool-patches] " Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180423164741.u4q5ge6iuioyyr23@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [PATCH 8/8] netbox: implement perform_request via async version' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox