DMSG2(ctx, DDEBUG, "handle_plugin_restoreobj: %s %d\n", rop->object_name, rop->object_type);
- // if (strcmp(rop->object_name, INI_RESTORE_OBJECT_NAME) == 0) {
- if (strcmp(rop->object_name, INI_RESTORE_OBJECT_NAME) == 0 && (rop->object_type == FT_PLUGIN_CONFIG || rop->object_type == FT_PLUGIN_CONFIG_FILLED)) {
-
+ // do not handle FT_PLUGIN_CONFIG when no one was saved by default
+ if (!DONOTSAVE_FT_PLUGIN_CONFIG && strcmp(rop->object_name, INI_RESTORE_OBJECT_NAME) == 0 &&
+ (rop->object_type == FT_PLUGIN_CONFIG || rop->object_type == FT_PLUGIN_CONFIG_FILLED))
+ {
DMSG(ctx, DINFO, "INIcmd: %s\n", rop->plugin_name);
ini.clear_items();
return bRC_Error;
}
- /* The first file in Full backup, is the RestoreObject */
- if (!estimate && mode == BACKUP_FULL && pluginconfigsent == false) {
- ConfigFile ini;
- ini.register_items(plugin_items_dump, sizeof(struct ini_items));
- sp->restore_obj.object_name = (char *)INI_RESTORE_OBJECT_NAME;
- sp->restore_obj.object_len = ini.serialize(robjbuf.handle());
- sp->restore_obj.object = robjbuf.c_str();
- sp->type = FT_PLUGIN_CONFIG;
- DMSG2(ctx, DINFO, "Prepared RestoreObject/%s (%d) sent.\n", INI_RESTORE_OBJECT_NAME, FT_PLUGIN_CONFIG);
- return bRC_OK;
+ if (!DONOTSAVE_FT_PLUGIN_CONFIG)
+ {
+ /* The first file in Full backup, is the RestoreObject */
+ if (!estimate && mode == BACKUP_FULL && pluginconfigsent == false) {
+ ConfigFile ini;
+ ini.register_items(plugin_items_dump, sizeof(struct ini_items));
+ sp->restore_obj.object_name = (char *)INI_RESTORE_OBJECT_NAME;
+ sp->restore_obj.object_len = ini.serialize(robjbuf.handle());
+ sp->restore_obj.object = robjbuf.c_str();
+ sp->type = FT_PLUGIN_CONFIG;
+ DMSG2(ctx, DINFO, "Prepared RestoreObject/%s (%d) sent.\n", INI_RESTORE_OBJECT_NAME, FT_PLUGIN_CONFIG);
+ return bRC_OK;
+ }
}
// check if this is the first file from backend to backup
}
}
- if (!estimate){
+ if (!estimate && !DONOTSAVE_FT_PLUGIN_CONFIG)
+ {
/* The current file was the restore object, so just ask for the next file */
- if (mode == BACKUP_FULL && pluginconfigsent == false) {
+ if (mode == BACKUP_FULL && pluginconfigsent == false)
+ {
pluginconfigsent = true;
return bRC_More;
}
extern const char *PLUGIN_DESCRIPTION;
// Plugin linking time variables
-extern const char *PLUGINPREFIX; /// is used for prefixing every Job and Debug messages generted by a plugin
-extern const char *PLUGINNAME; /// should match the backend $pluginname$ used for Handshake procedure
-extern const bool CUSTOMNAMESPACE; /// defines if metaplugin should send `Namespace=...` backend plugin parameter using PLUGINNAMESPACE variable
-extern const bool CUSTOMPREVJOBNAME; /// defines if metaplugin should send `PrevJobName=...` backend plugin parameter from bacula variable
-extern const char *PLUGINNAMESPACE; /// custom backend plugin namespace used as file name prefix
-extern const char *PLUGINAPI; /// the plugin api string which should match backend expectations
-extern const char *BACKEND_CMD; /// a backend execution command path
-extern const int32_t CUSTOMCANCELSLEEP; /// custom wait time for backend between USR1 and terminate procedures
-extern const bool ACCURATEPLUGINPARAMETER; /// accurate parameter for plugin parameter
-extern const int ADDINCLUDESTRIPOPTION; /// setup precompiled include path strip option
+extern const char *PLUGINPREFIX; /// is used for prefixing every Job and Debug messages generted by a plugin
+extern const char *PLUGINNAME; /// should match the backend $pluginname$ used for Handshake procedure
+extern const bool CUSTOMNAMESPACE; /// defines if metaplugin should send `Namespace=...` backend plugin parameter using PLUGINNAMESPACE variable
+extern const bool CUSTOMPREVJOBNAME; /// defines if metaplugin should send `PrevJobName=...` backend plugin parameter from bacula variable
+extern const char *PLUGINNAMESPACE; /// custom backend plugin namespace used as file name prefix
+extern const char *PLUGINAPI; /// the plugin api string which should match backend expectations
+extern const char *BACKEND_CMD; /// a backend execution command path
+extern const int32_t CUSTOMCANCELSLEEP; /// custom wait time for backend between USR1 and terminate procedures
+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
/// defines if metaplugin should handle local filesystem restore with Bacula Core functions
/// `false` means metaplugin will redirect local restore to backend
return;
}
+ struct timeval _timeout;
_timeout.tv_sec = 0;
_timeout.tv_usec = 1000;
{
int status;
int rbytes = 0;
+ struct timeval _timeout;
_timeout.tv_sec = PTCOMM_DEFAULT_TIMEOUT;
_timeout.tv_usec = 0;
{
int status;
int wbytes = 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)
bool f_cont; // when we are reading next part of data packet */
bool abort_on_error; // abort on error flag */
int32_t remaininglen; // the number of bytes to read when `f_cont` is true
- struct timeval _timeout; // a timeout when waiting for data to read from backend
+ uint32_t m_timeout; // a timeout when waiting for data to read from backend, in seconds
protected:
bool recvbackend_data(bpContext *ctx, char *buf, int32_t nbytes);
f_fatal(false),
f_cont(false),
abort_on_error(false),
- remaininglen(0)
+ remaininglen(0),
+ m_timeout(PTCOMM_DEFAULT_TIMEOUT)
{}
#if __cplusplus > 201103L
PTCOMM(PTCOMM &) = delete;
* @return true if flag is set
* @return false if flag is not set
*/
- bool is_abort_on_error() { return abort_on_error; }
+ inline bool is_abort_on_error() { return abort_on_error; }
+
+ inline void set_timeout(uint32_t timeout) { m_timeout = timeout; }
};
#endif /* _PTCOMM_H_ */