On 13.08.20 18:29, Kevin Wolf wrote: > Closing export is somewhat convoluted because nbd_export_close() and > nbd_export_put() call each other and the ways they actually end up being > nested is not necessarily obvious. > > However, it is not really necessary to call nbd_export_close() from > nbd_export_put() when putting the last reference because it only does > three things: > > 1. Close all clients. We're going to refcount 0 and all clients hold a > reference, so we know there is no active client any more. > > 2. Close the user reference (represented by exp->name being non-NULL). > The same argument applies: If the export were still named, we would > still have a reference. > > 3. Freeing exp->description. This is really cleanup work to be done when > the export is finally freed. There is no reason to already clear it > while clients are still in the process of shutting down.
Convincing. > So after moving the cleanup of exp->description, the code can be > simplified so that only nbd_export_close() calls nbd_export_put(), but > never the other way around. > > Signed-off-by: Kevin Wolf <kw...@redhat.com> > --- > nbd/server.c | 17 ++++------------- > 1 file changed, 4 insertions(+), 13 deletions(-) Reviewed-by: Max Reitz <mre...@redhat.com>
signature.asc
Description: OpenPGP digital signature