Skip to content

Commit af28905

Browse files
committed
Fix spurious error callbacks after shutdown; Fix tests exceptions; Added reconnect tests; release 2.0.1
1 parent ab56627 commit af28905

4 files changed

Lines changed: 704 additions & 60 deletions

File tree

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# [v2.0.1] - 2026-04-27
2+
3+
## Fixed
4+
- WebSocket `co_spawn` completion handler now guards `on_error_()` with a `run_` check, suppressing spurious error callbacks after shutdown.
5+
- Fixed use-after-free in WebSocket tests where `[&]` lambda captures referenced destroyed stack variables when async callbacks fired via IOCP after the test function returned. Affected tests (`ConnectToEchoServer`, `InvalidHostnameError`, `MultipleErrorCallbacks`, `ReconnectAfterError`, `PlainWebsocket_UrlParsing`) now use `shared_ptr` captures to extend captured variable lifetimes.
6+
7+
## Tests
8+
- Added 10 comprehensive `Reconnect_*` tests verifying correct behavior when reconnecting by creating a new `Websocket` instance during normal operation (service thread always running):
9+
- Graceful close → new-object reconnect
10+
- Three consecutive reconnect cycles with data verification
11+
- Reconnect initiated from within `on_disconnected_` callback (deadlock check)
12+
- Reconnect initiated from within `on_error_` callback
13+
- Reconnect after closing from within `on_data_` callback
14+
- Reconnect after simulated server-side close
15+
- Cross-session data integrity (no bleed via shared `io_context`/SSL context)
16+
- Rapid successive cycles (service thread stability)
17+
- Callback ordering across sessions (`connected``data``disconnected`)
18+
- Concurrent dual-instance connect (shared SSL context)
19+
120
# [v2.0.0] - 2026-02-15
221

322
## Changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (MSVC)
88
endif()
99

1010
project(slick-net
11-
VERSION 2.0.0
11+
VERSION 2.0.1
1212
LANGUAGES CXX
1313
)
1414

src/websocket_session.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ void Websocket::Impl::open() {
8484
std::rethrow_exception(eptr);
8585
} catch (const std::exception& e) {
8686
self->status_.store(Status::DISCONNECTED, std::memory_order_release);
87-
self->on_error_(e.what());
87+
if (detail::run_.load(std::memory_order_relaxed)) {
88+
self->on_error_(e.what());
89+
}
8890
}
8991
}
9092
});

0 commit comments

Comments
 (0)