libboostasio: close connection on timeout#463
Open
ricardocrl wants to merge 1 commit intoCopernicaMarketingSoftware:masterfrom
Open
libboostasio: close connection on timeout#463ricardocrl wants to merge 1 commit intoCopernicaMarketingSoftware:masterfrom
ricardocrl wants to merge 1 commit intoCopernicaMarketingSoftware:masterfrom
Conversation
ricardocrl
commented
May 31, 2022
Comment on lines
+516
to
+533
| * @param timeout The suggested timeout from the server | ||
| * @return uint16_t The timeout to use | ||
| */ | ||
| virtual uint16_t onNegotiate(TcpConnection *connection, uint16_t interval) override | ||
| virtual uint16_t onNegotiate(TcpConnection *connection, uint16_t timeout) override | ||
| { | ||
| // skip if no heartbeats are needed | ||
| if (interval == 0) return 0; | ||
| if (timeout == 0) return 0; | ||
|
|
||
| const auto fd = connection->fileno(); | ||
|
|
||
| auto iter = _watchers.find(fd); | ||
| if (iter == _watchers.end()) return 0; | ||
|
|
||
| // set the timer | ||
| iter->second->set_timer(connection, interval); | ||
| iter->second->set_timers(connection, timeout); | ||
|
|
||
| // we agree with the interval | ||
| return interval; | ||
| // we agree with the timeout | ||
| return timeout; |
Author
There was a problem hiding this comment.
This renaming is to achieve consistency with libev.h.
Although "interval" is the most used term in the library, I feel that calling "interval" wouldn't be intuitive to read "heartbeat interval = interval / 2". So I agree more with the "timeout" term chosen in libev.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The implementation is inspired in the approach used in libev.h. It will now handle
timeoutfromonNegotiate()in the same manner:As opposed to libev.h I opted for 2 separate timer (sending heartbeat + expire connection), for readability and maintainability purposes.
This PR addresses issue: #464