You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.)
The text was updated successfully, but these errors were encountered:
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_ITioctl never returns in your usecase, or am I missing something?
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 callconn.Close()
and close the file descriptor withf.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 haveConnect()
return anil
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 forUdev
vs. polling /sys/block, likeWaitForReadyUdev
/WaitForReady
.)The text was updated successfully, but these errors were encountered: