Skip to content
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

ifdestroy can block #5

Closed
wants to merge 1 commit into from
Closed

ifdestroy can block #5

wants to merge 1 commit into from

Conversation

djnz00
Copy link
Contributor

@djnz00 djnz00 commented Apr 17, 2014

Currently ifdestroy blocks indefinitely in pthread_join().
The file descriptor needs to be closed before the pthread_join(), since the receiver thread is probably blocked in poll() and will not unblock until the FD is closed and poll() returns with an error.
Another method would be to add a shutdown pipe to the poll FD set, but that is overkill since closing the FD aborts the poll anyway.
The above fixes the hang, but there is still a memory leak since closing the FD does not unmap the ring buffer. Once the thread has safely exited, the ring buffer must be unmapped using munmap().

@anttikantee
Copy link
Member

Closing the fd first exposes a race condition. Something might open another fd before the receiver sees "dying". I think the current code has its heritage in another implementation where there was a poll timeout, so no hang would happen.

I've actually fixed this the way you describe here:
http://nxr.netbsd.org/xref/src/sys/rump/net/lib/libvirtif/virtif_user.c#254

@djnz00 djnz00 closed this May 7, 2014
@djnz00 djnz00 deleted the fixed_ifdestroy branch May 7, 2014 08:05
@anttikantee
Copy link
Member

But this is not fixed yet, right? Let's keep an issue open until it is.

@anttikantee anttikantee changed the title fixed ifdestroy ifdestroy can block May 7, 2014
@anttikantee
Copy link
Member

Hrmph, apparently I can't reopen this. I'll file a new issue.

@anttikantee anttikantee mentioned this pull request May 7, 2014
@djnz00
Copy link
Contributor Author

djnz00 commented May 7, 2014

Sorry about that. I closed it because my patch wasn't going in and I
thought we'd end up with the pipe solution under a different ticket. -Huw

On Wed, May 7, 2014 at 8:35 PM, Antti Kantee [email protected]:

Hrmph, apparently I can't reopen this. I'll file a new issue.


Reply to this email directly or view it on GitHubhttps://github.com//pull/5#issuecomment-42416355
.

@anttikantee
Copy link
Member

Sure, it might be, but until it is, it's nice to explicitly list open problems, just in case someone else meanwhile runs into the same problem. Overdocumentation is rarely a problem ;-)

Anyway, no biggie.

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