Bug 3761 - globus_ftp_control library hangs at various places (depending on os)
: globus_ftp_control library hangs at various places (depending on os)
Status: NEW
: GridFTP
GridFTP
: 4.0.0
: PC Linux
: P3 normal
: ---
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2005-09-16 17:15 by
Modified: 2005-09-16 17:15 (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2005-09-16 17:15:54
The call  globus_ftp_control_server_accept seems to hangs then I am expecting
the callback for accept under RedHat 9 Liniux 2.4.2. 

Under Fedora Core 2 linux 2.6.10, I recieve the callback for the accept but not
for the authenticate. Unfortunately, the debugger can't seem to find the other
threads on that system. 

The documentation is a little scanty, so it is possible this is a configuration
error on my part, but given the different behavoir on different systems I find
this unlikely. I have included server and client code I have been using to test
this. The server simply listens,accepts and authenticates, the client simply
connects. 

I have tested this on gt4.0.0 as well as the latest from CVS

I have traced the freezing on the RedHat 9 bug to this mutex

***********************trace results***************************************
Breakpoint 2, globus_l_ftp_control_accept_cb (arg=0x41421618, handle=0x41421754,
result=0)
    at globus_ftp_control_server.c:1091
warning: Source file is more recent than executable.

1091        globus_object_t *                         error = GLOBUS_NULL;
(gdb) s
1094        globus_bool_t                             call_close_cb = GLOBUS_FALSE;
(gdb) s
1097        c_handle=(globus_ftp_control_handle_t *) arg;
(gdb) s
1098        cc_handle=&(c_handle->cc_handle);
(gdb) s
1100        if(result != GLOBUS_SUCCESS)
(gdb) s
1105        globus_mutex_lock(&(cc_handle->mutex));
(gdb) s
globus_mutex_lock (mut=0x414237b4) at globus_thread_pthreads.c:822
822         rc = globus_macro_mutex_lock(mut);
<<<freezes here


***********************************normal out with xio debuging
on************************************
split_server.c: 223: Done listen callback
[globus_xio_server_register_accept] Entering
[globus_l_xio_server_register_accept] I Entering
[globus_l_xio_server_register_accept:789] Op @ 0x805c328 ref increased to 2:
[globus_xio_driver_pass_accept] I Entering
[globus_xio_driver_pass_accept] I Exiting
[globus_l_xio_server_register_accept:800] Op @ 0x805c328 ref decreased to 1:
[globus_l_xio_server_register_accept] I Exiting
[globus_xio_server_register_accept] Exiting
[globus_i_xio_server_post_accept] I Entering
[globus_i_xio_server_post_accept:365] Op @ 0x805bcf0 ref decreased to 0:
[globus_i_xio_server_post_accept] I Exiting
[globus_l_xio_server_accept_kickout] I Exiting
[globus_i_xio_server_accept_callback] I Exiting
[globus_l_xio_driver_op_accept_kickout] I Exiting
[globus_xio_driver_finished_accept] I Exiting
[globus_l_xio_driver_open_op_kickout] I Entering
[globus_l_xio_open_close_callback] I Entering
[globus_l_xio_open_close_callback] : op@ 0x805c708 op->type=2 handle->state=3
[globus_l_xio_open_close_callback:846] Handle @ 0x805be78 state change:
    From:GLOBUS_XIO_HANDLE_STATE_OPENING
    to:  GLOBUS_XIO_HANDLE_STATE_OPEN
[globus_i_xio_timer_unregister_timeout] I Entering
[globus_i_xio_timer_unregister_timeout] I Exiting
[globus_l_xio_open_close_callback:875] Op @ 0x805c708 ref decreased to 2:
[globus_l_xio_open_close_callback:884] Op @ 0x805c708 state change:
    From:GLOBUS_XIO_OP_STATE_OPERATING
    to:  GLOBUS_XIO_OP_STATE_FINISH_WAITING
[globus_l_xio_open_close_callback_kickout] I Entering

*************************split_server.c ******************88888

/*
g++ -DDEBUG -lpthread -lglobus_ftp_client_gcc32dbgpthr
-lglobus_ftp_control_gcc32dbgpthr -L/usr/local/gt4/lib/
-I/usr/local/gt4/include/gcc32dbgpthr split_server.c -o split_server
*/

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>
#include "globus_ftp_client.h"
#include "globus_ftp_control.h"
#include <list>
#define ERROR -1;

#ifdef DEBUG
#define DPRINTF(s)  (fprintf(stderr,"%s: %d:
%s\n",__FILE__,__LINE__,s),fflush(stderr));
#define DPRINTF2(format,arg) char s[100]; sprintf(s,format,arg);
fprintf(stderr,"%s: %d: %s\n",__FILE__,__LINE__,s); 
#else
#define DPRINTF(s)
#define DPRINTF2(format,arg)
#endif

#define MUST_BE_SUCCESS(ret,msg)  if(ret!=GLOBUS_SUCCESS) { \
  fprintf(stderr,"%s: %d: %s \n",__FILE__,__LINE__,msg); \
  fprintf(stderr, "%s", globus_object_printable_to_string(globus_error_get(ret)));\
  exit(1);\
    }
