nbdkit_shutdown() is a harsh hammer (it kills the entire server);
sometimes in testing, it is more useful to disconnect just one client
while keeping the server responsive to a reconnect request. Start
this by implementing a new API and putting it to use in the
blocksize-policy filter. I also have a pending libnbd series that
plans to make use of this feature addition in its testsuite for
proving a bug-fix for libnbd not obeying qemu's 32M block_maximum
sizing constraints.
Still to come as followup to this: Rich and I discussed on IRC how to
extend the sh/eval plugins to allow rapid-prototype testing of
requesting client disconnects. The idea we came up with was defining
exit status 4 (nbdkit_shutdown), 5 (nbdkit_disconnect(true)), and 6
(nbdkit_disconnect(false)) as new recognized return values from the
shell scriptlets. I'd probably also change the documentation to
reserve return status 7-15 as currently undefined (right now, only 7
is undefined and 8-15 are currently documented as behaving the same as
exit status 1). The chance of this affecting a real client of the sh
or eval plugin is minimal.
Eric Blake (4):
server: Switch connection status to enum
server: Give client EOF when we are done writing
api: Add nbdkit_disconnect(int)
blocksize-policy: Add blocksize-write-disconnect=N parameter
docs/nbdkit-plugin.pod | 17 ++-
.../nbdkit-blocksize-policy-filter.pod | 21 +++
include/nbdkit-common.h | 3 +-
tests/Makefile.am | 40 +++++-
server/internal.h | 19 ++-
server/connections.c | 57 ++++----
server/crypto.c | 22 +--
server/nbdkit.syms | 3 +-
server/protocol.c | 107 ++++++++-------
server/public.c | 15 ++-
server/test-public.c | 14 +-
plugins/ocaml/NBDKit.mli | 5 +-
plugins/ocaml/NBDKit.ml | 1 +
plugins/ocaml/bindings.c | 12 +-
plugins/python/modfunctions.c | 14 ++
plugins/rust/src/lib.rs | 6 +
filters/blocksize-policy/policy.c | 27 +++-
tests/test-blocksize-write-disconnect.sh | 107 +++++++++++++++
tests/test-disconnect-tls.sh | 126 ++++++++++++++++++
tests/test-disconnect.sh | 100 ++++++++++++++
tests/test-disconnect-plugin.c | 95 +++++++++++++
21 files changed, 709 insertions(+), 102 deletions(-)
create mode 100755 tests/test-blocksize-write-disconnect.sh
create mode 100755 tests/test-disconnect-tls.sh
create mode 100755 tests/test-disconnect.sh
create mode 100644 tests/test-disconnect-plugin.c
--
2.37.3