Closed bduffany closed 1 year ago
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?
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
.)