summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/DevGuideExamples/PortableInterceptors/PICurrent_NameService/MessengerClient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/DevGuideExamples/PortableInterceptors/PICurrent_NameService/MessengerClient.cpp')
-rw-r--r--TAO/orbsvcs/DevGuideExamples/PortableInterceptors/PICurrent_NameService/MessengerClient.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/TAO/orbsvcs/DevGuideExamples/PortableInterceptors/PICurrent_NameService/MessengerClient.cpp b/TAO/orbsvcs/DevGuideExamples/PortableInterceptors/PICurrent_NameService/MessengerClient.cpp
index 3edbc5d2284..af4307307eb 100644
--- a/TAO/orbsvcs/DevGuideExamples/PortableInterceptors/PICurrent_NameService/MessengerClient.cpp
+++ b/TAO/orbsvcs/DevGuideExamples/PortableInterceptors/PICurrent_NameService/MessengerClient.cpp
@@ -7,6 +7,7 @@
// Ensure that the PI library is linked in when building statically
#include "tao/PI/PI.h"
#include "orbsvcs/CosNamingC.h"
+#include "ace/OS_NS_unistd.h"
#include <iostream>
int
@@ -42,7 +43,15 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
name.length(1);
name[0].id = CORBA::string_dup( "Messenger" );
- CORBA::Object_var obj = root->resolve( name );
+ CORBA::Object_var obj = CORBA::Object::_nil();
+ while ( CORBA::is_nil( obj.in() ) ) {
+ try {
+ obj = root->resolve( name );
+ } catch (const CosNaming::NamingContext::NotFound&) {
+ // Sleep for a second and try again
+ ACE_OS::sleep(1);
+ }
+ }
Messenger_var messenger = Messenger::_narrow( obj.in() );
if( CORBA::is_nil( messenger.in() ) ) {