Make rpc_disconnect() a no-op if the session is already disconnected

This addresses a bug causing a segfault if we destroy the nfs context/
disconnect the session while the mount_8_cb callbacks for checking the
filehandle for nested mountpoints are still in flight.

Issue found and reported by doktorstick

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
libnfs-4.0.0-vitalif
Ronnie Sahlberg 2016-07-05 13:18:17 -07:00
parent 28e01e67b1
commit fac3a95453
1 changed files with 4 additions and 0 deletions

View File

@ -583,6 +583,10 @@ int rpc_disconnect(struct rpc_context *rpc, const char *error)
{
assert(rpc->magic == RPC_CONTEXT_MAGIC);
/* Do not re-disconnect if we are already disconnected */
if (!rpc->is_connected) {
return 0;
}
rpc_unset_autoreconnect(rpc);
if (rpc->fd != -1) {