[omniORB] Detecting activated servants...

Marcus MacWilliam marcusma@lsl.co.uk
Fri Sep 27 14:55:01 2002


--------------64C8E0A7DF2CA090F2821AB4
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

bjorn rohde jensen wrote:

> Hi guys,
>
>   It is highly recommendable to let the POA handle
> servant deletion, since there are several threading
> issues involved in that. Let your servant implementations
> derive from PortableServer::RefCountServantBase and call
> removeRef on it instead of delete. Check your CORBA
> books about this, i am sure, you can rip an example
> from them:)
>
> Yours sincerely,
>
> Bjorn

Cannot do this, the project is updating our old BOA's to use POA's.
We have our own reference counting because the CORBA objects
are just wrappers for C++ objects, and can't be deleted verbatim.

Therefore we are not using the POA Reference Counting at all.

I thought our wrappers handled everything automatically, but I have
started to get omniorb messages in my server output, telling me
I am trying to delete an object that is still active.

This is strange because the object is deleted in a method that has
already called release() (our own), which calls
poa->deactivate_object(id)
for the servant in question.

We then cache the objects for deletion, and they are done the next
iteration
around. So they should not still be active.

Is there a way of determining if a servant is still active? Either by
passing
the ID to a method, or by calling a method on the servant.

I am hoping to do this only to track down which servants are still
active, in a debugging stage, so that I can check our code.

i.e. if it is still active, output a message.

But I do not know how to detect if a servant is still active, before I
delete it. The below is the code I am using, which I have had to alter
since a previous posting.

// Sanity check, if the object is still active, deactivate it.
try
{
    // Deactivate the object, using its unique object id.
    getPOA()->deactivate_object( m_pLastObject->m_object_id );

#ifdef GOTHIC_DEBUG
    // Local variable to hold entry.
    GOTH_VALUE temp = constructEntry(
m_pLastObject->getWrappedClassName(), m_lastObjectKey );

    // Output that we had to deactivate object.
    (void) goth_printf( goth_stdout, "DEBUG>\t\t\t\t\t[D] - Deactivating
object - %s.\n", temp.string );

    // Free the assigned temporary string.
    (void) goth_value_free( temp, DT_STRING );
#endif
}
catch ( ... ) {}

// Delete the object.
delete m_pLastObject;

Cheers,
--
 Marcus A.T MacWilliam, MSc, CEng, MBCS, BSc(Hons).
 Senior Software Engineer, Laser-Scan Ltd, Cambridge, CB4 0FY.
 Tel: +44 (0)1223 420414 x213. Mobile: +44 (0)7803 706597.
 Fax: +44 (0)1223 420044. Web: http://www.laser-scan.co.uk/


--------------64C8E0A7DF2CA090F2821AB4
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
bjorn rohde jensen wrote:
<blockquote TYPE=CITE>Hi guys,
<p>&nbsp; It is highly recommendable to let the POA handle
<br>servant deletion, since there are several threading
<br>issues involved in that. Let your servant implementations
<br>derive from PortableServer::RefCountServantBase and call
<br>removeRef on it instead of delete. Check your CORBA
<br>books about this, i am sure, you can rip an example
<br>from them:)
<p>Yours sincerely,
<p>Bjorn</blockquote>

<p><br>Cannot do this, the project is updating our old BOA's to use POA's.
<br>We have our own reference counting because the CORBA objects
<br>are just wrappers for C++ objects, and can't be deleted verbatim.
<p>Therefore we are not using the POA Reference Counting at all.
<p>I thought our wrappers handled everything automatically, but I have
<br>started to get omniorb messages in my server output, telling me
<br>I am trying to delete an object that is still active.
<p>This is strange because the object is deleted in a method that has
<br>already called release() (our own), which calls poa->deactivate_object(id)
<br>for the servant in question.
<p>We then cache the objects for deletion, and they are done the next iteration
<br>around. So they should not still be active.
<p>Is there a way of determining if a servant is still active? Either by
passing
<br>the ID to a method, or by calling a method on the servant.
<p>I am hoping to do this only to track down which servants are still
<br>active, in a debugging stage, so that I can check our code.
<p>i.e. if it is still active, output a message.
<p>But I do not know how to detect if a servant is still active, before
I
<br>delete it. The below is the code I am using, which I have had to alter
<br>since a previous posting.
<p><tt>// Sanity check, if the object is still active, deactivate it.</tt>
<br><tt>try</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp;&nbsp; // Deactivate the object, using its unique object
id.</tt>
<br><tt>&nbsp;&nbsp;&nbsp; getPOA()->deactivate_object( m_pLastObject->m_object_id
);</tt><tt></tt>
<p><tt>#ifdef GOTHIC_DEBUG</tt>
<br><tt>&nbsp;&nbsp;&nbsp; // Local variable to hold entry.</tt>
<br><tt>&nbsp;&nbsp;&nbsp; GOTH_VALUE temp = constructEntry( m_pLastObject->getWrappedClassName(),
m_lastObjectKey );</tt>
<br><tt>&nbsp;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; // Output that we had to deactivate object.</tt>
<br><tt>&nbsp;&nbsp;&nbsp; (void) goth_printf( goth_stdout, "DEBUG>\t\t\t\t\t[D]
- Deactivating object - %s.\n", temp.string );</tt><tt></tt>
<p><tt>&nbsp;&nbsp;&nbsp; // Free the assigned temporary string.</tt>
<br><tt>&nbsp;&nbsp;&nbsp; (void) goth_value_free( temp, DT_STRING );</tt>
<br><tt>#endif</tt>
<br><tt>}</tt>
<br><tt>catch ( ... ) {}</tt><tt></tt>
<p><tt>// Delete the object.</tt>
<br><tt>delete m_pLastObject;</tt>
<p>Cheers,
<br>--
<br>&nbsp;Marcus A.T MacWilliam, MSc, CEng, MBCS, BSc(Hons).
<br>&nbsp;Senior Software Engineer, Laser-Scan Ltd, Cambridge, CB4 0FY.
<br>&nbsp;Tel: +44 (0)1223 420414 x213. Mobile: +44 (0)7803 706597.
<br>&nbsp;Fax: +44 (0)1223 420044. Web: <A HREF="http://www.laser-scan.co.uk/">http://www.laser-scan.co.uk/</A>
<br>&nbsp;</html>

--------------64C8E0A7DF2CA090F2821AB4--