unsigned short  listening_port=9000;
pthread_mutex_t done_lock=PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t done_condition= PTHREAD_COND_INITIALIZER;
bool done_all=false;

void resp_callback(void *callback_arg,
		    globus_ftp_control_handle_t* 	server_handle,
		   globus_object_t* 	error)
{
  printf("resp callback\n");
}

void auth_callback( void *	 callback_arg,
		    struct globus_ftp_control_handle_s* 	handle,
		    globus_object_t* 	error,
		    globus_ftp_control_auth_info_t* 	auth_result)
{
  DPRINTF("in auth callback\n");
  if(error!=GLOBUS_SUCCESS){
    fprintf(stderr,"Error getting connection in auth callback \n");
    fprintf(stderr,"%s\n",globus_object_printable_to_string((error)));
    DPRINTF("CONTINUTING DESPITE ERROR\n");
  }
  
  
  
}
void accept_callback(   void *callback_arg,
			globus_ftp_control_handle_t* 	control_handle,
			globus_object_t* 	error){
  
  globus_result_t ret;
  DPRINTF("in accept callback\n");
  if(error!=GLOBUS_SUCCESS){
    fprintf(stderr,"Error getting connection in listen callback \n");
    fprintf(stderr,"%s\n",globus_object_printable_to_string((error)));
    DPRINTF("CONTINUTING DESPITE ERROR\n");
  }
  globus_ftp_control_auth_requirements_t 	auth_requirements;
  auth_requirements=GLOBUS_FTP_CONTROL_AUTH_GSSAPI;
  DPRINTF("Calling auth\n");
  ret=globus_ftp_control_server_authenticate (  	
					      control_handle,
					      auth_requirements,
					      auth_callback,
					      NULL);
  if(ret != GLOBUS_SUCCESS)
    {
      fprintf(stderr,"error calling authenticate\n ");
      globus_object_t * err;
      err = globus_error_get(ret);
      fprintf(stderr, "%s", globus_object_printable_to_string(err));
    } 
  DPRINTF("Done Calling auth\n");
}





void listen_callback(  	
		     void *callback_arg,
		     globus_ftp_control_server_t* 	server_handle,
		     globus_object_t* 	error){
  
  globus_ftp_control_handle_t control_handle;
  globus_result_t ret;
  DPRINTF("in listen callback\n");
  if(error!=GLOBUS_SUCCESS){
    fprintf(stderr,"Error getting connection in listen callback \n");
    fprintf(stderr,"%s\n",globus_object_printable_to_string((error)));
    DPRINTF("CONTINUING DESPITE ERROR\n");
  }
  if(server_handle->state!=GLOBUS_FTP_CONTROL_SERVER_LISTENING)
    {
      DPRINTF("SERVER STATE NOT LISTENING");
      
    }
  //initialize control handle
  globus_ftp_control_handle_init(&control_handle);
  
  if(ret != GLOBUS_SUCCESS)
    {
      fprintf(stderr,"error initializing control handle\n ");
      globus_object_t * err;
      err = globus_error_get(ret);
      fprintf(stderr, "%s", globus_object_printable_to_string(err));
     
    } 
 
  DPRINTF("Accepting connection\n");
 
  ret=globus_ftp_control_server_accept(server_handle,
				       &control_handle,
				       accept_callback,
				       NULL);
   DPRINTF("Done Accepting connection\n");
   if(ret != GLOBUS_SUCCESS)
     {
       fprintf(stderr,"error calling accept\n ");
       globus_object_t * err;
       err = globus_error_get(ret);
       fprintf(stderr, "%s", globus_object_printable_to_string(err));
       
   } 
   
    while(!done_all){
     pthread_cond_wait(&done_condition,&done_lock);
   }
   pthread_mutex_unlock(&done_lock);
   DPRINTF("Done listen callback\n");
}

