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

client.Connect() never returns #1

Closed
bduffany opened this issue May 27, 2023 · 1 comment · Fixed by #3
Closed

client.Connect() never returns #1

bduffany opened this issue May 27, 2023 · 1 comment · Fixed by #3

Comments

@bduffany
Copy link

bduffany commented May 27, 2023

I am working on an application in which an nbd may be swapped out for another one, using a long-running client process (an agent running inside a VM).

The approach I'm thinking of using is to call client.Disconnect() then umount the nbd.

However, for my particular case, this repeated connect/disconnect approach would result in a goroutine leak, because client.Connect() never returns. It is getting stuck in the <-fatal channel recv at the end of the func, which never receives a fatal error even if I call conn.Close() and close the file descriptor with f.Close().

Is it possible to have this function return once the device is connected? (Maybe instead of the OnConnected callback, just always do the connection check, and have Connect() return a nil error if and only if the connection is established successfully. Or if it's desired to make the connection check optional, have a separate func to explicitly wait for the device to be ready. Maybe there could be separate funcs for Udev vs. polling /sys/block, like WaitForReadyUdev / WaitForReady.)

@pojntfx
Copy link
Owner

pojntfx commented Jul 1, 2023

Hi! Sorry, completely missed this. That is indeed an interesting problem you are facing, but since this is using the kernel's internal NBD cient there isn't too much I can do here since the underlying NBD_DO_IT ioctl never returns in your usecase, or am I missing something?

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 a pull request may close this issue.

2 participants