#ifdef ZERO_ZERO in source3/locking/brlock.c

Jeremy Allison jra at samba.org
Fri May 29 12:38:55 MDT 2015

On Tue, May 26, 2015 at 09:47:56AM -0700, Kenny Dinh wrote:
> Hi all,
> I found this section of code in source4/torture/raw/lock.c,
> /* XXX Samba 3 will fail this test. This is temporary(because this isn't
>  * new to Win7, it succeeds in WinXP too), until I can come to a
>  * resolution as to whether Samba should support this or not. There is
>  * code to preference unlocking exclusive locks before shared locks,
>  * but its wrapped with "#ifdef ZERO_ZERO". -zkirsch */
> if (TARGET_IS_SAMBA3(tctx)) {
> } else {
> }
> On samba 4.1, the preference of unlocking exclusive locks before shared
> locks is still disabled by default.  This is the default behavior in
> Windows 7 onward.  I couldn't find any reference in the code or from samba
> bugzilla as to why the section of code was #ifdef'ed out with ZERO_ZERO.
> Was there any reason not to enable this logic by default in samba 4.X?

OK, I took a close look at this. It's to do with prioritizing
the handling of locks with a byte-range-length of zero, which
as far as I know no real-world applications actually use (tridge
go medieval on the locking algorithms with these tests as he *really*
wanted to know how Windows worked internally :-).

I think the reason it isn't enabled by default in smbd, is
that to pass this test we need to qsort the internal lock
list (look up the code in brlock.c in smbd), and for an edge
case that isn't used in the real world we decided it wasn't
worth wasting CPU on it.

Hope this helps !


More information about the samba-technical mailing list