]> git.proxmox.com Git - mirror_qemu.git/commit - qemu-nbd.c
nbd: fix assert() on qemu-nbd stop
authorPavel Butsykin <pbutsykin@virtuozzo.com>
Thu, 14 Apr 2016 10:20:15 +0000 (13:20 +0300)
committerMax Reitz <mreitz@redhat.com>
Fri, 15 Apr 2016 15:56:56 +0000 (17:56 +0200)
commit23994a5f524aa575c7a4b2e5250f17b127d2cf2f
tree2130464a53b0b2a12ab9a3251006dcb4acdb952e
parent200650d49f558d8394625ef7ee452a093efdb921
nbd: fix assert() on qemu-nbd stop

From time to time qemu-nbd is crashing on the following assert:
    assert(state == TERMINATING);
    nbd_export_closed
    nbd_export_put
    main
and the state at the moment of the crash is evaluated to TERMINATE.

During shutdown process of the client the nbd_client_thread thread sends
SIGTERM signal and the main thread calls the nbd_client_closed callback.
If the SIGTERM callback will be executed after change the state to
TERMINATING, then the state will once again be TERMINATE.

To solve the issue, we must change the state to TERMINATE only if the state
is RUNNING. In the other case we are shutting down already.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1460629215-11567-1-git-send-email-den@openvz.org
Signed-off-by: Max Reitz <mreitz@redhat.com>
qemu-nbd.c