Skip to content
  • Paolo Bonzini's avatar
    nbd: do not leak nbd_trip coroutines when a connection is torn down · ff2b68aa
    Paolo Bonzini authored
    
    
    Because nbd_client_close removes the I/O handlers for the client
    socket, there is no way that any suspended coroutines are restarted.
    This will be a problem with the QEMU embedded NBD server, because
    we will have a QMP command to forcibly close all connections with
    the clients.
    
    Instead, we can exploit the reference counting of NBDClients; shutdown the
    client socket, which will make it readable and writeable.  Also call the
    close callback, which will release the user's reference.  The coroutines
    then will fail and exit cleanly, and release all remaining references,
    until the last refcount finally triggers the closure of the client.
    
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    ff2b68aa