summaryrefslogtreecommitdiff
path: root/threadproc/netware/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'threadproc/netware/thread.c')
-rw-r--r--threadproc/netware/thread.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/threadproc/netware/thread.c b/threadproc/netware/thread.c
index 34a5691f5..a661ef886 100644
--- a/threadproc/netware/thread.c
+++ b/threadproc/netware/thread.c
@@ -87,12 +87,8 @@ apr_status_t apr_thread_create(apr_thread_t **new,
unsigned long flags = NX_THR_BIND_CONTEXT;
size_t stack_size = APR_DEFAULT_STACK_SIZE;
apr_allocator_t *allocator;
+ apr_pool_t *p;
- (*new) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t));
- if ((*new) == NULL) {
- return APR_ENOMEM;
- }
-
/* The thread can be detached anytime (from the creation or later with
* apr_thread_detach), so it needs its own pool and allocator to not
* depend on a parent pool which could be destroyed before the thread
@@ -103,29 +99,35 @@ apr_status_t apr_thread_create(apr_thread_t **new,
if (stat != APR_SUCCESS) {
return stat;
}
- stat = apr_pool_create_unmanaged_ex(&(*new)->pool,
- apr_pool_abort_get(pool),
+ stat = apr_pool_create_unmanaged_ex(&p, apr_pool_abort_get(pool),
allocator);
if (stat != APR_SUCCESS) {
apr_allocator_destroy(allocator);
return stat;
}
- apr_allocator_owner_set(allocator, (*new)->pool);
+ apr_allocator_owner_set(allocator, p);
+
+ (*new) = (apr_thread_t *)apr_pcalloc(p, sizeof(apr_thread_t));
+ if ((*new) == NULL) {
+ apr_pool_destroy(p);
+ return APR_ENOMEM;
+ }
+ (*new)->pool = p;
(*new)->data = data;
(*new)->func = func;
(*new)->exitval = -1;
(*new)->detached = (attr && apr_threadattr_detach_get(attr) == APR_DETACH);
if (attr && attr->thread_name) {
- (*new)->thread_name = apr_pstrndup(pool, ttr->thread_name,
+ (*new)->thread_name = apr_pstrndup(p, ttr->thread_name,
NX_MAX_OBJECT_NAME_LEN);
}
else {
- (*new)->thread_name = apr_psprintf(pool, "APR_thread %04d",
+ (*new)->thread_name = apr_psprintf(p, "APR_thread %04d",
++thread_count);
}
if ((*new)->thread_name == NULL) {
- apr_pool_destroy((*new)->pool);
+ apr_pool_destroy(p);
return APR_ENOMEM;
}
@@ -160,7 +162,7 @@ apr_status_t apr_thread_create(apr_thread_t **new,
/* NXThreadId_t *thread_id */ &(*new)->td);
if (stat) {
- apr_pool_destroy((*new)->pool);
+ apr_pool_destroy(p);
return stat;
}