diff options
author | Zeev Suraski <zeev@php.net> | 2000-06-16 14:38:05 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2000-06-16 14:38:05 +0000 |
commit | 33f94999756591d98d9061105496e7255e4f43da (patch) | |
tree | 14cb5197b1077545d1ef51bb772de1b614cb92c1 /TSRM | |
parent | 84eb48f0a1fd0a8be0f09ad3b77697922d2b5bfb (diff) | |
download | php-git-33f94999756591d98d9061105496e7255e4f43da.tar.gz |
Make it possible to access other threads' local storage. Only use it if you have a clear
knowledge of what you're doing!
Diffstat (limited to 'TSRM')
-rw-r--r-- | TSRM/TSRM.c | 9 | ||||
-rw-r--r-- | TSRM/TSRM.h | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index b95384b9e3..f1fdd3a85e 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -206,13 +206,18 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_ /* fetches the requested resource for the current thread */ -void *ts_resource(ts_rsrc_id id) +void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id) { - THREAD_T thread_id = tsrm_thread_id(); + THREAD_T thread_id; int hash_value; tsrm_tls_entry *thread_resources; void *resource; + if (th_id) { + thread_id = *th_id; + } else { + thread_id = tsrm_thread_id(); + } tsrm_debug("Fetching resource id %d for thread %ld\n", id, (long) thread_id); tsrm_mutex_lock(tsmm_mutex); diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index 4d2a2c2595..86e51a793f 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -81,7 +81,8 @@ TSRM_API void tsrm_shutdown(void); TSRM_API ts_rsrc_id ts_allocate_id(size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor); /* fetches the requested resource for the current thread */ -TSRM_API void *ts_resource(ts_rsrc_id id); +TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id); +#define ts_resource(id) ts_resource_ex(id, NULL) /* frees all resources allocated for the current thread */ TSRM_API void ts_free_thread(void); |