00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_gridftp.h"
00009 #include "adioi.h"
00010
00011 static globus_mutex_t lock;
00012 static globus_cond_t cond;
00013 static globus_bool_t delete_done, delete_success;
00014 static void delete_cb(void *myarg, globus_ftp_client_handle_t *handle, globus_object_t *error)
00015 {
00016
00017 if (error)
00018 {
00019 FPRINTF(stderr, "%s\n", globus_object_printable_to_string(error));
00020 }
00021 else
00022 {
00023 delete_success=GLOBUS_TRUE;
00024 }
00025 delete_done=GLOBUS_TRUE;
00026 }
00027
00028 void ADIOI_GRIDFTP_Delete(char *filename, int *error_code)
00029 {
00030 char myname[]="ADIOI_GRIDFTP_Delete";
00031 int myrank, nprocs;
00032 globus_ftp_client_handle_t handle;
00033 globus_result_t result;
00034
00035 *error_code = MPI_SUCCESS;
00036
00037 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
00038 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
00039
00040 globus_module_activate(GLOBUS_FTP_CLIENT_MODULE);
00041 result=globus_ftp_client_handle_init(&handle,GLOBUS_NULL);
00042
00043 if (result != GLOBUS_SUCCESS )
00044 {
00045 globus_err_handler("globus_ftp_client_handle_init",myname,result);
00046 *error_code= MPIO_Err_create_code(MPI_SUCCESS,
00047 MPIR_ERR_RECOVERABLE,
00048 myname, __LINE__,
00049 MPI_ERR_IO,
00050 "**io", "**io %s",
00051 globus_object_printable_to_string(globus_error_get(result)));
00052 return;
00053 }
00054
00055 delete_done=GLOBUS_FALSE;
00056 delete_success=GLOBUS_FALSE;
00057 result=globus_ftp_client_delete(&handle,filename,GLOBUS_NULL,delete_cb,GLOBUS_NULL);
00058 if (result != GLOBUS_SUCCESS )
00059 {
00060 globus_err_handler("globus_ftp_client_delete",myname,result);
00061 *error_code= MPIO_Err_create_code(MPI_SUCCESS,
00062 MPIR_ERR_RECOVERABLE,
00063 myname, __LINE__,
00064 MPI_ERR_IO,
00065 "**io", "**io %s",
00066 globus_object_printable_to_string(globus_error_get(result)));
00067 return;
00068 }
00069 globus_mutex_lock(&lock);
00070 while ( delete_done!=GLOBUS_TRUE )
00071 globus_cond_wait(&cond,&lock);
00072 globus_mutex_unlock(&lock);
00073 result=globus_ftp_client_handle_destroy(&handle);
00074 if (result != GLOBUS_SUCCESS )
00075 {
00076 globus_err_handler("globus_ftp_client_handle_destroy",myname,result);
00077 *error_code= MPIO_Err_create_code(MPI_SUCCESS,
00078 MPIR_ERR_RECOVERABLE,
00079 myname, __LINE__,
00080 MPI_ERR_IO,
00081 "**io", "**io %s",
00082 globus_object_printable_to_string(globus_error_get(result)));
00083 return;
00084 }
00085
00086 if ( delete_success!=GLOBUS_TRUE )
00087 {
00088 *error_code= MPIO_Err_create_code(MPI_SUCCESS,
00089 MPIR_ERR_RECOVERABLE,
00090 myname, __LINE__,
00091 MPI_ERR_IO,
00092 "**io", "**io %s",
00093 globus_object_printable_to_string(globus_error_get(result)));
00094 }
00095 }