[Tarantool-patches] [PATCH 4/4] qsync: don't send negative timeouts into fiber_cond_wait_timeout

Cyrill Gorcunov gorcunov at gmail.com
Tue Jul 14 17:44:40 MSK 2020


Basically our timeout is calculated via (a - b), where
@a is a constant positive value fetched once, in turn
the @b is rather a dynamic value thus the result may
be negative. libev uses assert() call to catch such
values when passed to timers setup. Thus lets intercept
potential assert() trigger and exit early if timeout
is already expired.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 src/box/txn_limbo.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c
index d5b887d36..3ed0b6db5 100644
--- a/src/box/txn_limbo.c
+++ b/src/box/txn_limbo.c
@@ -176,6 +176,8 @@ txn_limbo_wait_complete(struct txn_limbo *limbo, struct txn_limbo_entry *entry)
 		double deadline = start_time + replication_synchro_timeout;
 		bool cancellable = fiber_set_cancellable(false);
 		double timeout = deadline - fiber_clock();
+		if (timeout < 0)
+			goto do_rollback;
 		int rc = fiber_cond_wait_timeout(&limbo->wait_cond, timeout);
 		fiber_set_cancellable(cancellable);
 		if (txn_limbo_entry_is_complete(entry))
@@ -511,6 +513,8 @@ txn_limbo_wait_confirm(struct txn_limbo *limbo)
 		double deadline = start_time + replication_synchro_timeout;
 		bool cancellable = fiber_set_cancellable(false);
 		double timeout = deadline - fiber_clock();
+		if (timeout < 0)
+			goto timed_out;
 		int rc = fiber_cond_wait_timeout(&limbo->wait_cond, timeout);
 		fiber_set_cancellable(cancellable);
 		if (cwp.is_confirm || cwp.is_rollback)
-- 
2.26.2



More information about the Tarantool-patches mailing list