-
Notifications
You must be signed in to change notification settings - Fork 47
Handle unexpected Deflect server disconnections gracefully #751
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
Conversation
plugins/Deflect/DeflectPlugin.cpp
Outdated
@@ -184,6 +186,8 @@ class DeflectPlugin::Impl | |||
}); | |||
|
|||
_pollHandle->start(uvw::PollHandle::Event::READABLE); | |||
|
|||
_stream->setDisconnectedCallback([&] { _pollHandle->stop(); }); |
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.
capture _pollHandle
by copy, so it's always safe to be valid
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.
Since _pollHandle
is a member variable, and [&] captures this
be reference, this should be safe as well, shouldn't it?
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.
Not if _pollHandle
is destructed before _stream
? Also &
is capturing more than you need.
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.
I tried [=, _pollHandle], but it doesn't compile. I'll try to get back to this after the weekend.
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.
just [_pollHandle]
should work?!
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.
[pollHandle=_pollHandle]
does work in fact
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.
while testing and looking at the code again, it probably should capture the pollhandle by reference and also .reset()
it, so that _closeStream()
does not stop the handle again. I at least faced some error during a reconnect phase:
[INFO ] Closing Deflect stream
braynsService: src/unix/core.c:896: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
Aborted
This commit combined with 038e139 in Deflect master prevent an abort within libuv when the socket fd gets closed by QTcpSocket after a server side disconnect.
240226b
to
1b7d764
Compare
This commit combined with 038e139 in Deflect master prevent an
abort within libuv when the socket fd gets closed by QTcpSocket
after a server side disconnect.