int start_listening(unsigned short port){

 globus_ftp_control_server_t server_handle;
  globus_result_t ret;
  DPRINTF2("Start istening on port %d",port);
  ret= globus_ftp_control_server_handle_init(&server_handle);
  MUST_BE_SUCCESS(ret,"Opening server_handle");
  ret= globus_ftp_control_server_listen(&server_handle,&port,listen_callback,NULL);
  MUST_BE_SUCCESS(ret,"server_listen");
  DPRINTF("Now listening\n");
  
  pthread_mutex_lock(&done_lock);
  while(!done_all){
    pthread_cond_wait(&done_condition,&done_lock);
  }
  pthread_mutex_unlock(&done_lock);
  return 0;

}

void print_usage(char* name){

  fprintf(stderr,"%s [-p port]\n",name);

}
void handle_command_line(int argc, char** argv){
 for(int i=1;i<argc;i++){

    if(argv[i][0]=='-')
      {
	
	switch(argv[i][1])
	  {
	  case 'p':  
	    listening_port=atoi(argv[++i]);
	    break;
	  default :
	    print_usage(argv[0]);
	    exit(1);	
	  }
      }
    else
      {
	print_usage(argv[0]); exit(1);

      }
    
 }

}

int main(int argc,char** argv){
  globus_result_t ret;
  printf("starting server\n");
  handle_command_line(argc,argv);
  ret=globus_module_activate(GLOBUS_COMMON_MODULE);  
  MUST_BE_SUCCESS(ret,"activaet ftp control module"); 
  ret=globus_module_activate(GLOBUS_FTP_CONTROL_MODULE);  //Initialize globus
control module 
  MUST_BE_SUCCESS(ret,"activaet ftp control module");  
  ret=globus_module_activate(GLOBUS_FTP_CLIENT_MODULE);   //Initialize globus
client module 
  MUST_BE_SUCCESS(ret,"activaet ftp CLIENT module");
  ret=globus_module_activate(GLOBUS_COMMON_MODULE);   //Initialize globus client
module 
  MUST_BE_SUCCESS(ret,"activaet ftp common module");

  start_listening(listening_port);
   
}

*******************************split_client2.c******************

/*
g++ -DDEBUG -lpthread -lglobus_ftp_client_gcc32dbgpthr
-lglobus_ftp_control_gcc32dbgpthr -L/usr/local/gt4/lib/
-I/usr/local/gt4/include/gcc32dbgpthr split_client2.c -o split_client2
*/

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>
#include "globus_ftp_client.h"
#include "globus_ftp_control.h"
#include <list>
#define ERROR -1;

#ifdef DEBUG
#define DPRINTF(s)  fprintf(stderr,"%s: %d: %s\n",__FILE__,__LINE__,s);
#define DPRINTF2(format,arg) char s[100]; sprintf(s,format,arg);
fprintf(stderr,"%s: %d: %s\n",__FILE__,__LINE__,s); 
#else
#define DPRINTF(s)
#define DPRINTF2(format,arg)
#endif


#define MUST_BE_SUCCESS(ret,msg)  if(ret!=GLOBUS_SUCCESS) { \
  fprintf(stderr,"%s: %d: %s \n",__FILE__,__LINE__,msg); \
  fprintf(stderr, "%s", globus_object_printable_to_string(globus_error_get(ret)));\
  exit(1);\
    }

