Skip to contentSkip to conversation

master - dmeventd: wake up timer when setting new timeout

PATCH Zdenek Kabelac 1 participant 1 message Oct 22, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=941c6354dbf783da17851be7e38f243334a4acd6
Commit:        941c6354dbf783da17851be7e38f243334a4acd6
Parent:        02eb000f5145aa60578b4591053bff9a797e64cc
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu Oct 22 12:37:18 2015 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Thu Oct 22 22:34:29 2015 +0200

dmeventd: wake up timer when setting new timeout

---
 daemons/dmeventd/dmeventd.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
daemons/dmeventd/dmeventd.c +12 -3
index 885aa9d..bbdee82 100644
@@ -1274,11 +1274,20 @@ static int _set_timeout(struct message_data *message_data)
 	struct thread_status *thread;
 
 	_lock_mutex();
-	if ((thread = _lookup_thread_status(message_data)))
-		thread->timeout = message_data->timeout_secs;
+	thread = _lookup_thread_status(message_data);
 	_unlock_mutex();
 
-	return thread ? 0 : -ENODEV;
+	if (!thread)
+		return -ENODEV;
+
+	/* Lets reprogram timer */
+	pthread_mutex_lock(&_timeout_mutex);
+	thread->timeout = message_data->timeout_secs;
+	thread->next_time = 0;
+	pthread_cond_signal(&_timeout_cond);
+	pthread_mutex_unlock(&_timeout_mutex);
+
+	return 0;
 }
 
 static int _get_timeout(struct message_data *message_data)