nbdkit_shutdown3
Request shutdown or client disconnection
Usage
#include <nbdkit-plugin.h>void nbdkit_shutdown (void);void nbdkit_disconnect (int force);
Overview
Plugins and filters can call exit(3) in the configuration phase (before and including ".get_ready", but not in connected callbacks).
Once nbdkit has started serving connections, plugins and filters should not call exit(3). However they may instruct nbdkit to shut down by calling "nbdkit_shutdown", or to disconnect a single client by calling "nbdkit_disconnect".
nbdkit_shutdown
"nbdkit_shutdown" requests nbdkit to shut down asynchronously and returns (note that it does not exit the process immediately).
It ensures that the plugin and all filters are unloaded cleanly which may take some time. Further callbacks from nbdkit into the plugin or filter may occur after you have called this.
nbdkit_disconnect
"nbdkit_disconnect" requests that the current client connection be disconnected. It does not affect other connections, and it does not stop the same client from trying to reconnect.
It is only useful from connected callbacks — that is, after (but not including) ".open", and before ".close". To reject a client in ".preconnect", ".open" or ".list_exports" you should return an error instead.
If "force" is true, nbdkit will disconnect the client immediately, and the client will not receive any response to the current command or any other commands in flight in parallel threads. If "force" is false, nbdkit will not accept any new commands from the client (failing all commands other than "NBD_CMD_DISC" with "ESHUTDOWN"), but will allow existing commands to complete gracefully. Either way, the next callback for the current connection should be ".close".
Language bindings
In nbdkit-ocaml-plugin(3):
NBDKit.shutdown : unit -> unitNBDKit.disconnect : bool -> unit
import nbdkitnbdkit.shutdown()nbdkit.disconnect(force)
In nbdkit-rust-plugin(3):
use nbdkit::*;pub fn shutdown()pub fn disconnect(force: bool)
In nbdkit-sh-plugin(3), there are various magic error codes that can be returned to indicate that shutdown or disconnection is needed. See that documentation for a full description.