summaryrefslogtreecommitdiffstats
path: root/src/Net/ClientConnection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Net/ClientConnection.cpp')
-rw-r--r--src/Net/ClientConnection.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/Net/ClientConnection.cpp b/src/Net/ClientConnection.cpp
index e4de735..688dbc7 100644
--- a/src/Net/ClientConnection.cpp
+++ b/src/Net/ClientConnection.cpp
@@ -21,6 +21,8 @@
#include "FdManager.h"
#include "IPAddress.h"
+#include <boost/thread/locks.hpp>
+
#include <cstring>
#include <cerrno>
#include <sys/socket.h>
@@ -56,19 +58,17 @@ void ClientConnection::connectionHeader() {
}
void ClientConnection::connect(const IPAddress &address, bool daemon0) throw(Exception) {
- gl_rwlock_wrlock(stateLock);
+ boost::unique_lock<boost::shared_mutex> lock(stateLock);
daemon = daemon0;
if(_isConnected()) {
- gl_rwlock_unlock(stateLock);
return;
// TODO Error
}
sock = socket(PF_INET, SOCK_STREAM, 0);
if(sock < 0) {
- gl_rwlock_unlock(stateLock);
throw Exception("socket()", Exception::INTERNAL_ERRNO, errno);
}
@@ -81,7 +81,6 @@ void ClientConnection::connect(const IPAddress &address, bool daemon0) throw(Exc
delete peer;
peer = 0;
- gl_rwlock_unlock(stateLock);
throw Exception("connect()", Exception::INTERNAL_ERRNO, errno);
}
@@ -91,7 +90,6 @@ void ClientConnection::connect(const IPAddress &address, bool daemon0) throw(Exc
if(flags < 0) {
close(sock);
- gl_rwlock_unlock(stateLock);
throw Exception("fcntl()", Exception::INTERNAL_ERRNO, errno);
}
@@ -110,7 +108,7 @@ void ClientConnection::connect(const IPAddress &address, bool daemon0) throw(Exc
state = CONNECT;
- gl_rwlock_unlock(stateLock);
+ lock.unlock();
updateEvents();
}