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 3879C6EC40; Fri, 13 Aug 2021 15:14:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3879C6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628856893; bh=B3y98Rz/knYVx8NQeU4PlrWHxBJQytgg8mPE/OkEG/U=; h=To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=qdxhEk8VUGuXlu64WrgRVJXjAz/x14AcHNuCoa6ZWZ5+PQmk2xeoBewsPjkEXr8D6 ri4OcUP6Cqka4/nW6YFrCLnc1m9gGzPr2RUqu+T5hHaMlHj/XznApS623QwSk2dXne QLQGaB+rf1wvGZVspAaHj2z2XB4ePzL8UjV1a1SI= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 6587F6EC40 for ; Fri, 13 Aug 2021 15:14:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6587F6EC40 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mEW5L-0007K2-CP; Fri, 13 Aug 2021 15:14:51 +0300 To: tarantool-patches@dev.tarantool.org Cc: v.shpilevoy@tarantool.org, yaroslav.dynnikov@tarantool.org Date: Fri, 13 Aug 2021 15:14:51 +0300 Message-Id: <7b986fe9f451e1211b97d564ad6ed2ced048997f.1628856798.git.vdavydov@tarantool.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <923e00dac8a59e44dc2a87d44385812ea9d38db0.1628850359.git.vdavydov@tarantool.org> References: <923e00dac8a59e44dc2a87d44385812ea9d38db0.1628850359.git.vdavydov@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD906AB4890CDABF0C5CB76CEE71D3E4007182A05F5380850408580B8FDD25E916898B51C29EA79123A09C39C8A3ECDACACF1CF934CAA1CF663 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D4EF26BAC91EEE7FEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F0D8FAB78312C5B48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8CF9D7499647193B8234241CDCC53BC0F117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18C26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B613439FA09F3DCB32089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C69415AB31670C86C4A9CB9903A464B061475B0DD92CF3A5F9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF3A74CE74F45F2162699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3488E5CD2E691F556678BE25D5353BC855A13F994DD4C528F41694D0D61AE28EBE9D30DE4DF020C1B31D7E09C32AA3244CEEA37DE43644E9649C53032D50C4969F51E887DA02A9F7BF927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj0dLV0c3jbkww6Ssj5A8ZhA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D989C9E85F06D1120DDEFB9FC2CDDD3F0274CEFED1673C562683ABF942079399BFB559BB5D741EB966A65DFF43FF7BE03240331F90058701C67EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2] 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 Changes in v2: - Improved test. src/box/lua/net_box.c | 2 + test/box/net.box_fiber-async_gh-3107.result | 48 +++++++++++++++++++ test/box/net.box_fiber-async_gh-3107.test.lua | 20 ++++++++ 3 files changed, 70 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..ec2fd4f6441a 100644 --- a/test/box/net.box_fiber-async_gh-3107.result +++ b/test/box/net.box_fiber-async_gh-3107.result @@ -104,6 +104,54 @@ err:find('Usage') ~= nil --- - true ... +-- +-- Check that there's no unexpected yields. +-- +function assert_no_csw(func, ...) \ + local csw1 = fiber.info()[fiber.id()].csw \ + local ret = {func(...)} \ + local csw2 = fiber.info()[fiber.id()].csw \ + assert(csw2 - csw1 == 0) \ + return unpack(ret) \ +end +--- +... +future = c:call('long_function', {1, 2, 3}, {is_async = true}) +--- +... +assert_no_csw(future.is_ready, future) +--- +- false +... +assert_no_csw(future.result, future) +--- +- null +- Response is not ready +... +assert_no_csw(future.wait_result, future, 0) +--- +- null +- Timeout exceeded +... +finalize_long() +--- +... +future:wait_result() +--- +- [1, 2, 3] +... +assert_no_csw(future.is_ready, future) +--- +- true +... +assert_no_csw(future.result, future) +--- +- [1, 2, 3] +... +assert_no_csw(future.wait_result, future) +--- +- [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..71ba50b62ccb 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,26 @@ err:find('Usage') ~= nil _, err = pcall(future.wait_result, future, '100') err:find('Usage') ~= nil +-- +-- Check that there's no unexpected yields. +-- +function assert_no_csw(func, ...) \ + local csw1 = fiber.info()[fiber.id()].csw \ + local ret = {func(...)} \ + local csw2 = fiber.info()[fiber.id()].csw \ + assert(csw2 - csw1 == 0) \ + return unpack(ret) \ +end +future = c:call('long_function', {1, 2, 3}, {is_async = true}) +assert_no_csw(future.is_ready, future) +assert_no_csw(future.result, future) +assert_no_csw(future.wait_result, future, 0) +finalize_long() +future:wait_result() +assert_no_csw(future.is_ready, future) +assert_no_csw(future.result, future) +assert_no_csw(future.wait_result, future) + box.schema.func.drop('long_function') c:close() -- 2.25.1