[shibboleth-sp2] 47/100: Implemented a socket/thread map to insure one thread per socket.

Ferenc Wágner wferi-guest at moszumanska.debian.org
Tue Jan 26 21:29:16 UTC 2016


This is an automated email from the git hooks/post-receive script.

wferi-guest pushed a commit to annotated tag 1.2.1
in repository shibboleth-sp2.

commit 74aad3fc08da9ea1864594fcc19f62b34e5cf060
Author: Scott Cantor <cantor.2 at osu.edu>
Date:   Tue Oct 19 00:59:31 2004 +0000

    Implemented a socket/thread map to insure one thread per socket.
---
 shar/shar-utils.cpp | 29 +++++++++++------------------
 shar/shar-utils.h   |  1 -
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/shar/shar-utils.cpp b/shar/shar-utils.cpp
index d10a35a..02d55c1 100644
--- a/shar/shar-utils.cpp
+++ b/shar/shar-utils.cpp
@@ -42,7 +42,7 @@ using namespace shibtarget;
 using namespace log4cpp;
 
 namespace {
-  map<Thread*,int> children;
+  map<IListener::ShibSocket,Thread*> children;
   Mutex* 	child_lock = NULL;
   CondWait*	child_wait = NULL;
   bool		running;
@@ -67,43 +67,37 @@ void* shar_client_thread (void* arg)
   return NULL;
 }
 
-SharChild::SharChild(IListener::ShibSocket& s, const Iterator<ShibRPCProtocols>& protos) : sock(s), lock(NULL), child(NULL)
+SharChild::SharChild(IListener::ShibSocket& s, const Iterator<ShibRPCProtocols>& protos) : sock(s), child(NULL)
 {
   protos.reset();
   while (protos.hasNext())
     v_protos.push_back(protos.next());
   
-  // Create the lock and then lock this child
-  lock = Mutex::create();
-  Lock tl(lock);
-
   // Create the child thread
   child = Thread::create(shar_client_thread, (void*)this);
   child->detach();
-
-  // Lock the children map and add this child
-  Lock cl(child_lock);
-  children[child] = 1;
 }
 
 SharChild::~SharChild()
 {
-  // Lock this object
-  lock->lock();
-
-  // Then lock the children map, remove this thread, signal waiters, and return
+  // Then lock the children map, remove this socket/thread, signal waiters, and return
   child_lock->lock();
-  children.erase(child);
+  children.erase(sock);
   child_lock->unlock();
   child_wait->signal();
   
-  lock->unlock();
-  delete lock;
   delete child;
 }
 
 void SharChild::run()
 {
+    // Before starting up, make sure we fully "own" this socket.
+    child_lock->lock();
+    while (children.find(sock)!=children.end())
+        child_wait->wait(child_lock);
+    children[sock] = child;
+    child_lock->unlock();
+    
   if (!svc_create())
    return;
 
@@ -199,4 +193,3 @@ void SHARUtils::fini()
   delete child_lock;
   child_lock = NULL;
 }
-
diff --git a/shar/shar-utils.h b/shar/shar-utils.h
index c0bd7df..7804bff 100644
--- a/shar/shar-utils.h
+++ b/shar/shar-utils.h
@@ -82,7 +82,6 @@ private:
     shibtarget::IListener::ShibSocket sock;
     std::vector<ShibRPCProtocols> v_protos;
     shibboleth::Thread* child;
-    shibboleth::Mutex* lock;
 };
 
 struct SHARUtils

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/shibboleth-sp2.git



More information about the Pkg-shibboleth-devel mailing list