From 187fe61700fc97fff565ec53aac65c664042feae Mon Sep 17 00:00:00 2001 From: Gediminas Jakutis Date: Wed, 29 May 2019 13:03:49 +0300 Subject: daemon: get ready to use messaging interfaces. Signed-off-by: Gediminas Jakutis --- src/daemon/purple.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/daemon/purple.c') diff --git a/src/daemon/purple.c b/src/daemon/purple.c index 882ea61..e004448 100644 --- a/src/daemon/purple.c +++ b/src/daemon/purple.c @@ -246,9 +246,14 @@ int purple_init(void) void purple_close(void) { + int status; - if (pthread_mutex_trylock(&state.mutex) == EBUSY) { + status = pthread_mutex_trylock(&state.mutex); + + if (status == EBUSY) { pthread_cancel(state.purple); pthread_join(state.purple, NULL); + } else if (!status) { + pthread_mutex_unlock(&state.mutex); } } -- cgit v1.2.3