<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- P { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>It seems to me that that's true. We should have the read/write to m->val within a critical section, otherwise this will be susceptible to race conditions.<br>
</p>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Cyrus-sasl <cyrus-sasl-bounces+ddas=hortonworks.com@lists.andrew.cmu.edu> on behalf of Ted Yu <yuzhihong@gmail.com><br>
<b>Sent:</b> Sunday, April 16, 2017 3:38 AM<br>
<b>To:</b> W. Michael Petullo<br>
<b>Cc:</b> cyrus-sasl@lists.andrew.cmu.edu<br>
<b>Subject:</b> mutex_lock function and sasl_set_mutex</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div class="gmail_extra">Hi,</div>
<div class="gmail_extra">Looking at sasl_set_mutex function shown in cyrus-sasl-2.1.26/utils/testsuite.c :</div>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">
<div class="gmail_extra">int my_mutex_lock(my_mutex_t *m)</div>
<div class="gmail_extra">{</div>
<div class="gmail_extra">    if (m->val != 0)</div>
<div class="gmail_extra">    {</div>
<div class="gmail_extra">      fatal("Trying to lock a mutex already locked [single-threaded app]");</div>
<div class="gmail_extra">    }</div>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">Wouldn't calling <span class="gmail-s1" style="font-family:monaco; font-size:11px">pthread_mutex_lock</span><span style="font-family:monaco; font-size:11px">() better handle concurrent invocations of the mutex lock function ?</span></div>
<div class="gmail_extra"><span style="font-family:monaco; font-size:11px"><br>
</span></div>
<div class="gmail_extra"><span style="font-family:monaco; font-size:11px">Thanks</span></div>
</div>
</div>
</div>
</div>
</body>
</html>