1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#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);
}
|