diff options
author | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2003-09-29 12:35:32 +0000 |
---|---|---|
committer | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2003-09-29 12:35:32 +0000 |
commit | 59a0570d52652b80729a10bcaf745739335fa6fb (patch) | |
tree | 9748c8a61fa68e073c782daef6ca971423f88b88 /threadproc | |
parent | a65bfc8da5ef9a10a3f7d842db08d05c371143fa (diff) | |
download | libapr-59a0570d52652b80729a10bcaf745739335fa6fb.tar.gz |
* include/arch/unix/apr_arch_threadproc.h: Store a pthread_attr_t
structure in apr_threadattr_t, rather than a pointer to one.
* threadproc/unix/thread.c (apr_threadattr_create): Use a single
palloc call, omit ENOMEM handling. (apr_threadattr_detach_set,
apr_threadattr_detach_get, apr_thread_create): Adjust use of ->attr
appropriately.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64663 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc')
-rw-r--r-- | threadproc/unix/thread.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/threadproc/unix/thread.c b/threadproc/unix/thread.c index 062b3e930..68a59758c 100644 --- a/threadproc/unix/thread.c +++ b/threadproc/unix/thread.c @@ -58,21 +58,17 @@ #if APR_HAS_THREADS +/* XXX: missing a cleanup, pthread_attr_destroy is never called! */ + #if APR_HAVE_PTHREAD_H APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, apr_pool_t *pool) { apr_status_t stat; - (*new) = (apr_threadattr_t *)apr_pcalloc(pool, sizeof(apr_threadattr_t)); - (*new)->attr = (pthread_attr_t *)apr_pcalloc(pool, sizeof(pthread_attr_t)); - - if ((*new) == NULL || (*new)->attr == NULL) { - return APR_ENOMEM; - } - + (*new) = apr_palloc(pool, sizeof(apr_threadattr_t)); (*new)->pool = pool; - stat = pthread_attr_init((*new)->attr); + stat = pthread_attr_init(&(*new)->attr); if (stat == 0) { return APR_SUCCESS; @@ -91,9 +87,9 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, #ifdef PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR int arg = on; - if ((stat = pthread_attr_setdetachstate(attr->attr, &arg)) == 0) { + if ((stat = pthread_attr_setdetachstate(&attr->attr, &arg)) == 0) { #else - if ((stat = pthread_attr_setdetachstate(attr->attr, on)) == 0) { + if ((stat = pthread_attr_setdetachstate(&attr->attr, on)) == 0) { #endif return APR_SUCCESS; @@ -112,9 +108,9 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) int state; #ifdef PTHREAD_ATTR_GETDETACHSTATE_TAKES_ONE_ARG - state = pthread_attr_getdetachstate(attr->attr); + state = pthread_attr_getdetachstate(&attr->attr); #else - pthread_attr_getdetachstate(attr->attr, &state); + pthread_attr_getdetachstate(&attr->attr, &state); #endif if (state == 1) return APR_DETACH; @@ -153,7 +149,7 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, (*new)->func = func; if (attr) - temp = attr->attr; + temp = &attr->attr; else temp = NULL; |