#ifdef ZERO_ZERO in source3/locking/brlock.c

Kenny Dinh kdinh at peaxy.net
Fri May 29 13:38:02 MDT 2015


That helps a lot.  It makes sense to keep that logic disabled unless we
have to handle the corner case.

Thank you!

On Fri, May 29, 2015 at 11:38 AM, Jeremy Allison <jra at samba.org> wrote:

> 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)) {
> > CHECK_STATUS_OR(status, NT_STATUS_LOCK_NOT_GRANTED,
> >     NT_STATUS_FILE_LOCK_CONFLICT);
> > } else {
> > CHECK_STATUS(status, NT_STATUS_OK);
> > }
> >
> >
> > 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 !
>
> Jeremy.
>


More information about the samba-technical mailing list