This source file includes following definitions.
- delete_cb
- ADIOI_GRIDFTP_Delete
1
2
3
4
5
6
7
8 #include "ad_gridftp.h"
9 #include "adioi.h"
10
11 static globus_mutex_t lock;
12 static globus_cond_t cond;
13 static globus_bool_t delete_done, delete_success;
14 static void delete_cb(void *myarg, globus_ftp_client_handle_t *handle, globus_object_t *error)
15 {
16
17 if (error)
18 {
19 FPRINTF(stderr, "%s\n", globus_object_printable_to_string(error));
20 }
21 else
22 {
23 delete_success=GLOBUS_TRUE;
24 }
25 delete_done=GLOBUS_TRUE;
26 }
27
28 void ADIOI_GRIDFTP_Delete(char *filename, int *error_code)
29 {
30 char myname[]="ADIOI_GRIDFTP_Delete";
31 int myrank, nprocs;
32 globus_ftp_client_handle_t handle;
33 globus_result_t result;
34
35 *error_code = MPI_SUCCESS;
36
37 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
38 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
39
40 globus_module_activate(GLOBUS_FTP_CLIENT_MODULE);
41 result=globus_ftp_client_handle_init(&handle,GLOBUS_NULL);
42
43 if (result != GLOBUS_SUCCESS )
44 {
45 globus_err_handler("globus_ftp_client_handle_init",myname,result);
46 *error_code= MPIO_Err_create_code(MPI_SUCCESS,
47 MPIR_ERR_RECOVERABLE,
48 myname, __LINE__,
49 MPI_ERR_IO,
50 "**io", "**io %s",
51 globus_object_printable_to_string(globus_error_get(result)));
52 return;
53 }
54
55 delete_done=GLOBUS_FALSE;
56 delete_success=GLOBUS_FALSE;
57 result=globus_ftp_client_delete(&handle,filename,GLOBUS_NULL,delete_cb,GLOBUS_NULL);
58 if (result != GLOBUS_SUCCESS )
59 {
60 globus_err_handler("globus_ftp_client_delete",myname,result);
61 *error_code= MPIO_Err_create_code(MPI_SUCCESS,
62 MPIR_ERR_RECOVERABLE,
63 myname, __LINE__,
64 MPI_ERR_IO,
65 "**io", "**io %s",
66 globus_object_printable_to_string(globus_error_get(result)));
67 return;
68 }
69 globus_mutex_lock(&lock);
70 while ( delete_done!=GLOBUS_TRUE )
71 globus_cond_wait(&cond,&lock);
72 globus_mutex_unlock(&lock);
73 result=globus_ftp_client_handle_destroy(&handle);
74 if (result != GLOBUS_SUCCESS )
75 {
76 globus_err_handler("globus_ftp_client_handle_destroy",myname,result);
77 *error_code= MPIO_Err_create_code(MPI_SUCCESS,
78 MPIR_ERR_RECOVERABLE,
79 myname, __LINE__,
80 MPI_ERR_IO,
81 "**io", "**io %s",
82 globus_object_printable_to_string(globus_error_get(result)));
83 return;
84 }
85
86 if ( delete_success!=GLOBUS_TRUE )
87 {
88 *error_code= MPIO_Err_create_code(MPI_SUCCESS,
89 MPIR_ERR_RECOVERABLE,
90 myname, __LINE__,
91 MPI_ERR_IO,
92 "**io", "**io %s",
93 globus_object_printable_to_string(globus_error_get(result)));
94 }
95 }