(socket server) add a callback to the ConnectionState to be invoked when the connection is terminated. This will be used by the SocketServer in the future to know on time that the associated connection thread can be terminated.

This commit is contained in:
Benjamin Sergeant
2020-08-15 16:03:40 -07:00
parent 261095fa12
commit 785842de03
6 changed files with 33 additions and 3 deletions

View File

@ -8,11 +8,11 @@
#include "IXNetSystem.h"
#include "IXSelectInterrupt.h"
#include "IXSelectInterruptFactory.h"
#include "IXSetThreadName.h"
#include "IXSocket.h"
#include "IXSocketConnect.h"
#include "IXSocketFactory.h"
#include "IXSelectInterruptFactory.h"
#include <assert.h>
#include <sstream>
#include <stdio.h>
@ -259,7 +259,7 @@ namespace ix
if (_stop) return;
// Use poll to check whether a new connection is in progress
int timeoutMs = 10;
int timeoutMs = 10000;
bool readyToRead = true;
PollResultType pollResult =
Socket::poll(readyToRead, timeoutMs, _serverFd, _acceptSelectInterrupt);
@ -355,6 +355,7 @@ namespace ix
{
connectionState = _connectionStateFactory();
}
connectionState->setOnSetTerminatedCallback([this] { onSetTerminatedCallback(); });
if (_stop) return;
@ -423,4 +424,9 @@ namespace ix
{
_socketTLSOptions = socketTLSOptions;
}
void SocketServer::onSetTerminatedCallback()
{
;
}
} // namespace ix