-
-
Notifications
You must be signed in to change notification settings - Fork 511
Open
Labels
bugSomething isn't workingSomething isn't workingdiscussionThe viability / implementation of the issue is up for debateThe viability / implementation of the issue is up for debate
Description
Hi there,
i experience a serious issue (which is perfectly reproducible), that crashes the server, if a client closes connection uncleanly (like wifi outage). This happens with version 1.2.0, as well as with latest master a9e7b73.
If the client crashed, the server stucks in calling the onerror handler repeatedly with reason "uncleanly".
This somehow seems related to #549 .
Edit: this very naive fix seems to do the trick:
diff --git a/include/crow/websocket.h b/include/crow/websocket.h
index 7c6694e32..0e2822ba5 100644
--- a/include/crow/websocket.h
+++ b/include/crow/websocket.h
@@ -725,9 +725,11 @@ namespace crow // NOTE: Already documented in "crow/app.h"
{
// Note that if the close handler was not yet called at this point we did not receive a close packet (or send one)
// and thus we use ClosedAbnormally unless instructed otherwise
- if (!is_close_handler_called_)
+ if (!is_close_handler_called_) {
if (close_handler_)
close_handler_(*this, "uncleanly", code);
+ is_close_handler_called_ = true;
+ }
handler_->remove_websocket(this);
if (sending_buffers_.empty() && !is_reading)
delete this;
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdiscussionThe viability / implementation of the issue is up for debateThe viability / implementation of the issue is up for debate