#6521 Fixed access violation in SSL sockets
This commit is contained in:
parent
1709984f1e
commit
fb27752e3e
|
@ -38,15 +38,6 @@ SecureListenSocket::SecureListenSocket(
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SecureListenSocket::~SecureListenSocket()
|
|
||||||
{
|
|
||||||
SecureSocketSet::iterator it;
|
|
||||||
for (it = m_secureSocketSet.begin(); it != m_secureSocketSet.end(); it++) {
|
|
||||||
delete *it;
|
|
||||||
}
|
|
||||||
m_secureSocketSet.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
IDataSocket*
|
IDataSocket*
|
||||||
SecureListenSocket::accept()
|
SecureListenSocket::accept()
|
||||||
{
|
{
|
||||||
|
@ -75,8 +66,6 @@ SecureListenSocket::accept()
|
||||||
|
|
||||||
socket->secureAccept();
|
socket->secureAccept();
|
||||||
|
|
||||||
m_secureSocketSet.insert(socket);
|
|
||||||
|
|
||||||
return dynamic_cast<IDataSocket*>(socket);
|
return dynamic_cast<IDataSocket*>(socket);
|
||||||
}
|
}
|
||||||
catch (XArchNetwork&) {
|
catch (XArchNetwork&) {
|
||||||
|
|
|
@ -28,14 +28,9 @@ class SecureListenSocket : public TCPListenSocket{
|
||||||
public:
|
public:
|
||||||
SecureListenSocket(IEventQueue* events,
|
SecureListenSocket(IEventQueue* events,
|
||||||
SocketMultiplexer* socketMultiplexer, IArchNetwork::EAddressFamily family);
|
SocketMultiplexer* socketMultiplexer, IArchNetwork::EAddressFamily family);
|
||||||
~SecureListenSocket();
|
|
||||||
|
|
||||||
// IListenSocket overrides
|
// IListenSocket overrides
|
||||||
virtual IDataSocket*
|
virtual IDataSocket*
|
||||||
accept();
|
accept();
|
||||||
|
|
||||||
private:
|
|
||||||
typedef std::set<IDataSocket*> SecureSocketSet;
|
|
||||||
|
|
||||||
SecureSocketSet m_secureSocketSet;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,6 +96,7 @@ ClientListener::~ClientListener()
|
||||||
|
|
||||||
m_events->removeHandler(m_events->forIListenSocket().connecting(), m_listen);
|
m_events->removeHandler(m_events->forIListenSocket().connecting(), m_listen);
|
||||||
cleanupListenSocket();
|
cleanupListenSocket();
|
||||||
|
cleanupClientSockets();
|
||||||
delete m_socketFactory;
|
delete m_socketFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +129,8 @@ ClientListener::handleClientConnecting(const Event&, void*)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_clientSockets.insert(socket);
|
||||||
|
|
||||||
m_events->adoptHandler(m_events->forClientListener().accepted(),
|
m_events->adoptHandler(m_events->forClientListener().accepted(),
|
||||||
socket->getEventTarget(),
|
socket->getEventTarget(),
|
||||||
new TMethodEventJob<ClientListener>(this,
|
new TMethodEventJob<ClientListener>(this,
|
||||||
|
@ -149,7 +152,7 @@ ClientListener::handleClientAccepted(const Event&, void* vsocket)
|
||||||
IDataSocket* socket = static_cast<IDataSocket*>(vsocket);
|
IDataSocket* socket = static_cast<IDataSocket*>(vsocket);
|
||||||
|
|
||||||
// filter socket messages, including a packetizing filter
|
// filter socket messages, including a packetizing filter
|
||||||
synergy::IStream* stream = new PacketStreamFilter(m_events, socket, true);
|
synergy::IStream* stream = new PacketStreamFilter(m_events, socket, false);
|
||||||
assert(m_server != NULL);
|
assert(m_server != NULL);
|
||||||
|
|
||||||
// create proxy for unknown client
|
// create proxy for unknown client
|
||||||
|
@ -221,7 +224,14 @@ ClientListener::handleClientDisconnected(const Event&, void* vclient)
|
||||||
m_waitingClients.erase(i);
|
m_waitingClients.erase(i);
|
||||||
m_events->removeHandler(m_events->forClientProxy().disconnected(),
|
m_events->removeHandler(m_events->forClientProxy().disconnected(),
|
||||||
client);
|
client);
|
||||||
|
|
||||||
|
// pull out the socket before deleting the client so
|
||||||
|
// we know which socket we no longer need
|
||||||
|
IDataSocket* socket = static_cast<IDataSocket*>(client->getStream());
|
||||||
delete client;
|
delete client;
|
||||||
|
m_clientSockets.erase(socket);
|
||||||
|
delete socket;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,3 +242,13 @@ ClientListener::cleanupListenSocket()
|
||||||
{
|
{
|
||||||
delete m_listen;
|
delete m_listen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientListener::cleanupClientSockets()
|
||||||
|
{
|
||||||
|
ClientSockets::iterator it;
|
||||||
|
for (it = m_clientSockets.begin(); it != m_clientSockets.end(); it++) {
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
m_clientSockets.clear();
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ class IListenSocket;
|
||||||
class ISocketFactory;
|
class ISocketFactory;
|
||||||
class Server;
|
class Server;
|
||||||
class IEventQueue;
|
class IEventQueue;
|
||||||
|
class IDataSocket;
|
||||||
|
|
||||||
class ClientListener {
|
class ClientListener {
|
||||||
public:
|
public:
|
||||||
|
@ -72,10 +73,12 @@ private:
|
||||||
void handleClientDisconnected(const Event&, void*);
|
void handleClientDisconnected(const Event&, void*);
|
||||||
|
|
||||||
void cleanupListenSocket();
|
void cleanupListenSocket();
|
||||||
|
void cleanupClientSockets();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::set<ClientProxyUnknown*> NewClients;
|
typedef std::set<ClientProxyUnknown*> NewClients;
|
||||||
typedef std::deque<ClientProxy*> WaitingClients;
|
typedef std::deque<ClientProxy*> WaitingClients;
|
||||||
|
typedef std::set<IDataSocket*> ClientSockets;
|
||||||
|
|
||||||
IListenSocket* m_listen;
|
IListenSocket* m_listen;
|
||||||
ISocketFactory* m_socketFactory;
|
ISocketFactory* m_socketFactory;
|
||||||
|
@ -84,4 +87,5 @@ private:
|
||||||
Server* m_server;
|
Server* m_server;
|
||||||
IEventQueue* m_events;
|
IEventQueue* m_events;
|
||||||
bool m_useSecureNetwork;
|
bool m_useSecureNetwork;
|
||||||
|
ClientSockets m_clientSockets;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue