sh: Enable parallel thread model, when possible
commit02786baf5aca7c3553085e0958dbda99bcc028c7
authorEric Blake <eblake@redhat.com>
Fri, 2 Aug 2019 21:47:15 +0000 (2 16:47 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 2 Aug 2019 22:36:28 +0000 (2 17:36 -0500)
tree74831fd71def6ced193e3a0b25ef2f9b308c553f
parentb5b38e4e585ec5f22ea86feba6260b314f803559
sh: Enable parallel thread model, when possible

When we first created the sh plugin, we copied the thread model used
in most other language bindings of SERIALIZE_ALL_REQUESTS, because it
was easier to reason about and there was no way for a script to
override our choice.  However, we've since added support for scripts
to request a tighter model when needed, and we've also just fixed
remaining bugs about fds inadvertently leaked into the shell script
(at least, when pipe2 and accept4 are supported).  And the shell
itself is sufficiently expressive (even if not necessarily the most
efficient) for two scripts to come up with ways to enforce mutual
exclusion (for example, a script can use the success or failure of
'mkdir' on a coordinated filename to learn if it is first past the
gate, or set up FIFOs for interprocess communication).  Still, for
backwards-compatibility, this has to be something that the shell
script opts in to, rather than changing the default.

Many existing uses of shell scripts are tweaked to demonstrate the use
of opting in to parallel, and test-dump-plugin is massaged to show
both raising and lowering the thread model, modulo a capped maximum on
Haiku due to atomic CLOEXEC problems.  Meanwhile, the new
test-parallel-sh.sh test copies heavily from test-parallel-file.sh.

Signed-off-by: Eric Blake <eblake@redhat.com>
docs/nbdkit-loop.pod
plugins/sh/example.sh
plugins/sh/nbdkit-sh-plugin.pod
plugins/sh/sh.c
tests/Makefile.am
tests/test-cacheextents.sh
tests/test-dump-plugin.sh
tests/test-parallel-sh.sh [new file with mode: 0755]
tests/test-sh-extents.sh
tests/test-shell.sh