diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-05-21 20:44:43 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-05-21 20:44:43 +0000 |
commit | 208d6101a33fb58783edace74007ec3b455a0203 (patch) | |
tree | 49195fec33677d017464b3cffff4f92519bc2048 /TAO | |
parent | 56b325e46bad7ce588c874a8a564874764aacd7b (diff) | |
download | ATCD-208d6101a33fb58783edace74007ec3b455a0203.tar.gz |
ChangeLogTag: Tue May 21 15:03:45 2002 Irfan Pyarali <irfan@cs.wustl.edu>
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/ChangeLogs/ChangeLog-02a | 16 | ||||
-rw-r--r-- | TAO/tao/Thread_Lane_Resources.cpp | 25 | ||||
-rw-r--r-- | TAO/tests/File_IO/client.cpp | 122 |
3 files changed, 112 insertions, 51 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 87023e7e0e9..37dd3d6ed07 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,19 @@ +Tue May 21 15:03:45 2002 Irfan Pyarali <irfan@cs.wustl.edu> + + * tao/Thread_Lane_Resources.cpp (connector_registry): There was a + subtle bug in this method: <connector_registry_> was being + assigned to a new registry without it being opened first, + resulting in other threads potentially seeing a partially + initialized connector registry. In addition, the open() on the + registry was not being performed at the exact correct place. + This bug led to the File_IO test failing since it uses two + client threads invoking on the same server. + + * tests/File_IO/client.cpp: Added the ability to set the number of + iterations and the number of threads. Also validated the + connection to make sure we don't get an errand transient + exceptions. + Sat May 18 08:46:46 2002 Ossama Othman <ossama@uci.edu> * tests/ORT/ORT.dsw: diff --git a/TAO/tao/Thread_Lane_Resources.cpp b/TAO/tao/Thread_Lane_Resources.cpp index 71baf804d7e..8275653b391 100644 --- a/TAO/tao/Thread_Lane_Resources.cpp +++ b/TAO/tao/Thread_Lane_Resources.cpp @@ -99,26 +99,31 @@ TAO_Thread_Lane_Resources::connector_registry (ACE_ENV_SINGLE_ARG_DECL) if (this->connector_registry_ == 0) { // Ask it to create a new acceptor registry. - this->connector_registry_ = + TAO_Connector_Registry *connector_registry = this->orb_core_.resource_factory ()->get_connector_registry (); - if (this->connector_registry_ == 0) + if (connector_registry == 0) ACE_THROW_RETURN (CORBA::INITIALIZE ( CORBA::SystemException::_tao_minor_code ( TAO_CONNECTOR_REGISTRY_INIT_LOCATION_CODE, 0), CORBA::COMPLETED_NO), 0); - } - if (this->connector_registry_->open (&this->orb_core_) != 0) - ACE_THROW_RETURN (CORBA::INITIALIZE ( - CORBA::SystemException::_tao_minor_code ( - TAO_CONNECTOR_REGISTRY_INIT_LOCATION_CODE, - 0), - CORBA::COMPLETED_NO), - 0); + if (connector_registry->open (&this->orb_core_) != 0) + ACE_THROW_RETURN (CORBA::INITIALIZE ( + CORBA::SystemException::_tao_minor_code ( + TAO_CONNECTOR_REGISTRY_INIT_LOCATION_CODE, + 0), + CORBA::COMPLETED_NO), + 0); + // Finally, everything is created and opened successfully: + // now we can assign to the member. Otherwise, the + // assignment would be premature. + this->connector_registry_ = + connector_registry; + } } return this->connector_registry_; diff --git a/TAO/tests/File_IO/client.cpp b/TAO/tests/File_IO/client.cpp index a08a3af6baf..03ef6caf36c 100644 --- a/TAO/tests/File_IO/client.cpp +++ b/TAO/tests/File_IO/client.cpp @@ -25,19 +25,18 @@ ACE_RCSID(Default_Servant, client, "client.cpp,v 1.8 2001/03/26 21:16:52 coryan Exp") -static const char *iorfile = "ior"; + static const char *iorfile = "ior"; static const char *filename = "big.txt"; -static const int NUM_THREADS = 4; - +static int NUM_THREADS = 4; +static int iterations = 100; static CORBA::ORB_var orb; -static int loops=100; static int parse_args (int argc, char **argv) { - ACE_Get_Opt get_opts (argc, argv, "dk:f:"); + ACE_Get_Opt get_opts (argc, argv, "t:dk:f:i:"); int c; while ((c = get_opts ()) != -1) @@ -52,6 +51,12 @@ parse_args (int argc, char **argv) case 'f': filename = get_opts.opt_arg (); break; + case 't': + NUM_THREADS = ACE_OS::atoi (get_opts.opt_arg ()); + break; + case 'i': + iterations = ACE_OS::atoi (get_opts.opt_arg ()); + break; case '?': default: ACE_ERROR_RETURN ((LM_ERROR, @@ -59,6 +64,8 @@ parse_args (int argc, char **argv) "[-k <iorfile>]" "[-f <filename>]" "[-m <message>]" + "[-t <threads>]" + "[-i <iterations>]" "\n", argv [0]), -1); @@ -72,45 +79,78 @@ parse_args (int argc, char **argv) return 0; } +void +validate_connection (CORBA::Object_ptr object + ACE_ENV_ARG_DECL) +{ + // Try to validate the connection several times, ignoring transient + // exceptions. If the connection can still not be setup, return + // failure. + for (int i = 0; i < 100; ++i) + { + ACE_TRY + { + object->_non_existent (ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::TRANSIENT, exception) + { + // Ignore... + } + ACE_CATCHANY + { + // Rethrow any other exceptions. + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; + } +} + static void * MTTEST (void *args) { ACE_DECLARE_NEW_CORBA_ENV; - ACE_CString& ior = *(ACE_CString*)args; + + ACE_CString &ior = *(ACE_CString*)args; ACE_TRY { - CORBA::Object_var object = orb->string_to_object (ior.c_str () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Narrow the object reference to a File::System - File::System_var file_system = File::System::_narrow (object.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Creat the file filename i.e "test" - File::Descriptor_var fd = file_system->open (filename, - O_RDONLY - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - for( int i=0; i<loops; ++i) - { - //seek to the beginning of the file - ACE_DEBUG((LM_DEBUG,"Making request number %d\n",i)); - fd->lseek (0, SEEK_SET ACE_ENV_ARG_PARAMETER); + CORBA::Object_var object = orb->string_to_object (ior.c_str () + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - // Read back the written message - // Twice the size of the socket buffer - File::Descriptor::DataBuffer_var data_received = fd->read (128*1024 - ACE_ENV_ARG_PARAMETER); + validate_connection (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Narrow the object reference to a File::System + File::System_var file_system = File::System::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - } - // close the file - fd->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + // Creat the file filename i.e "test" + File::Descriptor_var fd = file_system->open (filename, + O_RDONLY + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + for( int i = 0; i < iterations; ++i) + { + //seek to the beginning of the file + ACE_DEBUG((LM_DEBUG,"Making request number %d\n",i)); + fd->lseek (0, SEEK_SET ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Read back the written message + // Twice the size of the socket buffer + File::Descriptor::DataBuffer_var data_received = fd->read (128*1024 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + // close the file + fd->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; } ACE_CATCHANY { @@ -159,15 +199,15 @@ main (int argc, char **argv) ACE_OS::close (input_file); if (ACE_Thread_Manager::instance ()->spawn_n (NUM_THREADS, - ACE_THR_FUNC (MTTEST), - (void *)&ior, - THR_NEW_LWP | THR_DETACHED) == -1) + ACE_THR_FUNC (MTTEST), + &ior, + THR_NEW_LWP | THR_DETACHED) == -1) { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n%a"), - ACE_TEXT ("thread create failed"))); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n%a"), + ACE_TEXT ("thread create failed"))); } - ACE_Thread_Manager::instance()->wait(); + ACE_Thread_Manager::instance()->wait(); } ACE_CATCHANY { |