Add Connection::reset
There was an issue where the connection deque was referring to old arena memory
This commit is contained in:
@@ -121,7 +121,6 @@ Key features:
|
||||
|
||||
Key features:
|
||||
- Arena allocator per connection for efficient memory management
|
||||
- **Request/Response arena lifecycle**: Arena resets after each complete request/response cycle
|
||||
- Weak reference to server for safe cleanup after server destruction
|
||||
- Private networking details accessible only to Server via friend relationship
|
||||
- Public handler interface: appendMessage(), closeAfterSend(), getArena(), getId()
|
||||
@@ -180,9 +179,10 @@ Arena Memory Lifecycle:
|
||||
2. **Response Generation**: Handler uses arena for temporary response construction (headers, JSON, etc.)
|
||||
3. **Response Queuing**: Handler calls `conn->appendMessage()` which copies data to arena-backed message queue
|
||||
4. **Response Writing**: Server writes all queued messages to socket via `writeBytes()`
|
||||
5. **Arena Reset**: After successful write completion, arena resets to reclaim all memory from the request/response cycle
|
||||
|
||||
This design assumes request/response pairs (HTTP-like protocols) but works for any protocol where there's a clear completion point for memory reclamation.
|
||||
The user is responsible for calling `conn->reset()` periodically to reclaim the
|
||||
arena memory. A good time to do this for a request/response protocol would be
|
||||
after all outgoing bytes have been written.
|
||||
|
||||
### API Design
|
||||
|
||||
|
||||
Reference in New Issue
Block a user