http: Discard output buffer on disconnect.

Prevents an assert.
This commit is contained in:
Unknown W. Brackets 2018-06-16 13:29:44 -07:00
parent c7baed26db
commit b7ac9a6f37
3 changed files with 9 additions and 0 deletions

View File

@ -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) {

View File

@ -51,6 +51,7 @@ public:
bool Printf(const char *fmt, ...);
bool Flush(bool allowBlock = true);
void Discard();
bool Empty();

View File

@ -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;
}