Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
http: Discard output buffer on disconnect.
Prevents an assert.
  • Loading branch information
unknownbrackets committed Jun 16, 2018
1 parent c7baed2 commit b7ac9a6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ext/native/net/sinks.cpp
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions ext/native/net/sinks.h
Expand Up @@ -51,6 +51,7 @@ class OutputSink {
bool Printf(const char *fmt, ...);

bool Flush(bool allowBlock = true);
void Discard();

bool Empty();

Expand Down
2 changes: 2 additions & 0 deletions ext/native/net/websocket_server.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit b7ac9a6

Please sign in to comment.