[omniORB] Bug fix for the ORB::shutdown

Serguei Kolos Serguei.Kolos at cern.ch
Thu Aug 26 11:19:03 BST 2004


Hello

Studying the hangups of my applications in the ORB::shutdown method I 
produced
the patch, which solves this problem for me for both omniORB 4.0.3 and 
4.0.4.
The patch is attached and the explanation follows.

For me the origin of the problem was in the giopServer::deactivate() 
function, which
shuts down all the connections and immediately after that it shuts down the
randezvousers (or endpoints) of those connections. Very often it happens 
that
the randezvouser is destroyed before all the connections had a chance to 
notice
that they have been shut down and some of them may stay after that forever.
The reason is that the endpont, which has to listen on that connection 
and create
a new worker for it when appropriate, simply does not exist anymore. As 
a result the
giopServer::deactivate() function hangs forever on the pd_cond condition.

The solution is very simple:
1. The giopServer::deactivate() function proceed to randezvousers 
shutdown ONLY
    if there are no connections (!pd_connections).
2. I have modified the conditions, under which the pd_cond is 
broadcasted. Now it is done in case
    either there are no connections (!pd_connections) or if the 
randezvousers list is empty
    (Link::is_empty(pd_rendezvousers)).

That's it.  Now the shutdown is done in more then one iteration inside 
the giopServer::deactivate()
function. In the first step all the connections are shut down (but not 
the randezvousers), and then
the giopServer::deactivate() function starts waiting on the pd_cond 
condition. When this condition
is signaled the deactivate wakes up and goes to the beginning again. At 
some step it founds that
the pd_connections equals to 0 and then it shutdowns the randezvousers.

I tested the patch and it works very well for me - no hangups anymore.

Cheers,
Sergei
-------------- next part --------------
*** src/lib/omniORB/orbcore/giopServer.cc	Thu Aug 26 09:49:31 2004
--- src/lib/omniORB/orbcore/giopServer.cc.original	Thu Aug 26 09:48:13 2004
***************
*** 500,509 ****
      Link* p = pd_rendezvousers.next;
      if (p != &pd_rendezvousers) waitforcompletion = 1;
  
!     if (!pd_nconnections)
!       for (; p != &pd_rendezvousers; p = p->next) {
!         ((giopRendezvouser*)p)->terminate();
!       }
    }
  
    if (!Link::is_empty(pd_bidir_monitors)) {
--- 500,508 ----
      Link* p = pd_rendezvousers.next;
      if (p != &pd_rendezvousers) waitforcompletion = 1;
  
!     for (; p != &pd_rendezvousers; p = p->next) {
!       ((giopRendezvouser*)p)->terminate();
!     }
    }
  
    if (!Link::is_empty(pd_bidir_monitors)) {
***************
*** 813,820 ****
    }
  
    if (pd_state == INFLUX) {
!     if ( ( Link::is_empty(pd_rendezvousers) || pd_nconnections == 0 ) &&
! 	   Link::is_empty(pd_bidir_monitors ) ) {
        pd_cond.broadcast();
      }
    }
--- 812,820 ----
    }
  
    if (pd_state == INFLUX) {
!     if (Link::is_empty(pd_rendezvousers) &&
! 	pd_nconnections == 0             &&
! 	Link::is_empty(pd_bidir_monitors)   ) {
        pd_cond.broadcast();
      }
    }
***************
*** 912,919 ****
      }
  
      if (pd_state == INFLUX) {
!       if ( ( Link::is_empty(pd_rendezvousers) || pd_nconnections == 0 ) &&
! 	   Link::is_empty(pd_bidir_monitors ) ) {
  	pd_cond.broadcast();
        }
      }
--- 912,920 ----
      }
  
      if (pd_state == INFLUX) {
!       if (Link::is_empty(pd_rendezvousers) &&
! 	  pd_nconnections == 0             &&
! 	  Link::is_empty(pd_bidir_monitors)   ) {
  	pd_cond.broadcast();
        }
      }
***************
*** 1147,1154 ****
    m->remove();
    delete m;
    if (pd_state == INFLUX) {
!     if ( ( Link::is_empty(pd_rendezvousers) || pd_nconnections == 0 ) &&
! 	   Link::is_empty(pd_bidir_monitors ) ) {
        pd_cond.broadcast();
      }
    }
--- 1148,1156 ----
    m->remove();
    delete m;
    if (pd_state == INFLUX) {
!     if (Link::is_empty(pd_rendezvousers) &&
! 	pd_nconnections == 0             &&
! 	Link::is_empty(pd_bidir_monitors)   ) {
        pd_cond.broadcast();
      }
    }


More information about the omniORB-list mailing list