<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 10 (filtered)">

<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>In testing the use of spread in our Open Link application I
have found several situations that can result in deadlocks, when using spread in
a multi-threaded application.&nbsp; </span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>We have a main thread in our application that
connects/disconnects from spread for every one of our &quot;internal sessions&quot;.&nbsp;
Each &quot;internal session&quot; has a separate thread to receive the messages
from spread and queue them up internally.&nbsp; I have been testing situations
where we create multiple &quot;internal sessions&quot; of our application and
then remove them.&nbsp; </span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>In the function SP_scat_receive it locks the mutex associated
with the particular connection at the top:</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>&amp;Mbox_mutex[mbox &amp; MAX_MUTEX_MASK][1]</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>However, there are several situations where it returns
without unlocking that mutex.&nbsp; Most or all of them seem to be the case are
when the &nbsp;spread session is taken out from underneath it by a seperate
thread (as is happening in our application).&nbsp; However, since the mbox is
mapped to a mutex from 1 - 255,&nbsp; different spread mboxes can share the
same mutex.&nbsp; This results in a deadlock with the other thread mapped to
the same mutex is stuck waiting for the thread that already returned, to give
up the lock on its mutex.</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Although I didn&#8217;t run into it, a similar situation seems
like it can occur in SP_internal_multicast where the mutex (&amp;Mbox_mutex[mbox
&amp; MAX_MUTEX_MASK][0]) is not always unlocked. </span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I have made the changes locally, and it fixes our issues,
but I wanted to bring it to your attention.&nbsp; </span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Regards,</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Greg</span></font></p>

</div>

</body>

</html>