summaryrefslogtreecommitdiffstats
path: root/src/Net/ServerConnection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Net/ServerConnection.cpp')
-rw-r--r--src/Net/ServerConnection.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Net/ServerConnection.cpp b/src/Net/ServerConnection.cpp
index 97e2ae4..aa8042e 100644
--- a/src/Net/ServerConnection.cpp
+++ b/src/Net/ServerConnection.cpp
@@ -54,13 +54,15 @@ void ServerConnection::connectionHeaderReceiveHandler(const void *data, unsigned
ConnectionHeader header2 = {'M', 'A', 'D', 0, 0, 1, 1, 0};
- rawSend((uint8_t*)&header2, sizeof(header2));
-
enterReceiveLoop();
+
+ rawSend((uint8_t*)&header2, sizeof(header2));
}
ServerConnection::ServerConnection(int sock0, const IPAddress &address, gnutls_dh_params_t dh_params, const std::string &x905CertFile, const std::string &x905KeyFile)
: daemon(false) {
+ gl_rwlock_wrlock(stateLock);
+
sock = sock0;
peer = new IPAddress(address);
@@ -73,9 +75,13 @@ ServerConnection::ServerConnection(int sock0, const IPAddress &address, gnutls_d
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t)sock);
- FdManager::get()->registerFd(sock, sigc::mem_fun(this, &Connection::sendReceive));
+ FdManager::get()->registerFd(sock, sigc::mem_fun(this, &ServerConnection::sendReceive));
+
+ state = CONNECT;
+
+ gl_rwlock_unlock(stateLock);
- handshake();
+ updateEvents();
}
}