Websocket: allow a hard shutdown after flushing data.
Don't wait for the other end to acknowledge closing the socket. Signed-off-by: Michael Meeks <michael.meeks@collabora.com> Change-Id: If5e4bb6d9c5148c0e0c61d59c233f6cf5594c577pull/8667/head
parent
df343fc5fa
commit
9e0cef08c2
|
@ -238,7 +238,8 @@ protected:
|
|||
|
||||
public:
|
||||
void shutdown(const StatusCodes statusCode = StatusCodes::NORMAL_CLOSE,
|
||||
const std::string& statusMessage = std::string())
|
||||
const std::string& statusMessage = std::string(),
|
||||
bool hardShutdown = false)
|
||||
{
|
||||
std::shared_ptr<StreamSocket> socket = _socket.lock();
|
||||
if (socket)
|
||||
|
@ -250,6 +251,10 @@ public:
|
|||
socket->ignoreInput();
|
||||
assert(socket->getInBuffer().empty() &&
|
||||
"Socket buffer must be empty after ignoreInput");
|
||||
|
||||
// force close after writing this message
|
||||
if (hardShutdown)
|
||||
socket->shutdown();
|
||||
}
|
||||
|
||||
_wsPayload.clear();
|
||||
|
@ -259,6 +264,13 @@ public:
|
|||
_shuttingDown = false;
|
||||
}
|
||||
|
||||
/// Don't wait for the remote Websocket to handshake with us; go down fast.
|
||||
void shutdownAfterWriting()
|
||||
{
|
||||
shutdown(WebSocketHandler::StatusCodes::NORMAL_CLOSE, std::string(),
|
||||
true /* hard async shutdown & close */);
|
||||
}
|
||||
|
||||
private:
|
||||
bool handleTCPStream(const std::shared_ptr<StreamSocket>& socket)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue