<div dir="ltr"><div>That's even better, still LGTM.</div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span><div><div dir="ltr">Best regards</div><div>Yaroslav Dynnikov<br></div></div></span></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 13 Aug 2021 at 15:14, Vladimir Davydov <<a href="mailto:vdavydov@tarantool.org">vdavydov@tarantool.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">It didn't yield before commit 954194a1ca5c ("net.box: rewrite request<br>
implementation in C"). It shouldn't yield now.<br>
<br>
Follow-up #6241<br>
---<br>
<a href="https://github.com/tarantool/tarantool/tree/vdavydov/netbox-dont-yield-in-future-wait-result-if-timeout-is-0" rel="noreferrer" target="_blank">https://github.com/tarantool/tarantool/tree/vdavydov/netbox-dont-yield-in-future-wait-result-if-timeout-is-0</a><br>
<br>
Changes in v2:<br>
 - Improved test.<br>
<br>
 src/box/lua/net_box.c                         |  2 +<br>
 test/box/net.box_fiber-async_gh-3107.result   | 48 +++++++++++++++++++<br>
 test/box/net.box_fiber-async_gh-3107.test.lua | 20 ++++++++<br>
 3 files changed, 70 insertions(+)<br>
<br>
diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c<br>
index 229dec590cf9..43a7d78a1122 100644<br>
--- a/src/box/lua/net_box.c<br>
+++ b/src/box/lua/net_box.c<br>
@@ -235,6 +235,8 @@ netbox_request_complete(struct netbox_request *request)<br>
 static inline bool<br>
 netbox_request_wait(struct netbox_request *request, double *timeout)<br>
 {<br>
+       if (*timeout == 0)<br>
+               return false;<br>
        double ts = ev_monotonic_now(loop());<br>
        int rc = fiber_cond_wait_timeout(&request->cond, *timeout);<br>
        *timeout -= ev_monotonic_now(loop()) - ts;<br>
diff --git a/test/box/net.box_fiber-async_gh-3107.result b/test/box/net.box_fiber-async_gh-3107.result<br>
index aaaca351a579..ec2fd4f6441a 100644<br>
--- a/test/box/net.box_fiber-async_gh-3107.result<br>
+++ b/test/box/net.box_fiber-async_gh-3107.result<br>
@@ -104,6 +104,54 @@ err:find('Usage') ~= nil<br>
 ---<br>
 - true<br>
 ...<br>
+--<br>
+-- Check that there's no unexpected yields.<br>
+--<br>
+function assert_no_csw(func, ...)               \<br>
+    local csw1 = <a href="http://fiber.info" rel="noreferrer" target="_blank">fiber.info</a>()[<a href="http://fiber.id" rel="noreferrer" target="_blank">fiber.id</a>()].csw   \<br>
+    local ret = {func(...)}                     \<br>
+    local csw2 = <a href="http://fiber.info" rel="noreferrer" target="_blank">fiber.info</a>()[<a href="http://fiber.id" rel="noreferrer" target="_blank">fiber.id</a>()].csw   \<br>
+    assert(csw2 - csw1 == 0)                    \<br>
+    return unpack(ret)                          \<br>
+end<br>
+---<br>
+...<br>
+future = c:call('long_function', {1, 2, 3}, {is_async = true})<br>
+---<br>
+...<br>
+assert_no_csw(future.is_ready, future)<br>
+---<br>
+- false<br>
+...<br>
+assert_no_csw(future.result, future)<br>
+---<br>
+- null<br>
+- Response is not ready<br>
+...<br>
+assert_no_csw(future.wait_result, future, 0)<br>
+---<br>
+- null<br>
+- Timeout exceeded<br>
+...<br>
+finalize_long()<br>
+---<br>
+...<br>
+future:wait_result()<br>
+---<br>
+- [1, 2, 3]<br>
+...<br>
+assert_no_csw(future.is_ready, future)<br>
+---<br>
+- true<br>
+...<br>
+assert_no_csw(future.result, future)<br>
+---<br>
+- [1, 2, 3]<br>
+...<br>
+assert_no_csw(future.wait_result, future)<br>
+---<br>
+- [1, 2, 3]<br>
+...<br>
 box.schema.func.drop('long_function')<br>
 ---<br>
 ...<br>
diff --git a/test/box/net.box_fiber-async_gh-3107.test.lua b/test/box/net.box_fiber-async_gh-3107.test.lua<br>
index d23f368cbce4..71ba50b62ccb 100644<br>
--- a/test/box/net.box_fiber-async_gh-3107.test.lua<br>
+++ b/test/box/net.box_fiber-async_gh-3107.test.lua<br>
@@ -36,6 +36,26 @@ err:find('Usage') ~= nil<br>
 _, err = pcall(future.wait_result, future, '100')<br>
 err:find('Usage') ~= nil<br>
<br>
+--<br>
+-- Check that there's no unexpected yields.<br>
+--<br>
+function assert_no_csw(func, ...)               \<br>
+    local csw1 = <a href="http://fiber.info" rel="noreferrer" target="_blank">fiber.info</a>()[<a href="http://fiber.id" rel="noreferrer" target="_blank">fiber.id</a>()].csw   \<br>
+    local ret = {func(...)}                     \<br>
+    local csw2 = <a href="http://fiber.info" rel="noreferrer" target="_blank">fiber.info</a>()[<a href="http://fiber.id" rel="noreferrer" target="_blank">fiber.id</a>()].csw   \<br>
+    assert(csw2 - csw1 == 0)                    \<br>
+    return unpack(ret)                          \<br>
+end<br>
+future = c:call('long_function', {1, 2, 3}, {is_async = true})<br>
+assert_no_csw(future.is_ready, future)<br>
+assert_no_csw(future.result, future)<br>
+assert_no_csw(future.wait_result, future, 0)<br>
+finalize_long()<br>
+future:wait_result()<br>
+assert_no_csw(future.is_ready, future)<br>
+assert_no_csw(future.result, future)<br>
+assert_no_csw(future.wait_result, future)<br>
+<br>
 box.schema.func.drop('long_function')<br>
<br>
 c:close()<br>
-- <br>
2.25.1<br>
<br>
</blockquote></div>