From 35b724400e504ae6f69a478339e4549475957bb9 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Sun, 6 Sep 2015 13:26:49 +0300 Subject: [PATCH 1/1] Limited waiting for response. --- projects/rlm_stg/iface.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/projects/rlm_stg/iface.cpp b/projects/rlm_stg/iface.cpp index 7394e288..d99dd393 100644 --- a/projects/rlm_stg/iface.cpp +++ b/projects/rlm_stg/iface.cpp @@ -98,10 +98,14 @@ STG_RESULT stgRequest(STG_CLIENT::TYPE type, const char* userName, const char* p response.done = false; client->request(type, toString(userName), toString(password), fromSTGPairs(pairs)); pthread_mutex_lock(&response.mutex); - while (!response.done) - pthread_cond_wait(&response.cond, &response.mutex); + timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += 5; + int res = 0; + while (!response.done && res == 0) + res = pthread_cond_timedwait(&response.cond, &response.mutex, &ts); pthread_mutex_unlock(&response.mutex); - if (!response.status) + if (res != 0 || !response.status) return emptyResult(); return toResult(response.result); } catch (const STG_CLIENT::Error& ex) { -- 2.44.2