summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-21 15:28:26 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-21 15:28:26 +0000
commitad09fe13921b6f7f9622ac380e1c7353b8128895 (patch)
treea9f2015b806025ddee9e81e362dd462214bc1722
parent97725b5957fc9da35fdd9d2e2c657640d001cde0 (diff)
downloadATCD-ad09fe13921b6f7f9622ac380e1c7353b8128895.tar.gz
ChangeLogTag: Wed Jul 21 10:25:07 1999 David L. Levine <levine@cs.wustl.edu>
-rw-r--r--ChangeLog-99b12
-rw-r--r--ace/OS.cpp62
-rw-r--r--ace/OS.h13
3 files changed, 56 insertions, 31 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b
index e51453750b1..3606a8e6b82 100644
--- a/ChangeLog-99b
+++ b/ChangeLog-99b
@@ -1,3 +1,15 @@
+Wed Jul 21 10:25:07 1999 David L. Levine <levine@cs.wustl.edu>
+
+ * ace/OS.{h,cpp} (tss_base,tss_open): with TSS emulation,
+ no longer return indication of whether tss_base allocated
+ the ts_storage array. Instead, added an (optional)
+ argument that tss_open can use for that purpose. This
+ allows threads that haven't been spawned by ACE to use
+ ACE's TSS emulation. Thanks to David Hauck
+ <davidh@realtimeint.com> for reporting this and testing
+ the fix on NT. And, thanks to Terry Rosenbaum
+ <Terry.Rosenbaum@Radiology.MSU.edu> for originally reporting it.
+
Wed Jul 21 09:34:09 1999 David L. Levine <levine@cs.wustl.edu>
* examples/Shared_Malloc/test_position_independent_malloc.cpp (main):
diff --git a/ace/OS.cpp b/ace/OS.cpp
index 6421099b8fb..3f502f9edf0 100644
--- a/ace/OS.cpp
+++ b/ace/OS.cpp
@@ -2010,7 +2010,7 @@ ACE_TSS_Emulation_cleanup (void *ptr)
}
void **
-ACE_TSS_Emulation::tss_base (void* ts_storage[])
+ACE_TSS_Emulation::tss_base (void* ts_storage[], u_int *ts_created)
{
// TSS Singleton implementation.
@@ -2025,9 +2025,9 @@ ACE_TSS_Emulation::tss_base (void* ts_storage[])
ACE_NO_HEAP_CHECK;
if (ACE_OS::thr_keycreate (&native_tss_key_,
&ACE_TSS_Emulation_cleanup) != 0)
- {
+ {
return 0; // Major problems, this should *never* happen!
- }
+ }
key_created_ = 1;
}
}
@@ -2044,39 +2044,45 @@ ACE_TSS_Emulation::tss_base (void* ts_storage[])
// at least on Pthreads Draft 4 platforms.
if (old_ts_storage == 0)
{
+ if (ts_created)
+ *ts_created = 1u;
+
// Use the ts_storage passed as argument, if non-zero. It is
// possible that this has been implemented in the stack. At the
// moment, this is unknown. The cleanup must not do nothing.
// If ts_storage is zero, allocate (and eventually leak) the
// storage array.
if (ts_storage == 0)
- {
- ACE_NO_HEAP_CHECK;
+ {
+ ACE_NO_HEAP_CHECK;
- ACE_NEW_RETURN (ts_storage,
- void*[ACE_TSS_THREAD_KEYS_MAX],
- 0);
+ ACE_NEW_RETURN (ts_storage,
+ void*[ACE_TSS_THREAD_KEYS_MAX],
+ 0);
- // Zero the entire TSS array. Do it manually instead of using
- // memset, for optimum speed. Though, memset may be faster
- // :-)
- void **tss_base_p = ts_storage;
+ // Zero the entire TSS array. Do it manually instead of
+ // using memset, for optimum speed. Though, memset may be
+ // faster :-)
+ void **tss_base_p = ts_storage;
- for (u_int i = 0;
- i < ACE_TSS_THREAD_KEYS_MAX;
- ++i)
- *tss_base_p++ = 0;
- }
+ for (u_int i = 0;
+ i < ACE_TSS_THREAD_KEYS_MAX;
+ ++i)
+ *tss_base_p++ = 0;
+ }
- // Store the pointer in thread-specific storage. It gets deleted
- // via the ACE_TSS_Emulation_cleanup function when the thread
- // terminates.
- if (ACE_OS::thr_setspecific (native_tss_key_,
- (void *) ts_storage) != 0)
+ // Store the pointer in thread-specific storage. It gets
+ // deleted via the ACE_TSS_Emulation_cleanup function when the
+ // thread terminates.
+ if (ACE_OS::thr_setspecific (native_tss_key_,
+ (void *) ts_storage) != 0)
return 0; // Major problems, this should *never* happen!
}
+ else
+ if (ts_created)
+ ts_created = 0;
- return old_ts_storage;
+ return ts_storage ? ts_storage : old_ts_storage;
}
#endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
@@ -2131,9 +2137,9 @@ ACE_TSS_Emulation::tss_open (void *ts_storage[ACE_TSS_THREAD_KEYS_MAX])
// Zero the entire TSS array.
void **tss_base_p = ts_storage;
for (u_int i = 0; i < ACE_TSS_THREAD_KEYS_MAX; ++i, ++tss_base_p)
- {
- *tss_base_p = 0;
- }
+ {
+ *tss_base_p = 0;
+ }
return (void *) tss_base;
# else /* ! ACE_PSOS */
@@ -2143,7 +2149,9 @@ ACE_TSS_Emulation::tss_open (void *ts_storage[ACE_TSS_THREAD_KEYS_MAX])
// directly by the shell (without spawning a new task) after
// another program has been run.
- if (tss_base (ts_storage) == 0)
+ u_int ts_created = 0;
+ tss_base (ts_storage, &ts_created);
+ if (ts_created)
{
# else /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */
tss_base () = ts_storage;
diff --git a/ace/OS.h b/ace/OS.h
index fc84499bb9e..f4fe8250faf 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -6820,9 +6820,14 @@ public:
// Does _not_ check for a valid key.
static void *tss_open (void *ts_storage[ACE_TSS_THREAD_KEYS_MAX]);
- // Setup an array to be used for local TSS. Returns the array address on
- // success. Returns 0 if local TSS had already been setup for this thread.
- // There is no corresponding tss_close () because it is not needed.
+ // Setup an array to be used for local TSS. Returns the array
+ // address on success. Returns 0 if local TSS had already been
+ // setup for this thread. There is no corresponding tss_close ()
+ // because it is not needed.
+ // NOTE: tss_open () is called by ACE for threads that it spawns.
+ // If your application spawns threads without using ACE, and it uses
+ // ACE's TSS emulation, each of those threads should call tss_open
+ // (). See the ace_thread_adapter () implementaiton for an example.
static void tss_close ();
// Shutdown TSS emulation. For use only by ACE_OS::cleanup_tss ().
@@ -6837,7 +6842,7 @@ private:
// key (that has one) when the thread exits.
# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
- static void **tss_base (void* ts_storage[] = 0);
+ static void **tss_base (void* ts_storage[] = 0, u_int *ts_created = 0);
// Location of current thread's TSS array.
# else /* ! ACE_HAS_THREAD_SPECIFIC_STORAGE */
static void **&tss_base ();