-
Notifications
You must be signed in to change notification settings - Fork 34
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
feat(listener): close with timeout #198
Conversation
Pull Request Test Coverage Report for Build 5934931546
💛 - Coveralls |
l_ctx->is_closed = TRUE; | ||
enif_mutex_unlock(l_ctx->lock); | ||
|
||
// It is safe to close it without holding the lock | ||
// This also ensures no ongoing listener callbacks | ||
// This is a blocking call. @TODO have async version or use dirty scheduler |
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.
was the TODO removed on purpose or by accident? (as it's not related to this change)
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.
We could use ListenerStop for async calls instead and keep ListenerCLose sync.
maybe it is a good time to add ListenerStop support.
I will update the PR.
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.
This is a blocking call but it is cheap, that is why the @todo is removed.
l_ctx->is_closed = TRUE; | ||
enif_mutex_unlock(l_ctx->lock); | ||
|
||
// It is safe to close it without holding the lock | ||
// This also ensures no ongoing listener callbacks | ||
// This is a blocking call. @TODO have async version or use dirty scheduler | ||
// This is a blocking call. | ||
// | ||
MsQuic->ListenerClose(l); |
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.
is it OK to close the listener if it was already closed? Or should it be better to return just after the critical section if ret != ATOM_OK?
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.
It is ok.
L476 set it to NULL and ListenerClose has _Pre_defensive_
annotation. So it will never trigger use-after-free.
case quicer_nif:close_listener(Listener) of | ||
ok -> | ||
receive | ||
{quic, listener_stopped, Listener} -> |
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.
The event is only shot to the Listener owner who opens the listener.
The timeout prevents long blocking on the caller who is not the owner.
maybe we should check the owner ship in NIF and return {error, not_owner}
also fix config resource leaks in listener
8759833
to
ca76eeb
Compare
replaced with #205 |
No description provided.