This filter retries a request on failure. Add a flag to make this
filter optional, but default to using it if available (so there's no
change to default behaviour).
The reason we want to make this option is that the next commit will
want to use nbdkit-ssh-plugin to probe to see if a remote file is
present, and we don't want to retry that probe on failure.
---
input/nbdkit_ssh.mli | 1 +
input/nbdkit_ssh.ml | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/input/nbdkit_ssh.mli b/input/nbdkit_ssh.mli
index bc798c5a73..daa20bb2a5 100644
--- a/input/nbdkit_ssh.mli
+++ b/input/nbdkit_ssh.mli
@@ -25,6 +25,7 @@ type password =
val create_ssh : ?bandwidth:Types.bandwidth ->
?cor:string ->
+ ?retry:bool ->
password:password ->
?port:string ->
server:string ->
diff --git a/input/nbdkit_ssh.ml b/input/nbdkit_ssh.ml
index 3f6da9b62d..3b72d3adb3 100644
--- a/input/nbdkit_ssh.ml
+++ b/input/nbdkit_ssh.ml
@@ -44,7 +44,8 @@ let error_unless_nbdkit_min_version config =
error_unless_nbdkit_version_ge config nbdkit_min_version
(* Create an nbdkit module specialized for reading from SSH sources. *)
-let create_ssh ?bandwidth ?cor ~password ?port ~server ?user path =
+let create_ssh ?bandwidth ?cor ?(retry=true)
+ ~password ?port ~server ?user path =
if not (Nbdkit.is_installed ()) then
error (f_"nbdkit is not installed or not working");
@@ -67,7 +68,8 @@ let create_ssh ?bandwidth ?cor ~password ?port ~server ?user path =
(* Retry filter (if it exists) can be used to get around brief
* interruptions in service. It must be closest to the plugin.
*)
- Nbdkit.add_filter_if_available cmd "retry";
+ if retry then
+ Nbdkit.add_filter_if_available cmd "retry";
(* Caching extents speeds up qemu-img, especially its consecutive
* block_status requests with req_one=1.
--
2.43.0