Hello,

You should wait for eof in data_callback_read in addition to done_cb before setting monitor.done. It is very possible to get done_cb before the final data_callback_read.

Mike

On 6/25/2012 4:26 AM, shobhit puri wrote:
Hello

I hope you are doing well. I am unable to read/write any file greater
than a particular size which is coming ~100Kb. The program gets terminated.
I would be highly thankful to you if you please tell that what can be
the logic behind this error and where I might be getting wrong. It will
help me to work around it, with my code in that direction.
For support I am writing the following is the code sniplet of my Globus
get/read function. I am using globus gridftp client API:


int grid_ftp_server_client_get(char read_buffer[BUFFER_SIZE], char *url,
int partial_offset, int partial_end_offset){

     globus_result_t res;
     globus_ftp_client_operationattr_t attr;
     globus_ftp_client_handleattr_t hattr;

     globus_mutex_init(&monitor[7].mutex, NULL);
     globus_cond_init(&monitor[7].cond, NULL);

     globus_ftp_client_restart_marker_t marker;
     if (globus_ftp_client_restart_marker_init(&marker)!= GLOBUS_SUCCESS) {
          globus_libc_printf("\n\t\t ERROR : Failed to initialize the
restart marker\n");
          return -1;
     }

     globus_mutex_lock(&monitor[7].mutex);
     {
         globus_ftp_client_operationattr_init(&attr);
         globus_ftp_client_operationattr_set_authorization("###
Authorization string ###" );
         globus_ftp_client_handleattr_init(&hattr);
         globus_ftp_client_handle_init(&handle[7],&hattr);

         res =
globus_ftp_client_partial_get(&handle[7],url,&attr,&marker,partial_offset,partial_end_offset,get_file_done_cb,
&monitor[7]);
         if (res != GLOBUS_SUCCESS) {
             globus_object_t * err;
             err = globus_error_get(res);
             globus_libc_printf( "\n ERROR : %s",
globus_object_printable_to_string(err));
             monitor[7].done= GLOBUS_TRUE;
         }else{

             monitor[7].done = GLOBUS_FALSE;

globus_ftp_client_register_read(&handle[7],read_buffer,BUFFER_SIZE,data_callback_read,0);
         }

         while(!monitor[7].done) {
             fprintf(stdout, "waiting in globus get...\n");
             globus_cond_wait(&monitor[7].cond, &monitor[7].mutex);
         }

         globus_ftp_client_operationattr_destroy(&attr);
         globus_ftp_client_handleattr_destroy(&hattr);
         globus_ftp_client_handle_destroy(&handle[7]);
     }
     globus_mutex_unlock(&monitor[7].mutex);
     return 0;
}

void data_callback_read(void* user_arg ,globus_ftp_client_handle_t*
n_handle, globus_object_t* err, globus_byte_t* buffer_t, globus_size_t
length, globus_off_t offset, globus_bool_t eof)
{
     if (!eof ) {
         globus_ftp_client_register_read(n_handle, buffer_t,
BUFFER_SIZE, data_callback_read, 0);
     }
}



The following is the debug output ( Note I am using it along with FUSE):

*Inside globus get
*unique: 29, opcode: OPEN (14), nodeid: 3, insize: 48
    unique: 29, success, outsize: 32
unique: 30, opcode: READ (15), nodeid: 3, insize: 80
read[0] 65536 bytes from 0 flags: 0x8000
*waiting in globus get...
waiting in globus get...
waiting in globus get...
Signaling the wait
size read: 65536
*   read[0] 65536 bytes from 0
    unique: 30, success, outsize: 65552
unique: 31, opcode: READ (15), nodeid: 3, insize: 80
read[0] 131072 bytes from 65536 flags: 0x8000

* Inside globus get
waiting in globus get...
waiting in globus get...
*unique: 32, opcode: READ (15), nodeid: 3, insize: 80
read[0] 32768 bytes from 196608 flags: 0x8000

  Inside globus get
waiting in globus get...


Thanks a lot in advance.
Best Regards
--
Shobhit Puri
Fourth Year Undergraduate Student
Department of Information Technology
Indian Institute of Information Technology, Allahabad, India
Currently Intern at Karlsruhe Institute of Technology, Karlsruhe, Germany
Email: [email protected] <mailto:[email protected]>,
[email protected] <mailto:[email protected]>
Phone: +49-15210578547, +91-9457011377


Reply via email to