@@ -71,10 +71,11 @@ void ConnectionAutomaton::disconnect() {
7171 }
7272}
7373
74- void ConnectionAutomaton::reconnect (std::unique_ptr<DuplexConnection> newConnection) {
75- disconnect ();
76- connection_ = std::move (newConnection);
77- connect ();
74+ void ConnectionAutomaton::reconnect (
75+ std::unique_ptr<DuplexConnection> newConnection) {
76+ disconnect ();
77+ connection_ = std::move (newConnection);
78+ connect ();
7879}
7980
8081ConnectionAutomaton::~ConnectionAutomaton () {
@@ -138,7 +139,8 @@ void ConnectionAutomaton::onNext(std::unique_ptr<folly::IOBuf> frame) {
138139
139140 stats_.frameRead (ss.str ());
140141
141- // TODO(tmont): If a frame is invalid, it will still be tracked. However, we actually want that. We want to keep
142+ // TODO(tmont): If a frame is invalid, it will still be tracked. However, we
143+ // actually want that. We want to keep
142144 // each side in sync, even if a frame is invalid.
143145 resumeTracker_->trackReceivedFrame (*frame);
144146
@@ -218,17 +220,20 @@ void ConnectionAutomaton::onConnectionFrame(
218220 bool canResume = false ;
219221
220222 if (isServer_ && isResumable_) {
221- // find old ConnectionAutmaton via calling listener.
222- // Application will call resumeFromAutomaton to setup streams and resume information
223- canResume = resumeListener_ (frame.token_ , frame.position_ );
223+ // find old ConnectionAutmaton via calling listener.
224+ // Application will call resumeFromAutomaton to setup streams and
225+ // resume information
226+ canResume = resumeListener_ (frame.token_ , frame.position_ );
224227 }
225228
226229 if (canResume) {
227230 outputFrameOrEnqueue (
228- Frame_RESUME_OK (resumeTracker_->impliedPosition ()).serializeOut ());
231+ Frame_RESUME_OK (resumeTracker_->impliedPosition ())
232+ .serializeOut ());
229233 resumeCache_->retransmitFromPosition (frame.position_ , *this );
230234 } else {
231- outputFrameOrEnqueue (Frame_ERROR::canNotResume (" can not resume" ).serializeOut ());
235+ outputFrameOrEnqueue (
236+ Frame_ERROR::canNotResume (" can not resume" ).serializeOut ());
232237 disconnect ();
233238 }
234239 } else {
@@ -240,11 +245,13 @@ void ConnectionAutomaton::onConnectionFrame(
240245 case FrameType::RESUME_OK: {
241246 Frame_RESUME_OK frame;
242247 if (frame.deserializeFrom (std::move (payload))) {
243- if (!isServer_ && isResumable_ && resumeCache_->isPositionAvailable (frame.position_ )) {
248+ if (!isServer_ && isResumable_ &&
249+ resumeCache_->isPositionAvailable (frame.position_ )) {
244250 resumeCache_->retransmitFromPosition (frame.position_ , *this );
245251 } else {
246- outputFrameOrEnqueue (Frame_ERROR::canNotResume (" can not resume" ).serializeOut ());
247- disconnect ();
252+ outputFrameOrEnqueue (
253+ Frame_ERROR::canNotResume (" can not resume" ).serializeOut ());
254+ disconnect ();
248255 }
249256 } else {
250257 outputFrameOrEnqueue (Frame_ERROR::unexpectedFrame ().serializeOut ());
@@ -321,17 +328,18 @@ void ConnectionAutomaton::sendKeepalive() {
321328 outputFrameOrEnqueue (pingFrame.serializeOut ());
322329}
323330
324- void ConnectionAutomaton::sendResume (const ResumeIdentificationToken & token) {
331+ void ConnectionAutomaton::sendResume (const ResumeIdentificationToken& token) {
325332 Frame_RESUME resumeFrame (token, resumeTracker_->impliedPosition ());
326333 outputFrameOrEnqueue (resumeFrame.serializeOut ());
327334}
328335
329336bool ConnectionAutomaton::isPositionAvailable (ResumePosition position) {
330- return resumeCache_->isPositionAvailable (position);
337+ return resumeCache_->isPositionAvailable (position);
331338}
332339
333- ResumePosition ConnectionAutomaton::positionDifference (ResumePosition position) {
334- return resumeCache_->position () - position;
340+ ResumePosition ConnectionAutomaton::positionDifference (
341+ ResumePosition position) {
342+ return resumeCache_->position () - position;
335343}
336344
337345void ConnectionAutomaton::onClose (ConnectionCloseListener listener) {
@@ -374,16 +382,14 @@ void ConnectionAutomaton::outputFrame(
374382 connectionOutput_.onNext (std::move (outputFrame));
375383}
376384
377- void ConnectionAutomaton::resumeFromAutomaton (ConnectionAutomaton& oldAutomaton)
378- {
379- if (isServer_ && isResumable_)
380- {
385+ void ConnectionAutomaton::resumeFromAutomaton (
386+ ConnectionAutomaton& oldAutomaton) {
387+ if (isServer_ && isResumable_) {
381388 streams_ = std::move (oldAutomaton.streams_ );
382389 factory_ = oldAutomaton.factory_ ;
383390
384391 resumeTracker_ = std::move (oldAutomaton.resumeTracker_ );
385392 resumeCache_ = std::move (oldAutomaton.resumeCache_ );
386393 }
387394}
388-
389395}
0 commit comments