diff options
author | davidxu <davidxu@FreeBSD.org> | 2005-10-30 23:59:01 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2005-10-30 23:59:01 +0000 |
commit | 363ab5c5662f36c68f5120d8974cbc31004815b0 (patch) | |
tree | 01f1b99189e13c89095bfda8c94891daaf7a71e6 | |
parent | 7d06f79e600999d829bd8331f5e724190cf0bc42 (diff) | |
download | FreeBSD-src-363ab5c5662f36c68f5120d8974cbc31004815b0.zip FreeBSD-src-363ab5c5662f36c68f5120d8974cbc31004815b0.tar.gz |
Add thread exit handler in timer_loop to handle broken buggy code which
could lead to memory leak.
-rw-r--r-- | lib/libthr/thread/thr_timer.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libthr/thread/thr_timer.c b/lib/libthr/thread/thr_timer.c index fa3b893..c3f5ed5 100644 --- a/lib/libthr/thread/thr_timer.c +++ b/lib/libthr/thread/thr_timer.c @@ -107,7 +107,7 @@ __timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid) SIGEMPTYSET(set); SIGADDSET(set, tmr->signo); __sys_sigprocmask(SIG_BLOCK, &set, &oset); - ret = pthread_create(&newtd, &attr, timer_loop, tmr); + ret = _pthread_create(&newtd, &attr, timer_loop, tmr); __sys_sigprocmask(SIG_SETMASK, &oset, NULL); pthread_attr_destroy(&attr); if (__predict_false(ret != 0)) { @@ -152,6 +152,7 @@ timer_loop(void *arg) siginfo_t si; sigset_t set; + THR_CLEANUP_PUSH(curthread, free, tmr); THR_UMTX_LOCK(curthread, &tmr->lock); THR_UMTX_UNLOCK(curthread, &tmr->lock); SIGEMPTYSET(set); @@ -163,6 +164,7 @@ timer_loop(void *arg) tmr->function(&tmr->value); } } + THR_CLEANUP_POP(curthread, 0); free(tmr); return (0); } |