This is indeed a misuse. A very similar bug used to be there in io-threads, but we have moved to using pthread_cond over there since a while.<br><br>To fix this problem we could use a pthread_mutex/pthread_cond pairĀ + a boolean flag in place of the misused mutex. Or, we could just declare gd_op_sm_lock as a synclock_t to achieve the same result.<div><br></div><div>Thanks</div><br><div class="gmail_quote">On Tue Nov 25 2014 at 10:26:34 AM Emmanuel Dreyfus &lt;<a href="mailto:manu@netbsd.org">manu@netbsd.org</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I made a simple fix that address the problem:<br>
<a href="http://review.gluster.org/9197" target="_blank">http://review.gluster.org/9197</a><br>
<br>
Are there other places where the same bug could exist? Anyone familiar<br>
with the code would tell?<br>
<br>
Emmanuel Dreyfus &lt;<a href="mailto:manu@netbsd.org" target="_blank">manu@netbsd.org</a>&gt; wrote:<br>
<br>
&gt; in glusterd_op_sm(), we lock and unlock the gd_op_sm_lock mutex.<br>
&gt; Unfortunately, locking and unlocking can happen in different threads<br>
&gt; (task swap will occur in handelr call).<br>
&gt;<br>
&gt; This case is explictely covered by POSIX: the behavior is undefined.<br>
&gt; <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lo" target="_blank">http://pubs.opengroup.org/<u></u>onlinepubs/9699919799/<u></u>functions/pthread_mutex_lo</a><br>
&gt; ck.html<br>
&gt;<br>
&gt; When unlocking from a thread that is not owner, Linux seems to be fine<br>
&gt; (though you never know with unspecified operation), while NetBSD returns<br>
&gt; EPERM, causing a spurious error in tests/basic/pump.t . It can be observed<br>
&gt; in a few failed tests here:<br>
&gt; <a href="http://build.gluster.org/job/rackspace-netbsd7-regression-triggered/" target="_blank">http://build.gluster.org/job/<u></u>rackspace-netbsd7-regression-<u></u>triggered/</a><br>
&gt;<br>
&gt; Fixing it seems far from being obvious. I guess it needs to use syncop,<br>
&gt; but the change would be intrusive. Do we have another option? Is it<br>
&gt; possible to switch a task to a given thread?<br>
<br>
<br>
--<br>
Emmanuel Dreyfus<br>
<a href="http://hcpnet.free.fr/pubz" target="_blank">http://hcpnet.free.fr/pubz</a><br>
<a href="mailto:manu@netbsd.org" target="_blank">manu@netbsd.org</a><br>
______________________________<u></u>_________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@gluster.org" target="_blank">Gluster-devel@gluster.org</a><br>
<a href="http://supercolony.gluster.org/mailman/listinfo/gluster-devel" target="_blank">http://supercolony.gluster.<u></u>org/mailman/listinfo/gluster-<u></u>devel</a><br>
</blockquote></div>