<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=gb2312"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:ËÎÌå;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:ËÎÌå;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@ËÎÌå";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        font-size:10.5pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        text-indent:21.0pt;
        font-size:10.5pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=ZH-CN link=blue vlink=purple style='text-justify-trim:punctuation'><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>I¡¯ll answer this myself:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>When esl_mutex_t&nbsp; is created in esl_mutex_create(), attribution ¡°PTHREAD_MUTEX_RECERSIVE¡± is set. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>This attribution allows mutex is locked for several times without unlock in the same thread.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>So there is no dead lock issue for esl_execute()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>But I still meet another dead lock between main thread (sending ESL cmd) and ESL event process thread, is there any constrain for esl interface usages in *INBOUND* mode under multi-thread?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<o:p>&nbsp;</o:p></span></p><p class=MsoNormal style='text-indent:15.75pt'><span lang=EN-US>esl_execute()<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:18.0pt;text-indent:0cm'><span lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoListParagraph style='margin-left:18.0pt;text-indent:0cm'><span lang=EN-US>When I read the implementation of the code,&nbsp; is there any possibility to dead lock as following?<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:42.0pt;text-indent:0cm'><span lang=EN-US>esl_execute()<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:42.0pt;text-indent:0cm'><span lang=EN-US>&nbsp; &nbsp; +--&gt;esl_send_recv /esl_send_recv_timed(_handle, _cmd, 0)<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:42.0pt;text-indent:0cm'><span lang=EN-US>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+--&gt;&nbsp;esl_mutex_lock(handle-&gt;mutex); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt;&lt;&lt;&lt; lock for 1<sup>st</sup> time<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:42.0pt;text-indent:0cm'><span lang=EN-US>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;+--&gt;&nbsp;esl_recv_event_timed(handle,&nbsp;ms, 0, &amp;handle&nbsp;-&gt;last_sr_event)<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:42.0pt;text-indent:0cm'><span lang=EN-US>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+--&gt;&nbsp;esl_recv_event()<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:42.0pt;text-indent:0cm'><span lang=EN-US>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; +----&gt;&nbsp;esl_mutex_lock(handle-&gt;mutex);&nbsp; &lt;&lt;&lt;&lt;&lt;&lt; lock for 2<sup>nd</sup> time, but preview one is not unlock<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoListParagraph style='margin-left:42.0pt;text-indent:0cm'><span lang=EN-US><o:p>&nbsp;</o:p></span></p></div></body></html>