Skip to content
Snippets Groups Projects
Commit 54e0d5e3 authored by al.schwinn's avatar al.schwinn
Browse files

#38 Wrong usage of class "Lock"

parent 7cd415b8
No related branches found
No related tags found
No related merge requests found
......@@ -185,8 +185,9 @@ void Connection::doClose(PLC* thePLC, bool withLock)
//withLock argument is used to avoid Recursive mutex that is not supported
//by LynxOS platform.
Lock lock;
if (withLock)
Lock lock(connMux_);
lock.setMutex(connMux_);
if (isConnected_)
{
......
......@@ -54,16 +54,31 @@ private:
class Lock
{
public:
Lock(Mutex* mutex) :
mutex_(mutex)
{
mutex_->lock();
}
Lock() :
mutex_(NULL)
{
}
~Lock()
{
mutex_->unlock();
if (mutex_ != NULL)
mutex_->unlock();
}
void setMutex(Mutex* mutex)
{
mutex_ = mutex;
}
protected:
Mutex* mutex_;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment