From 4bfe2ec686ffd04f6df62ab4bafc83e48f2d4d33 Mon Sep 17 00:00:00 2001 From: somdoron Date: Mon, 18 Jan 2016 15:30:07 +0200 Subject: [PATCH] fix bug in condition variable using invalid timeout --- src/condition_variable.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/condition_variable.hpp b/src/condition_variable.hpp index 4e20b401..7e2ad89b 100644 --- a/src/condition_variable.hpp +++ b/src/condition_variable.hpp @@ -164,6 +164,12 @@ namespace zmq timeout.tv_sec += timeout_ / 1000; timeout.tv_nsec += (timeout_ % 1000) * 1000000; + + if (timeout.tv_nsec > 1E9) { + timeout.tv_sec++; + timeout.tv_nsec -= 1E9; + } + rc = pthread_cond_timedwait (&cond, mutex_->get_mutex (), &timeout); } else