[omniORB] I can't use bidir correctly

Duncan Grisby duncan@grisby.org
Wed Jul 3 11:58:01 2002


On Friday 28 June, Slava Garelin wrote:

> I use modified version eg2_clt and eg2_impl from src/example/echo
> dir.  These changes add POA in the client and remove an entrance in
> orb-> run () in the server.

I've looked into this, and bidirectional GIOP is working fine. The
only bit that isn't working is cleaning up on orb->destroy(), which
causes the problems you are seeing. Obviously I need to fix that, but
I probably won't have time this week.

You may be failing to realise that you need to create POAs with the
bidirectional policy on both client and server sides before
bidirectional is used. I've included a patch for the callback example
that makes it use bidirectional GIOP. Here's a relevant snippet from
the server-side trace:

omniORB: (3) inputMessage: from giop:tcp:10.0.0.1:33220 44 bytes
omniORB: (3) Handling a GIOP LOCATE_REQUEST.
omniORB: (3) sendChunk: to giop:tcp:10.0.0.1:33220 20 bytes
omniORB: (3) inputMessage: from giop:tcp:10.0.0.1:33220 283 bytes
omniORB: (3)  recieve codeset service context and set TCS to (ISO-8859-1,UTF-16)
omniORB: (3)  receive bidir IIOP service context: ( 10.0.0.1:33219 )
omniORB: (3) Accepted request from giop:tcp:10.0.0.1:33220 to switch to bidirectional because of this rule: "* bidir,unix,tcp,ssl"
omniORB: (3) Creating ref to remote: root/bidir<0>
 target id      : IDL:cb/CallBack:1.0
 most derived id: IDL:cb/CallBack:1.0
cb_server: Doing a single call-back: Hello!
omniORB: (3) LocateRequest to remote: root/bidir<0>
omniORB: (3) sendChunk: to giop:tcp:10.0.0.1:33220 44 bytes


Port 33220 is the port opened by the client to call the server. 33219
is the port number the client is using to listen for connections. Note
how when the server does a LocateRequest to the callback object, it
uses port 33220, rather than 33219.

Cheers,

Duncan.


diff -u -r old_omni/src/examples/call_back/cb_client.cc omni/src/examples/call_back/cb_client.cc
--- old_omni/src/examples/call_back/cb_client.cc	Fri Jun  8 18:15:28 2001
+++ omni/src/examples/call_back/cb_client.cc	Wed Jul  3 11:35:57 2002
@@ -71,13 +71,23 @@
 
       // Initialise the POA.
       obj = orb->resolve_initial_references("RootPOA");
-      PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
-      PortableServer::POAManager_var pman = poa->the_POAManager();
+      PortableServer::POA_var rootpoa = PortableServer::POA::_narrow(obj);
+      PortableServer::POAManager_var pman = rootpoa->the_POAManager();
       pman->activate();
 
+      // Create a POA with the Bidirectional policy
+      CORBA::PolicyList pl;
+      pl.length(1);
+      CORBA::Any a;
+      a <<= BiDirPolicy::BOTH;
+      pl[0] = orb->create_policy(BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, a);
+
+      PortableServer::POA_var poa = rootpoa->create_POA("bidir", pman, pl);
+
       // Register a CallBack object in this process.
       cb_i* mycallback = new cb_i();
-      cb::CallBack_var callback = mycallback->_this();  // *implicit activation*
+      PortableServer::ObjectId_var oid = poa->activate_object(mycallback);
+      cb::CallBack_var callback = mycallback->_this();
       mycallback->_remove_ref();
 
       if( argc == 2 )  do_single(server, callback);
diff -u -r old_omni/src/examples/call_back/cb_server.cc omni/src/examples/call_back/cb_server.cc
--- old_omni/src/examples/call_back/cb_server.cc	Fri Jun  8 18:15:28 2001
+++ omni/src/examples/call_back/cb_server.cc	Wed Jul  3 11:34:42 2002
@@ -140,12 +140,22 @@
 
     {
       CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
-      PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
-      PortableServer::POAManager_var pman = poa->the_POAManager();
+      PortableServer::POA_var rootpoa = PortableServer::POA::_narrow(obj);
+      PortableServer::POAManager_var pman = rootpoa->the_POAManager();
       pman->activate();
 
+      // Create a POA with the Bidirectional policy
+      CORBA::PolicyList pl;
+      pl.length(1);
+      CORBA::Any a;
+      a <<= BiDirPolicy::BOTH;
+      pl[0] = orb->create_policy(BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, a);
+
+      PortableServer::POA_var poa = rootpoa->create_POA("bidir", pman, pl);
+
       server_i* myserver = new server_i();
-      obj = myserver->_this();             // *implicit activation*
+      PortableServer::ObjectId_var oid = poa->activate_object(myserver);
+      obj = myserver->_this();
       myserver->_remove_ref();
 
       CORBA::String_var sior(orb->object_to_string(obj));
diff -u -r old_omni/src/examples/call_back/dir.mk omni/src/examples/call_back/dir.mk
--- old_omni/src/examples/call_back/dir.mk	Tue Jul  4 16:23:22 2000
+++ omni/src/examples/call_back/dir.mk	Wed Jul  3 11:32:38 2002
@@ -17,10 +17,10 @@
 	$(RM) $(cb_client) $(cb_server) $(cb_shutdown)
 
 $(cb_client): cb_client.o $(CORBA_STATIC_STUB_OBJS) $(CORBA_LIB_DEPEND)
-	@(libs="$(CORBA_LIB_NODYN)"; $(CXXExecutable))
+	@(libs="$(CORBA_LIB)"; $(CXXExecutable))
 
 $(cb_server): cb_server.o $(CORBA_STATIC_STUB_OBJS) $(CORBA_LIB_DEPEND)
-	@(libs="$(CORBA_LIB_NODYN)"; $(CXXExecutable))
+	@(libs="$(CORBA_LIB)"; $(CXXExecutable))
 
 $(cb_shutdown): cb_shutdown.o $(CORBA_STATIC_STUB_OBJS) $(CORBA_LIB_DEPEND)
-	@(libs="$(CORBA_LIB_NODYN)"; $(CXXExecutable))
+	@(libs="$(CORBA_LIB)"; $(CXXExecutable))
diff -u -r old_omni/src/examples/echo/eg2_clt.cc omni/src/examples/echo/eg2_clt.cc


-- 
 -- Duncan Grisby         --
  -- duncan@grisby.org     --
   -- http://www.grisby.org --