<div dir="ltr"><div>Thanks for your patch. LGTM.<br></div><br><div><div><div><div dir="ltr" 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></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 13 Aug 2021 at 13:27, Vladimir Davydov <<a href="mailto:vdavydov@tarantool.org" target="_blank">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>
src/box/lua/net_box.c | 2 ++<br>
test/box/net.box_fiber-async_gh-3107.result | 26 +++++++++++++++++++<br>
test/box/net.box_fiber-async_gh-3107.test.lua | 12 +++++++++<br>
3 files changed, 40 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..60f084ca3130 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,32 @@ err:find('Usage') ~= nil<br>
---<br>
- true<br>
...<br>
+--<br>
+-- Check that wait_result(0) doesn't yield.<br>
+--<br>
+future = c:call('long_function', {1, 2, 3}, {is_async = true})<br>
+---<br>
+...<br>
+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>
+ret = future:wait_result(0) \<br>
+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>
+---<br>
+...<br>
+ret -- timeout<br>
+---<br>
+- null<br>
+...<br>
+csw2 - csw1 -- 0<br>
+---<br>
+- 0<br>
+...<br>
+finalize_long()<br>
+---<br>
+...<br>
+future:wait_result()<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..9632e9228bbb 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,18 @@ err:find('Usage') ~= nil<br>
_, err = pcall(future.wait_result, future, '100')<br>
err:find('Usage') ~= nil<br>
<br>
+--<br>
+-- Check that wait_result(0) doesn't yield.<br>
+--<br>
+future = c:call('long_function', {1, 2, 3}, {is_async = true})<br>
+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>
+ret = future:wait_result(0) \<br>
+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>
+ret -- timeout<br>
+csw2 - csw1 -- 0<br>
+finalize_long()<br>
+future:wait_result()<br>
+<br>
box.schema.func.drop('long_function')<br>
<br>
c:close()<br>
-- <br>
2.25.1<br>
<br>
</blockquote></div>