Grid Community Toolkit  6.2.1567772254 (tag: v6.2.20190906)
globus_ftp_client_restart_plugin.example

The following example illustrates a typical use of the restart plugin. In this case, we configure a plugin instance to restart the operation for up to an hour, using an exponential back-off between retries.

#include "globus_ftp_client.h"
#include "globus_ftp_client_restart_plugin.h"
#include "globus_time.h"
int
main(int argc, char *argv[])
{
globus_ftp_client_plugin_t restart_plugin;
globus_ftp_client_handleattr_t handleattr;
globus_ftp_client_handle_t handle;
globus_abstime_t deadline;
globus_module_activate(GLOBUS_FTP_CLIENT_MODULE);
globus_module_activate(GLOBUS_FTP_CLIENT_RESTART_PLUGIN_MODULE);
/* Set a deadline to be now + 1 hour */
GlobusAbstimeSet(deadline, 60 * 60, 0);
/* initialize a plugin with this deadline */
globus_ftp_client_restart_plugin_init(
&restart_plugin,
0, /* # retry limit (0 means don't limit) */
GLOBUS_NULL, /* interval between retries--null means
* exponential backoff
*/
&deadline);
/* Set up our handle to use the new plugin */
globus_ftp_client_handleattr_init(&handleattr);
globus_ftp_client_handleattr_add_plugin(&handleattr, &restart_plugin);
globus_ftp_client_handle_init(&handle, &handleattr);
/*
* Now, if a fault occurs processing this get, the plugin will restart
* it with an exponential back-off, and will bail if a fault occurs
* after 1 hour of retrying
*/
globus_ftp_client_get(&handle,
"ftp://ftp.globus.org/pub/globus/README",
GLOBUS_NULL,
GLOBUS_NULL,
callback_fn,
GLOBUS_NULL);
}