Permalink
Browse files

http: Discard output buffer on disconnect.

Prevents an assert.
  • Loading branch information...
unknownbrackets committed Jun 16, 2018
1 parent c7baed2 commit b7ac9a6f373bec66b24155749c9dced035e46135
Showing with 9 additions and 0 deletions.
  1. +6 −0 ext/native/net/sinks.cpp
  2. +1 −0 ext/native/net/sinks.h
  3. +2 −0 ext/native/net/websocket_server.cpp
@@ -341,6 +341,12 @@ bool OutputSink::Flush(bool allowBlock) {
return true;
}
void OutputSink::Discard() {
read_ = 0;
write_ = 0;
valid_ = 0;
}
void OutputSink::Drain() {
// Avoid small reads if possible.
if (valid_ > PRESSURE) {
@@ -51,6 +51,7 @@ class OutputSink {
bool Printf(const char *fmt, ...);
bool Flush(bool allowBlock = true);
void Discard();
bool Empty();
@@ -259,6 +259,8 @@ bool WebSocketServer::Process(float timeout) {
// Since select said it was readable, we assume this means disconnect.
closeReason_ = WebSocketClose::ABNORMAL;
open_ = false;
// Kill any remaining output too.
out_->Discard();
return false;
}

0 comments on commit b7ac9a6

Please sign in to comment.