diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-08-22 18:45:12 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-09-19 15:26:28 +0200 |
commit | ff2b68aa70d10b7eae813b04e9a23723dbd89ebd (patch) | |
tree | 3ddaf5829ccd5d60a14345cf0d5d6c4981bf6d2d /nbd.h | |
parent | ce33967af74523685c7f911f6576c689728fcc81 (diff) | |
download | qemu-ff2b68aa70d10b7eae813b04e9a23723dbd89ebd.zip qemu-ff2b68aa70d10b7eae813b04e9a23723dbd89ebd.tar.gz qemu-ff2b68aa70d10b7eae813b04e9a23723dbd89ebd.tar.bz2 |
nbd: do not leak nbd_trip coroutines when a connection is torn down
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: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'nbd.h')
-rw-r--r-- | nbd.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -84,6 +84,7 @@ void nbd_export_close(NBDExport *exp); NBDClient *nbd_client_new(NBDExport *exp, int csock, void (*close)(NBDClient *)); +void nbd_client_close(NBDClient *client); void nbd_client_get(NBDClient *client); void nbd_client_put(NBDClient *client); |