shib-threads.{h,cpp}:
authorwarlord <warlord@cb58f699-b61c-0410-a6fe-9272a202ed29>
Thu, 30 Jan 2003 15:18:36 +0000 (15:18 +0000)
committerwarlord <warlord@cb58f699-b61c-0410-a6fe-9272a202ed29>
Thu, 30 Jan 2003 15:18:36 +0000 (15:18 +0000)
added Thread::mask_signal() function to mask around pthread_sigmask()
(couldn't call it sigmask() because that's a macro)

shar-utils.cpp:
shib-ccache.cpp:
block all signals in children threads, to make sure they don't
(improperly) handle signals, such as at SHAR Shutdown.

git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@257 cb58f699-b61c-0410-a6fe-9272a202ed29

shar/shar-utils.cpp
shib-target/shib-ccache.cpp
shib-target/shib-threads.cpp
shib-target/shib-threads.h

index e6b4eae..edb81cb 100644 (file)
@@ -50,7 +50,16 @@ void*
 shar_client_thread (void* arg)
 {
   SharChild* child = (SharChild*)arg;
+
+  // First, let's block all signals
+  sigset_t sigmask;
+  sigfillset(&sigmask);
+  Thread::mask_signals(SIG_BLOCK, &sigmask, NULL);
+
+  // the run the child until they exit.
   child->run();
+
+  // now we can clean up and exit the thread.
   delete child;
   return NULL;
 }
index e589ca7..e7b30d2 100644 (file)
@@ -328,6 +328,13 @@ void InternalCCache::cleanup()
 void* InternalCCache::cleanup_fcn(void* cache_p)
 {
   InternalCCache* cache = (InternalCCache*)cache_p;
+
+  // First, let's block all signals
+  sigset_t sigmask;
+  sigfillset(&sigmask);
+  Thread::mask_signals(SIG_BLOCK, &sigmask, NULL);
+
+  // Now run the cleanup process.
   cache->cleanup();
 }
 
index 3b665c3..fbec9c6 100644 (file)
@@ -141,6 +141,11 @@ void Thread::exit(void* return_val)
   pthread_exit (return_val);
 }
     
+int Thread::mask_signals(int how, const sigset_t *newmask, sigset_t *oldmask)
+{
+  return pthread_sigmask(how,newmask,oldmask);
+}
+
 Mutex * Mutex::create()
 {
   return new MutexImpl();
index 5e0855a..bed8ca8 100644 (file)
@@ -12,6 +12,7 @@
 #ifdef __cplusplus
 
 #include <time.h>
+#include <signal.h>
 
 namespace shibtarget {
 
@@ -23,6 +24,7 @@ namespace shibtarget {
   public:
     static Thread* create(void* (*start_routine)(void*), void* arg);
     static void exit(void* return_val);
+    static int mask_signals(int how, const sigset_t *newmask, sigset_t *oldmask);
 
     virtual int detach() = 0;
     virtual int join(void** thread_return) = 0;