diff options
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | external/rcclibtranslate.c | 2 | ||||
-rw-r--r-- | src/rccexternal.c | 20 |
3 files changed, 19 insertions, 5 deletions
@@ -1 +1 @@ -0.2.2 +0.2.3 diff --git a/external/rcclibtranslate.c b/external/rcclibtranslate.c index 7a36814..24f44a2 100644 --- a/external/rcclibtranslate.c +++ b/external/rcclibtranslate.c @@ -166,7 +166,9 @@ void rccLibTranslateFree() { if (session) { if (thread) { exitflag = 1; + g_mutex_lock(mutex); g_cond_signal(cond); + g_mutex_unlock(mutex); g_thread_join(thread); thread = NULL; exitflag = 0; diff --git a/src/rccexternal.c b/src/rccexternal.c index 6a81c56..be9f97d 100644 --- a/src/rccexternal.c +++ b/src/rccexternal.c @@ -79,13 +79,25 @@ int rccExternalInit() { } void rccExternalFree() { + int retry; + pid_t res; + struct timespec timeout = { 0, 5000000 }; + if (pid == (pid_t)-1) return; - - rccExternalConnect(0); - if (addr) free(addr); - waitpid(pid, NULL, 0); + for (retry = 0; retry < 3; retry++) { + rccExternalConnect(0); + + nanosleep(&timeout, NULL); + + res = waitpid(pid, NULL, WNOHANG); + if (res) break; + else timeout.tv_nsec*10; + } + pid = (pid_t)-1; + if (addr) free(addr); + } static int rccExternalSetDeadline(struct timeval *tv, unsigned long timeout) { |