From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 2CFBB6EC40; Fri, 13 Aug 2021 13:27:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2CFBB6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628850478; bh=vjPynHTLhUVIeT4mIvjOwodgVYWqnF3U+XjmZ9m7ktM=; h=To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ydjaoBJnXcmwxgHV1SX2nCBQtVcltjNJTp8G97zHw9qXUEP+UeaZN1Hla6PQ6g9LZ qYVux/3aP2S/VlO9Lkzb8bdLdGLge/09d8NaPSyT9RDSyQC+AlONWJQOTqHPKFRatN pmMerH3xNrU7LT0PnkLtwWvQkhXR7EjRMpVucTag= Received: from smtpng2.i.mail.ru (smtpng2.i.mail.ru [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 1FCA96EC40 for ; Fri, 13 Aug 2021 13:27:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1FCA96EC40 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1mEUPq-0005Rc-MQ; Fri, 13 Aug 2021 13:27:55 +0300 To: tarantool-patches@dev.tarantool.org Cc: v.shpilevoy@tarantool.org, yaroslav.dynnikov@tarantool.org Date: Fri, 13 Aug 2021 13:27:52 +0300 Message-Id: <923e00dac8a59e44dc2a87d44385812ea9d38db0.1628850359.git.vdavydov@tarantool.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9BCE6B93DE0C6C3914462CDB1732D383C182A05F53808504002D208E8E565CC3EC7469F9D04DE7655CB9ED2849E97380B95340A3BD939F953 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D78D3A378738F99DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637DAE863916B47044D8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D852E2AFB0C5BF089ACE42AE56E89AF362117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B613439FA09F3DCB32089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C69415AB31670C86C7B21194C2A22BE0FEA6E8C94DC52B43C9C2B6934AE262D3EE7EAB7254005DCED3A96BCF046FC1CF19510FB958DCE06DB6ED91DBE5ABE359A805C47957401F4812272C4C079A4C8AD93EDB24507CE13387DFF0A840B692CF8 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346C409ABC5F9C579BA283C445C1C53F87BA789FC3D1859DB4FEE68F5188175C8C747D2E4D887689D51D7E09C32AA3244CACC9DB53F358DFAFE2BB34CE8A8517513FD9C8CA1B0515E0927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj0dLV0c3jbkzNFvOZQvI3FA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DECB058A6EB23D540A31F60D7C4DF5B1B274CEFED1673C562683ABF942079399BFB559BB5D741EB966A65DFF43FF7BE03240331F90058701C67EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH] net.box: do not yield in future.wait_result(0) X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladimir Davydov via Tarantool-patches Reply-To: Vladimir Davydov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" It didn't yield before commit 954194a1ca5c ("net.box: rewrite request implementation in C"). It shouldn't yield now. Follow-up #6241 --- https://github.com/tarantool/tarantool/tree/vdavydov/netbox-dont-yield-in-future-wait-result-if-timeout-is-0 src/box/lua/net_box.c | 2 ++ test/box/net.box_fiber-async_gh-3107.result | 26 +++++++++++++++++++ test/box/net.box_fiber-async_gh-3107.test.lua | 12 +++++++++ 3 files changed, 40 insertions(+) diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c index 229dec590cf9..43a7d78a1122 100644 --- a/src/box/lua/net_box.c +++ b/src/box/lua/net_box.c @@ -235,6 +235,8 @@ netbox_request_complete(struct netbox_request *request) static inline bool netbox_request_wait(struct netbox_request *request, double *timeout) { + if (*timeout == 0) + return false; double ts = ev_monotonic_now(loop()); int rc = fiber_cond_wait_timeout(&request->cond, *timeout); *timeout -= ev_monotonic_now(loop()) - ts; diff --git a/test/box/net.box_fiber-async_gh-3107.result b/test/box/net.box_fiber-async_gh-3107.result index aaaca351a579..60f084ca3130 100644 --- a/test/box/net.box_fiber-async_gh-3107.result +++ b/test/box/net.box_fiber-async_gh-3107.result @@ -104,6 +104,32 @@ err:find('Usage') ~= nil --- - true ... +-- +-- Check that wait_result(0) doesn't yield. +-- +future = c:call('long_function', {1, 2, 3}, {is_async = true}) +--- +... +csw1 = fiber.info()[fiber.id()].csw \ +ret = future:wait_result(0) \ +csw2 = fiber.info()[fiber.id()].csw +--- +... +ret -- timeout +--- +- null +... +csw2 - csw1 -- 0 +--- +- 0 +... +finalize_long() +--- +... +future:wait_result() +--- +- [1, 2, 3] +... box.schema.func.drop('long_function') --- ... diff --git a/test/box/net.box_fiber-async_gh-3107.test.lua b/test/box/net.box_fiber-async_gh-3107.test.lua index d23f368cbce4..9632e9228bbb 100644 --- a/test/box/net.box_fiber-async_gh-3107.test.lua +++ b/test/box/net.box_fiber-async_gh-3107.test.lua @@ -36,6 +36,18 @@ err:find('Usage') ~= nil _, err = pcall(future.wait_result, future, '100') err:find('Usage') ~= nil +-- +-- Check that wait_result(0) doesn't yield. +-- +future = c:call('long_function', {1, 2, 3}, {is_async = true}) +csw1 = fiber.info()[fiber.id()].csw \ +ret = future:wait_result(0) \ +csw2 = fiber.info()[fiber.id()].csw +ret -- timeout +csw2 - csw1 -- 0 +finalize_long() +future:wait_result() + box.schema.func.drop('long_function') c:close() -- 2.25.1