Skip to content

Conversation

hernando
Copy link
Contributor

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.

@hernando hernando requested review from dnachbaur and karjonas March 22, 2019 14:37
@@ -184,6 +186,8 @@ class DeflectPlugin::Impl
});

_pollHandle->start(uvw::PollHandle::Event::READABLE);

_stream->setDisconnectedCallback([&] { _pollHandle->stop(); });
Copy link
Contributor

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

Copy link
Contributor Author

@hernando hernando Mar 22, 2019

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just [_pollHandle] should work?!

Copy link
Contributor

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

Copy link
Contributor

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.
@dnachbaur dnachbaur force-pushed the fix_disconnect_abort branch from 240226b to 1b7d764 Compare March 25, 2019 16:35
@dnachbaur dnachbaur merged commit eae1d7f into master Mar 25, 2019
@dnachbaur dnachbaur deleted the fix_disconnect_abort branch March 25, 2019 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants