OmniThread Question on NT 4.0

Elan Freedy elanf@netvision.net.il
Mon, 9 Mar 1998 15:25:24 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_000F_01BD4B6F.94B73690
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

With regards to my previous message below.  I believe I have isolated =
the problem in the omni thread code for Windows NT.  The destructor for =
the omni_thread object does call CloseHandle() for the cond_semaphore, =
thus leaving a open handle to a kernel object. The code fragment below =
has a fix, note the marked lines.

omni_thread::~omni_thread(void)
{
    DB(cerr << "destructor called for thread " << id() << endl);
>>  if (!CloseHandle(cond_semaphore))
>>  throw omni_thread_fatal(GetLastError());
    if (!CloseHandle(handle))
 throw omni_thread_fatal(GetLastError());
}

    -----Original Message-----
    From: Elan Freedy <elanf@netvision.net.il>
    To: omniorb-list@orl.co.uk <omniorb-list@orl.co.uk>
    Date: Monday, March 09, 1998 11:20
    Subject: OmniThread Question on NT 4.0
   =20
   =20
    Greetings all,
    =20
    I'm presently developing an application on NT, using omniORB, and am
    therefore using omni threads for all my threading needs. The =
application
    creates a lot of short lived detached worker threads which perform a =
small
    task then disappear. When I monitor the application in the NT task =
manager
    the number of threads, fluxuate within a reasonable boundary however =
the
    number of "handles" seems to just increase. I've checked with the =
debugger
    to verify that the omni thread destructor is being called properly =
which
    calls CloseHandle()...however the number of handles seems to grow =
with no
    bounds. Any ideas how I can fix this? or is this something that can =
be
    ignored?
    =20
    Thanks.
    Elan Freedy=20


------=_NextPart_000_000F_01BD4B6F.94B73690
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type><!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 =
HTML//EN">
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>With regards to my previous message =
below.&nbsp;=20
I believe I have isolated the problem in the omni thread code for =
Windows=20
NT.&nbsp; The destructor for the omni_thread object does call =
CloseHandle() for=20
the cond_semaphore, thus leaving a open handle to a kernel object. The =
code=20
fragment below has a fix, note the marked lines.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT><FONT=20
size=3D2><BR>omni_thread::~omni_thread(void)<BR>{<BR>&nbsp;&nbsp;&nbsp; =
DB(cerr=20
&lt;&lt; &quot;destructor called for thread &quot; &lt;&lt; id() =
&lt;&lt;=20
endl);<BR>&gt;&gt;&nbsp; if =
(!CloseHandle(cond_semaphore))<BR>&gt;&gt;&nbsp;=20
throw omni_thread_fatal(GetLastError());<BR>&nbsp;&nbsp;&nbsp; if=20
(!CloseHandle(handle))<BR>&nbsp;throw=20
omni_thread_fatal(GetLastError());<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 solid 2px; MARGIN-LEFT: 5px; PADDING-LEFT: =
5px">
    <DIV><FONT face=3DArial size=3D2><B>-----Original =
Message-----</B><BR><B>From:=20
    </B>Elan Freedy &lt;<A=20
    =
href=3D"mailto:elanf@netvision.net.il">elanf@netvision.net.il</A>&gt;<BR>=
<B>To:=20
    </B><A =
href=3D"mailto:omniorb-list@orl.co.uk">omniorb-list@orl.co.uk</A>=20
    &lt;<A=20
    =
href=3D"mailto:omniorb-list@orl.co.uk">omniorb-list@orl.co.uk</A>&gt;<BR>=
<B>Date:=20
    </B>Monday, March 09, 1998 11:20<BR><B>Subject: </B>OmniThread =
Question on=20
    NT 4.0<BR><BR></DIV></FONT>
    <DIV><FONT color=3D#000000 size=3D2><FONT color=3D#000000 size=3D2>
    <DIV><FONT color=3D#000000>Greetings all,</FONT></DIV>
    <DIV><FONT color=3D#000000></FONT>&nbsp;</DIV>
    <DIV><FONT color=3D#000000>I'm presently developing an application =
on NT,=20
    using omniORB, and am</FONT></DIV>
    <DIV><FONT color=3D#000000>therefore using omni threads for all my =
threading=20
    needs. The application</FONT></DIV>
    <DIV><FONT color=3D#000000>creates a lot of short lived detached =
worker=20
    threads which perform a small</FONT></DIV>
    <DIV><FONT color=3D#000000>task then disappear. When I monitor the =
application=20
    in the NT task manager</FONT></DIV>
    <DIV><FONT color=3D#000000>the number of threads, fluxuate within a =
reasonable=20
    boundary however the</FONT></DIV>
    <DIV><FONT color=3D#000000>number of &quot;handles&quot; seems to =
just=20
    increase. I've checked with the debugger</FONT></DIV>
    <DIV><FONT color=3D#000000>to verify that the omni thread destructor =
is being=20
    called properly which</FONT></DIV>
    <DIV><FONT color=3D#000000>calls CloseHandle()...however the number =
of handles=20
    seems to grow with no</FONT></DIV>
    <DIV><FONT color=3D#000000>bounds. Any ideas how I can fix this? or =
is this=20
    something that can be</FONT></DIV>
    <DIV><FONT color=3D#000000>ignored?</FONT></DIV>
    <DIV><FONT color=3D#000000></FONT>&nbsp;</DIV>
    <DIV><FONT color=3D#000000>Thanks.</FONT></DIV>
    <DIV><FONT color=3D#000000>Elan Freedy </FONT></DIV></FONT>
    <DIV>&nbsp;</DIV></FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_000F_01BD4B6F.94B73690--