mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-26 12:24:46 +00:00
Guard last_event_id() against the async event loop in SSEClient (#2644)
last_event_id() returned a reference to a string that run_event_loop() assigns on its own thread under start_async(), so a caller reading it from another thread raced the writes. The member is now guarded by a mutex and the getter returns a copy. The return type changes from const std::string & to std::string. Code that binds the result to a const reference or copies it still compiles.
This commit is contained in:
1 parent
391de32115
commit
2f8b9f6f57
3 files changed
+51
-4
No files matched your search
+1
-1
@@ -100,7 +100,7 @@ sse.stop();
|
||||
|
||||
```cpp
|
||||
bool connected = sse.is_connected();
|
||||
const std::string &id = sse.last_event_id();
|
||||
std::string id = sse.last_event_id();
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
Reference in new issue
Block a user