root/ompi/mca/io/romio321/romio/adio/ad_gridftp/ad_gridftp_fcntl.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. fcntl_size_cb
  2. ADIOI_GRIDFTP_Fcntl

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 2003 University of Chicago, Ohio Supercomputer Center. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "ad_gridftp.h"
   9 #include "adioi.h"
  10 #include "adio_extern.h"
  11 
  12 globus_mutex_t fcntl_size_lock;
  13 globus_cond_t fcntl_size_cond;
  14 globus_bool_t fcntl_size_done;
  15 
  16 void fcntl_size_cb(void *myargs, globus_ftp_client_handle_t *handle,
  17                   globus_object_t *error)
  18 {
  19     if (error)
  20         {
  21             FPRINTF(stderr, "%s\n", globus_object_printable_to_string(error));
  22         }
  23     globus_mutex_lock(&fcntl_size_lock);
  24     fcntl_size_done=GLOBUS_TRUE;
  25     globus_cond_signal(&fcntl_size_cond);
  26     globus_mutex_unlock(&fcntl_size_lock);
  27 }
  28 
  29 void ADIOI_GRIDFTP_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, 
  30                         int *error_code)
  31 {
  32     MPI_Datatype copy_etype, copy_filetype;
  33     int combiner, i, j, k, filetype_is_contig, err;
  34     ADIOI_Flatlist_node *flat_file;
  35     char myname[]="ADIOI_GRIDFTP_Fcntl";
  36 
  37     int myrank, nprocs;
  38 
  39     *error_code = MPI_SUCCESS;
  40 
  41     MPI_Comm_size(fd->comm, &nprocs);
  42     MPI_Comm_rank(fd->comm, &myrank);
  43 
  44     switch(flag) {
  45     case ADIO_FCNTL_GET_FSIZE:
  46         {
  47             globus_result_t result;
  48             globus_off_t fsize=0;
  49             
  50             globus_mutex_init(&fcntl_size_lock,GLOBUS_NULL);
  51             globus_cond_init(&fcntl_size_cond,GLOBUS_NULL);
  52             fcntl_size_done=GLOBUS_FALSE;
  53             if ( (result=globus_ftp_client_size(&(gridftp_fh[fd->fd_sys]),
  54                                                 fd->filename,
  55                                                 &(oattr[fd->fd_sys]),
  56                                                 &(fsize),
  57                                                 fcntl_size_cb,
  58                                                 GLOBUS_NULL))!=GLOBUS_SUCCESS )
  59                 {
  60                     globus_err_handler("globus_ftp_client_size",myname,result);
  61                     *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  62                                     MPIR_ERR_RECOVERABLE,
  63                                     myname, __LINE__, MPI_ERR_IO,
  64                                     "**io", "**io %s", 
  65                                     globus_object_printable_to_string(globus_error_get(result)));
  66                     return;
  67                 }
  68             globus_mutex_lock(&fcntl_size_lock);
  69             while ( fcntl_size_done!=GLOBUS_TRUE )
  70                 globus_cond_wait(&fcntl_size_lock,&fcntl_size_cond);
  71             globus_mutex_unlock(&fcntl_size_lock);
  72             globus_mutex_destroy(&fcntl_size_lock);
  73             globus_cond_destroy(&fcntl_size_cond);
  74             fcntl_struct->fsize=fsize;
  75         }
  76         *error_code = MPI_SUCCESS;
  77         break;
  78 
  79     case ADIO_FCNTL_SET_DISKSPACE:
  80         ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code);
  81         break;
  82 
  83     case ADIO_FCNTL_SET_ATOMICITY:
  84     default:
  85         *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  86                         MPIR_ERR_RECOVERABLE,
  87                         myname, __LINE__,
  88                         MPI_ERR_ARG,
  89                         "**flag", "**flag %d", flag);
  90     }
  91 }

/* [<][>][^][v][top][bottom][index][help] */