unsigned short  listening_port=15007;
pthread_mutex_t done_lock=PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t done_condition= PTHREAD_COND_INITIALIZER;
bool done_all=false;

void auth_callback( void*	 callback_arg,
		      globus_ftp_control_handle_s* 	handle,
		      globus_object_t* 	error,
		      globus_ftp_control_response_t* 	auth_result)
{
  globus_result_t ret;
  DPRINTF("in auth callback\n");
  if(error!=GLOBUS_SUCCESS){
    fprintf(stderr,"Error getting connection in auth callback \n");
    fprintf(stderr,"%s\n",globus_object_printable_to_string((error)));
    DPRINTF("CONTINUTING DESPITE ERROR\n");
  }   
 globus_ftp_control_auth_info_t	auth_info;
  ret=globus_ftp_control_authenticate (  	
     	handle,
     	&auth_info,
	GLOBUS_TRUE,
     	auth_callback,
     	NULL);
     if(ret != GLOBUS_SUCCESS)
     {
       fprintf(stderr,"error calling authenticate\n ");
       globus_object_t * err;
       err = globus_error_get(ret);
       fprintf(stderr, "%s", globus_object_printable_to_string(err));
       
   } 
  


}
void connect_callback(    void*  	 callback_arg,
			  globus_ftp_control_handle_t* 	handle,
			  globus_object_t * 	error,
			  globus_ftp_control_response_t* 	ftp_response)

{
  DPRINTF("IN CONNECT_CALLBACK");
  if(error!=GLOBUS_SUCCESS){
    fprintf(stderr,"Error getting connection in auth callback \n");
    fprintf(stderr,"%s\n",globus_object_printable_to_string((error)));
    DPRINTF("CONTINUTING DESPITE ERROR\n");
  } 
  DPRINTF2("%s\n",ftp_response->response_buffer);

}

void print_usage(char* name){

  fprintf(stderr,"%s [-p port]\n",name);

}

void handle_command_line(int argc, char** argv){
 for(int i=1;i<argc;i++){

    if(argv[i][0]=='-')
      {
	
	switch(argv[i][1])
	  {
	  case 'p':  
	    listening_port=atoi(argv[++i]);
	    break;
	  default :
	    print_usage(argv[0]);
	    exit(1);	
	  }
      }
    else
      {
	print_usage(argv[0]); exit(1);

      }
    
 }

}

int main(int argc,char** argv){
  globus_ftp_control_handle_t control_handle;
  globus_result_t ret;
    //initialize control handle
  handle_command_line(argc,argv);
  ret=globus_module_activate(GLOBUS_FTP_CONTROL_MODULE);  
  MUST_BE_SUCCESS(ret,"activaet ftp control module");  
  ret=globus_module_activate(GLOBUS_FTP_CLIENT_MODULE);   //Initialize globus
client module 
  MUST_BE_SUCCESS(ret,"activaet ftp CLIENT module");

  globus_ftp_control_handle_init(&control_handle);
   if(ret != GLOBUS_SUCCESS)
   {
     fprintf(stderr,"error initializing control handle\n ");
     globus_object_t * err;
     err = globus_error_get(ret);
     fprintf(stderr, "%s", globus_object_printable_to_string(err));
     
   } 
   unsigned short port=listening_port;
   ret=globus_ftp_control_connect(&control_handle,
				  "localhost",
				  port,
				  connect_callback,
				  NULL);
   MUST_BE_SUCCESS(ret,"could not connect");
   printf("finished connect\n");
   pthread_mutex_lock(&done_lock);
   while(!done_all){
     pthread_cond_wait(&done_condition,&done_lock);
   }
   pthread_mutex_unlock(&done_lock);
}
------- Comment #1 From 2005-09-16 18:40:03 -------
Subject: Re:  New: globus_ftp_control library hangs at various places
 (depending on os)

Ignoring the bug for a moment, we intend to deprecate the control 
library in GT4.2, if at all possible.  It might be worthwhile to start 
an email thread discussing what you are doing and options that may be 
supported better / longer.