ConnProperties: atomic "authenticated" field

This commit is contained in:
Stéphane Lepin 2019-05-02 13:11:34 +02:00
parent bb9cf83744
commit d8b37328a1
3 changed files with 11 additions and 4 deletions

View File

@ -18,12 +18,17 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "ConnectionProperties.h"
ConnectionProperties::ConnectionProperties()
: _authenticated(false)
{
}
bool ConnectionProperties::isAuthenticated()
{
return _authenticated;
return _authenticated.load();
}
void ConnectionProperties::setAuthenticated(bool authenticated)
{
_authenticated = authenticated;
_authenticated.store(authenticated);
}

View File

@ -18,11 +18,14 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#pragma once
#include <boost/atomic.hpp>
class ConnectionProperties
{
public:
explicit ConnectionProperties();
bool isAuthenticated();
void setAuthenticated(bool authenticated);
private:
bool _authenticated;
boost::atomic<bool> _authenticated;
};

View File

@ -155,7 +155,6 @@ void WSServer::onOpen(connection_hdl hdl)
{
QMutexLocker locker(&_clMutex);
_connections.insert(hdl);
_connectionProperties[hdl] = ConnectionProperties();
locker.unlock();
QString clientIp = getRemoteEndpoint(hdl);