[omniORB] Inconsistent linked list of giopTransportImpl in
giopEndpoint.cc
Qian Feng
qian at jfsys.com
Thu Sep 25 19:11:17 BST 2003
Hi, All,
I just have a project which use the ssl support of omniORB4, and the client
program goes something like this:
sslContext::certificate_authority_file = "root.pem";
sslContext::key_file = "client.pem";
sslContext::key_file_password = "password";
...
CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
...
CORBA::release(orb)
...
CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
...
The first call to CORBA::ORB_init always return correctly, but the second
one always fail.
So I digged into the source code, and found that it failed in
omni_giopEndpoint_initialiser::attach() at the following code fragment:
giopTransportImpl* impl = implHead();
while (impl) {
impl->initialise();
impl = impl->next;
}
The reason is the there is a invalid pointer in the linked list which cause
the call to impl->initialise(); throw a exception. It turns out that
elements were added to the list in giopTransportImpl::giopTransportImpl and
were never removed!
Because my project uses SSL transport, during the first CORBA::ORB_init, a
sslTransportImpl object was created and added to the list, and during the
call to CORBA::release(orb), the sslTransportImpl object will be deleted in
omni_sslTransport_initialiser::detach() while the pointer to this object is
still in the linked list mentioned above. This is the root cause of the
failure of the second call, I think.
Since objects were inserted into the list during it's constructor, I think
it's good place to remove it from the list in it's destructor. I came up
with the following patch to fix this problem, and it seems works for me.
Any comments are very welcomed.
Thanks,
Qian Feng
---HERE BEGINS THE PATCH---
--- src/lib/omniORB/orbcore/giopEndpoint.cc 22 May 2003 13:41:41 -0000
1.1.2.14
+++ src/lib/omniORB/orbcore/giopEndpoint.cc 25 Sep 2003 09:04:51 -0000
@@ -243,6 +243,14 @@
////////////////////////////////////////////////////////////////////////
giopTransportImpl::~giopTransportImpl() {
+ //remove the destructed impl from the list.
+ giopTransportImpl** pp = &implHead();
+ while(*pp != NULL && *pp != this){
+ pp = &((*pp)->next);
+ }
+ if(*pp == this){
+ *pp = this->next;
+ }
}
////////////////////////////////////////////////////////////////////////
---PATCH ENDS HERE---
More information about the omniORB-list
mailing list