Skip to content

Commit 0faf4b5

Browse files
Aaron Bradyfacebook-github-bot
authored andcommitted
fix crash on sendKeepalive fail
Summary: if the socket connection is closed (or a close is detected) remotely during sendKeepalive then * stop() gets invoked and * the connection_ pointer is cleared and * pending_ is set to false * but pending_ will still be set to true after this returns, and you'll get a crash as the connection_ shared_ptr is now null. swapping the order allows stop() to clear the pending_ flag properly if send fails. Reviewed By: phoad Differential Revision: D8926438 fbshipit-source-id: 897a46abc70a50d1e6cce50c0502a4cd86d6d4ae
1 parent 0470932 commit 0faf4b5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rsocket/internal/KeepaliveTimer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ void KeepaliveTimer::sendKeepalive() {
5353
localPtr->disconnectOrCloseWithError(
5454
Frame_ERROR::connectionError("no response to keepalive"));
5555
} else {
56-
connection_->sendKeepalive();
56+
// this must happen before sendKeepalive as it can potentially result in
57+
// stop() being called
5758
pending_ = true;
59+
connection_->sendKeepalive();
5860
schedule();
5961
}
6062
}

0 commit comments

Comments
 (0)