Mutex changes

This commit is contained in:
Cloaked9000 2017-01-23 09:15:40 +00:00
parent 64f35e2a92
commit 657c8e21ad
6 changed files with 5 additions and 10 deletions

View File

@ -115,9 +115,6 @@ namespace fr
std::unique_ptr<mbedtls_ssl_context> ssl;
mbedtls_ssl_config conf;
uint32_t flags;
std::mutex outbound_mutex;
std::mutex inbound_mutex;
};
}

View File

@ -6,6 +6,7 @@
#define FRNETLIB_SOCKET_H
#include <mutex>
#include "NetworkEncoding.h"
#include "Packet.h"
@ -165,6 +166,9 @@ namespace fr
bool is_blocking;
bool is_connected;
std::mutex outbound_mutex;
std::mutex inbound_mutex;
#ifdef _WIN32
static WSADATA wsaData;
static uint32_t instance_count;

View File

@ -107,8 +107,6 @@ protected:
std::string unprocessed_buffer;
std::unique_ptr<char[]> recv_buffer;
int32_t socket_descriptor;
std::mutex outbound_mutex;
std::mutex inbound_mutex;
};
}

View File

@ -40,7 +40,6 @@ namespace fr
Socket::Status SSLSocket::send_raw(const char *data, size_t size)
{
std::lock_guard<std::mutex> guard(outbound_mutex);
int error = 0;
while((error = mbedtls_ssl_write(ssl.get(), (const unsigned char *)data, size)) <= 0)
{
@ -55,8 +54,6 @@ namespace fr
Socket::Status SSLSocket::receive_raw(void *data, size_t data_size, size_t &received)
{
std::lock_guard<std::mutex> guard(inbound_mutex);
int read = MBEDTLS_ERR_SSL_WANT_READ;
received = 0;
if(unprocessed_buffer.size() < data_size)

View File

@ -80,6 +80,7 @@ namespace fr
ssize_t bytes_remaining = buffer_size;
size_t bytes_read = 0;
std::lock_guard<std::mutex> guard(inbound_mutex);
while(bytes_remaining > 0)
{
size_t received = 0;

View File

@ -22,7 +22,6 @@ namespace fr
Socket::Status TcpSocket::send_raw(const char *data, size_t size)
{
std::lock_guard<std::mutex> guard(outbound_mutex);
size_t sent = 0;
while(sent < size)
{
@ -56,7 +55,6 @@ namespace fr
Socket::Status TcpSocket::receive_raw(void *data, size_t buffer_size, size_t &received)
{
std::lock_guard<std::mutex> guard(inbound_mutex);
received = 0;
if(unprocessed_buffer.size() < buffer_size)
{