Mutex changes
This commit is contained in:
parent
64f35e2a92
commit
657c8e21ad
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user