-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIXED] EventLoop: Socket now closed only after event loop done polling #815
base: main
Are you sure you want to change the base?
Conversation
The socket was closed by the NATS library itself, which could cause some issue when the event loop thread would still be polling it. We now defer to the event loop adapter to make sure that the event loop library is done polling before invoking a new function that will take care of closing the socket. I have updated the event loop test (that simulates what our adapters are doing). The mockup event loop implementation is a bit too simplistic but should be ok for now. If we have issues, we would have to make the events a linked list. Resolves #814 Signed-off-by: Ivan Kozlovic <[email protected]>
@levb I would like if possible have @dmitry-sles-novikov build from this branch and test with it to see if that resolves the issue. @levb Assuming we get an ok, note that although this is a fix, we have to add a new API in nats.h and also the event loop adapters now will use this new API. So not sure if it will have to be a 3.10 and not a fix to 3.9. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #815 +/- ##
==========================================
+ Coverage 68.71% 70.56% +1.85%
==========================================
Files 39 47 +8
Lines 15207 15455 +248
Branches 3143 3183 +40
==========================================
+ Hits 10449 10906 +457
+ Misses 1700 1472 -228
- Partials 3058 3077 +19 ☔ View full report in Codecov by Sentry. |
@@ -2146,9 +2146,21 @@ _evStopPolling(natsConnection *nc) | |||
|
|||
nc->sockCtx.useEventLoop = false; | |||
nc->el.writeAdded = false; | |||
s = nc->opts->evCbs.read(nc->el.data, NATS_EVENT_ACTION_REMOVE); | |||
// The "write" event is added and removed as we write, however, we always |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Right, matching the changes in natsLibevent_Read
, thx for the explanation comment!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thx for the descriptive comments!
@dmitry-sles-novikov standing by for your confirmation |
The socket was closed by the NATS library itself, which could cause some issue when the event loop thread would still be polling it. We now defer to the event loop adapter to make sure that the event loop library is done polling before invoking a new function that will take care of closing the socket.
I have updated the event loop test (that simulates what our adapters are doing). The mockup event loop implementation is a bit too simplistic but should be ok for now. If we have issues, we would have to make the events a linked list.
Resolves #814
Signed-off-by: Ivan Kozlovic [email protected]