From: Pawel Polawski
Date: Mon, 7 Jan 2013 14:00:27 +0000 (+0100)
Subject: Release of changes from Samsung private repository.
X-Git-Tag: submit/tizen_2.1/20130424.233001~5^2~21
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d62a50da4603be59bf61361de368a8b69b0584e3;p=platform%2Fcore%2Fsecurity%2Fsecurity-server.git
Release of changes from Samsung private repository.
* Fixed possible thread synchronization issue
Change-Id: I434ff4bf5c539dfe845d52369dc51d7bddc29081
---
diff --git a/src/services/caller/security_caller.h b/src/services/caller/security_caller.h
index 107e92e..e1b68d0 100644
--- a/src/services/caller/security_caller.h
+++ b/src/services/caller/security_caller.h
@@ -110,18 +110,20 @@ class SecurityCallerThread : public DPL::Thread
{
if (m_eventHolder) // if m_eventHolder is set, the request has been received
{
- m_eventHolder->FinalizeSending(); // send actuall event in charge of calling thread
+ m_eventHolder->FinalizeSending(); // send actual event in charge of calling thread
delete m_eventHolder;
m_eventHolder = NULL;
+ LogDebug("setting finished state");
pthread_mutex_lock(&m_syncMutex); // lock m_finished
m_finished = true;
pthread_mutex_unlock(&m_syncMutex); // unlock m_finished
+ LogDebug("finished");
pthread_cond_signal(&m_cond2); // signal a calling thread that event has been posted.
}
LogDebug("waiting for event");
// atomically:
// unlock m_mutex, wait on m_cond until signal received, lock m_mutex
- pthread_cond_wait(&m_cond, &m_mutex);
+ pthread_cond_wait(&m_cond, &m_mutex);
LogDebug("found an event");
}
@@ -155,19 +157,23 @@ class SecurityCallerThread : public DPL::Thread
}
Assert(correct_thread &&
"This method may not be called from DPL managed thread or main thread");
+ LogDebug("putting an event to be posted");
pthread_mutex_lock(&m_mutex); // lock shared data
Assert(m_eventHolder == NULL && "Whooops");
m_eventHolder = new EventHolderImpl(event); // put an event to be posted
pthread_mutex_unlock(&m_mutex); // unlock shared data
+ LogDebug("Signal caller thread that new event has been created");
pthread_cond_signal(&m_cond); // signal SecurityCallerThread to wake up because new
// event is waiting to be posted
+ LogDebug("waiting untill send completes");
pthread_mutex_lock(&m_syncMutex); /* wait until send completes */
- m_finished = false;
while (!m_finished)
{
pthread_cond_wait(&m_cond2, &m_syncMutex); // wait until event is posted
}
+ LogDebug("done");
+ m_finished = false;
pthread_mutex_unlock(&m_syncMutex);
pthread_mutex_unlock(&m_mutex2);
}
@@ -178,4 +184,6 @@ class SecurityCallerThread : public DPL::Thread
typedef DPL::Singleton SecurityCallerSingleton;
+
+
#endif //SECURITY_CALLER_H__