File: globus_ftp_client_restart_plugin.example

package info (click to toggle)
globus-ftp-client 9.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,320 kB
  • sloc: ansic: 35,236; sh: 4,292; perl: 2,723; makefile: 271
file content (44 lines) | stat: -rw-r--r-- 1,429 bytes parent folder | download | duplicates (10)
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);
}