]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
pluginlib: Add per plugin IO timeout for backend.
authorRadosław Korzeniewski <radoslaw@korzeniewski.net>
Fri, 5 Nov 2021 15:12:34 +0000 (16:12 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:56 +0000 (13:56 +0200)
Backend can define compile in timeout value with the following variable:
`const uint32_t BACKEND_TIMEOUT = 0; // use default`
The value set at this variable defines a timeout in seconds which will
be applied to all recvbackend_data() and sendbackend_data() calls.
The value of zero (0) setup a default timeout of 3600 seconds.
Set it to zero if unsure.

bacula/src/plugins/fd/pluginlib/metaplugin.cpp
bacula/src/plugins/fd/pluginlib/metaplugin.h
bacula/src/plugins/fd/pluginlib/ptcomm.cpp
bacula/src/plugins/fd/pluginlib/ptcomm.h

index 713da99ce7d5f391446feb700324008e12847a11..1cb47a225cb417fbf79afb02530479648c51db9f 100644 (file)
@@ -469,6 +469,10 @@ bRC METAPLUGIN::run_backend(bpContext *ctx)
    /* setup communication channel */
    backend.ctx->set_bpipe(bp);
    DMSG(ctx, DINFO, "Backend executed at PID=%i\n", bp->worker_pid);
+
+   backend.ctx->set_timeout(BACKEND_TIMEOUT);
+   DMSG(ctx, DINFO, "setup backend timeout=%d\n", backend.ctx->get_timeout());
+
    return bRC_OK;
 }
 
index e9889d1875a157c10bba95652952b9e11ff01105..3479e04658981274c593d5c99617418e4b634ca5 100644 (file)
@@ -71,6 +71,7 @@ extern const int32_t CUSTOMCANCELSLEEP;         /// custom wait time for backend
 extern const bool ACCURATEPLUGINPARAMETER;      /// accurate parameter for plugin parameter
 extern const int ADDINCLUDESTRIPOPTION;         /// setup precompiled include path strip option
 extern const bool DONOTSAVE_FT_PLUGIN_CONFIG;   /// when set to `true` then Metaplugin won't save FT_PLUGIN_CONFIG as a first file during Full backup
+extern const uint32_t BACKEND_TIMEOUT;          /// define a custom timeout value in seconds for data exchange (read from or write to backend)
 
 /// defines if metaplugin should handle local filesystem restore with Bacula Core functions
 /// `false` means metaplugin will redirect local restore to backend
index 3979d139c3a2935d53233148f071342289689a45..5a41c84c423c4c120cdf812586cb0a0a230e6a13 100644 (file)
@@ -154,7 +154,7 @@ bool PTCOMM::recvbackend_data(bpContext *ctx, char *buf, int32_t nbytes)
    int rbytes = 0;
    struct timeval _timeout;
 
-   _timeout.tv_sec = PTCOMM_DEFAULT_TIMEOUT;
+   _timeout.tv_sec = m_timeout > 0 ? m_timeout : PTCOMM_DEFAULT_TIMEOUT;
    _timeout.tv_usec = 0;
 
    while (nbytes > 0)
index 2f5f17a315a8d63dedf954c3aab54028525bf38f..d8ae25fa350dd8365d86a225150f0dabbafa384e 100644 (file)
@@ -297,7 +297,19 @@ public:
     */
    inline bool is_abort_on_error() { return abort_on_error; }
 
-   inline void set_timeout(uint32_t timeout) { m_timeout = timeout; }
+   /**
+    * @brief Set the timeout value in seconds
+    *
+    * @param timeout a value in seconds
+    */
+   inline void set_timeout(uint32_t timeout) { m_timeout = timeout > 0 ? timeout : PTCOMM_DEFAULT_TIMEOUT; }
+
+   /**
+    * @brief Get the timeout object
+    *
+    * @return uint32_t a current value of the PTCOMM Timeout
+    */
+   inline uint32_t get_timeout() { return m_timeout; }
 };
 
 #endif   /* _PTCOMM_H_ */