Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Conversation

@emgre
Copy link
Member

@emgre emgre commented Nov 17, 2020

Fix it and added a unit test.

Fix #392.

@codecov
Copy link

codecov bot commented Nov 17, 2020

Codecov Report

Merging #407 (23668af) into develop (4372862) will increase coverage by 0.11%.
The diff coverage is 63.15%.

@@             Coverage Diff             @@
##           develop     #407      +/-   ##
===========================================
+ Coverage    51.29%   51.40%   +0.11%     
===========================================
  Files          423      423              
  Lines        13439    13444       +5     
===========================================
+ Hits          6893     6911      +18     
+ Misses        6546     6533      -13     
Impacted Files Coverage Δ
cpp/lib/src/link/LinkContext.h 100.00% <ø> (ø)
cpp/lib/src/master/MasterContext.h 100.00% <ø> (ø)
cpp/lib/src/master/MasterStack.h 100.00% <ø> (ø)
cpp/lib/src/master/MasterSessionStack.cpp 27.18% <18.75%> (ø)
cpp/lib/src/master/MasterStack.cpp 19.35% <25.00%> (ø)
cpp/lib/src/link/LinkContext.cpp 91.39% <100.00%> (+1.23%) ⬆️
cpp/lib/src/link/LinkLayer.cpp 100.00% <100.00%> (ø)
cpp/lib/src/master/MasterContext.cpp 84.16% <100.00%> (+0.12%) ⬆️
cpp/lib/src/transport/TransportLayer.cpp 93.75% <0.00%> (-1.57%) ⬇️
cpp/lib/src/link/LinkFrame.cpp 95.06% <0.00%> (-1.24%) ⬇️
... and 4 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@emgre emgre changed the title Keep-alive timer was not properly calculated. Keep-alive timer was not properly calculated + LinkContext lifetime issue Nov 17, 2020
@emgre
Copy link
Member Author

emgre commented Nov 17, 2020

Since I had to play in LinkContext, I made a fix for #396. This would replace #395. Instead of owning the shared_ptr in the callbacks and waiting in the destructor for them to release, the callbacks instead own a weak_ptr and checks that it's still valid (the shared_ptr automatically gets destroyed in the LinkContext default destructor).

@emgre emgre force-pushed the bugfix/keep-alive-timer-reset branch from 9130b38 to 2c55c66 Compare April 5, 2022 21:50
emgre added 2 commits April 7, 2022 16:37
I also added a protection against another possible dangling pointer issue
with `MContext`.
@emgre
Copy link
Member Author

emgre commented Apr 12, 2022

As noted by Nicholas Lee, even with the original fix, the keep-alive timers were internally expiring early, just to restart a very short timer afterwards. This was caused by how we used to drive the keep-alive timer. It was not restarted on every link activity, we were just waiting for the old one to expire and then we were re-calculating a new timer based on the recorded last link activity. I made the change to simply restart the timer on every link activity, I think it's cleaner.

As for the LinkContext lifetime issue, I ended up superseding #435 by simply having the LinkContext be shared_from_this. Shutdown is properly done in the OnLowerLayerDown and checked in the callbacks. I also found that MContext could possibly have a similar issue (if a shutdown occurs while waiting for a response), so I applied the same fix. Shutdown is also properly checked.

@emgre emgre merged commit e8b1de4 into develop Apr 12, 2022
@emgre emgre deleted the bugfix/keep-alive-timer-reset branch April 12, 2022 14:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants