diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2006-01-09 21:30:43 +0000 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2006-01-09 21:30:43 +0000 |
commit | d480558fe8a2de12be4fcd9a1bdd1b71c233787b (patch) | |
tree | 78f730b1e865dc1b0d53e005bfe03cf834abeae3 | |
parent | 690b7da850a2a241ca220b21938ec114c919d87b (diff) | |
download | librcc-d480558fe8a2de12be4fcd9a1bdd1b71c233787b.tar.gz librcc-d480558fe8a2de12be4fcd9a1bdd1b71c233787b.tar.bz2 librcc-d480558fe8a2de12be4fcd9a1bdd1b71c233787b.tar.xz librcc-d480558fe8a2de12be4fcd9a1bdd1b71c233787b.zip |
Fixed lockup on exit
- Fixed lockup on exit (Waiting rccexternal exit forever)
-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) { |