go-nfs
go-nfs copied to clipboard
add handler call on unmounts
Allow handlers to correlate Mount
and Unmount
events to free resources like file handles when a client disconnects.
upon testing, it looks like the unmount
RPC call is only made when the nfs session has authentication. In the null authentication that's mostly being used, the unmounting of the device may (at least for linux clients) only be signaled through the closing of the TCP connection.
Hey @willscott - thanks for this great library! How can I help in pushing this one past the finish line?
PR welcome :) - i think it's probably not as drafted here, but rather on seeing the network connection terminate
@willscott that's a good idea, but from my experience with TCP in Go, I don't know that there's a safe cross-platform way (looking at you, Windows!) to check TCP connection "liveness".
The only reliable way to tell if a connection is truly open, is to try to read from it (>0 bytes), which introduces its own set of complexities.
See recap of the problem on go-sql-driver/mysql 's attempt at the same.
Additionally, naive question regarding NFS implementations in the wild:
Will closing a TCP connection to a server necessarily mean explicit unmounting?
I can imagine an NFS client driver closing idle connections after a while of inactivity and reconnecting on demand when accessed by the user. Perhaps the connection tracks state that forbids this?
I think your concern is probably why there isn't a clear Unmount
event that makes sense. The decision to unmount in a stateless protocol like NFS ends up being a hybrid between the server's policy on when to clean up state and clients signalling explicit disconnects.
I think there may be a useful event to raise to handlers on these explicit disconnects when they are signaled by clients, and that's probably what this should be, with the understanding that it won't be "complete"