Switch goroutines for contexts in packetconn - #395
Conversation
80b0c3c to
5ce1626
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #395 +/- ##
==========================================
- Coverage 84.45% 84.38% -0.07%
==========================================
Files 41 41
Lines 3416 3388 -28
==========================================
- Hits 2885 2859 -26
Misses 393 393
+ Partials 138 136 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
5ce1626 to
306a259
Compare
JoTurk
left a comment
There was a problem hiding this comment.
Looks great thank you, I also tested it locally :)
Just 2 comments and one nit.
| defer cancel() | ||
|
|
||
| detachDeadline := context.AfterFunc(combinedCtx, func() { | ||
| _ = p.nextConn.SetReadDeadline(veryOld) |
There was a problem hiding this comment.
nit: maybe we shouldn't ignore deadline errors?
There was a problem hiding this comment.
So actually I gave that one some thoughts because it was specifically handled in the previous impl. My conclusion here is that failing at the SetReadDeadline stage should only happen if the connection is closed already. So we don't really care at that stage. Now this holds true for standard implementations, in the case the connection was not closed and the SetReadDeadline truly failed (which in theory should never happen unless the underlying implementation is buggy) we would be in much more trouble since that operation could hang forever (which was also the case in the previous impl since we only returned the err after the read finished).
I think a better alternative here would be to simply panic in case of error so it gives a chance to recover?
There was a problem hiding this comment.
Actually realized we cannot do that properly because AfterFunc would panic on a different goroutine - reworking the whole SetReadDeadline instead
There was a problem hiding this comment.
Here I am opting for a closure of the whole connection so that we avoid hanging
631b858 to
6384588
Compare
34c0b6d to
434e560
Compare
434e560 to
6f42564
Compare
Remove goroutines in Write/Read hot paths from packetconn