diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 8657b0ec6cbf8b3128cd61650784bbf157639d35..d7455b571d55a2584f3f3f3c572adc88b9f5782f 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -634,8 +634,11 @@ virNetClientMarkClose(virNetClientPtr client, VIR_DEBUG("client=%p, reason=%d", client, reason); if (client->sock) virNetSocketRemoveIOCallback(client->sock); - client->wantClose = true; - client->closeReason = reason; + /* Don't override reason that's already set. */ + if (!client->wantClose) { + client->wantClose = true; + client->closeReason = reason; + } }