On Fri, 4 Dec 2009 13:03:00 +0100, Jens Rehsack
<rehs...@googlemail.com> wrote:

> 2009/12/4 H.Merijn Brand <h.m.br...@xs4all.nl>:
> > On Fri, 4 Dec 2009 10:03:54 +0100, Jens Rehsack
> > <rehs...@googlemail.com> wrote:
> >
> >> 2009/12/3 H.Merijn Brand <h.m.br...@xs4all.nl>:
> >> > Any objections to me committing below change?
> >>
> >> While the originator of this request updates his ticket, maybe a smarter
> >> implementation is reasonable:
> >>
> >> I could modify S::S opentable () to request opening for reading/writing,
> >> so you could differ between LOCK_SH and LOCK_EX automatically.
> >
> > That can still be done. You can set a localized $data->{Database}{f_lock}
> > What I have now done (and committed) is create support and
> > documentation  for locking control. How this will be used is up to the
> > higher levels.
> 
> I wouldn't use the numbers 0..2 - I'd suggest using LOCK_SH, LOCK_EX
> etc. instead.

I just extended what was already there: hard-coded numbers.

> This will help if any (exotic) OS defines it in the upper half byte or so.

Yes, but it will also slow down. Given that string compares take longer
than numeric compares, and that we will have to do a lot more checking
(like only accept the spelling/casing we would accept) in several
places.

> >> Further, it could be suitable to or LOCK_NB, which allows to avoid 
> >> deadlocks.
> >
> > LOCK_NB?
> 
> NON_BLOCK:
> #define   LOCK_NB           0x04      /* do not block when locking */
> [...]
> ERRORS
>      The flock() system call fails if:
> 
>      [EWOULDBLOCK]    The file is locked and the LOCK_NB option was specified.

       A call to flock () may block if an incompatible lock is held by another
       process.   To  make  a non-blocking request, include LOCK_NB (by ORing)
       with any of the above operations.

Only makes it more difficult. Maybe the docs should state "or whatever flag(s)
your running OS supports". If we go that way, we'd need a list of what `would
be' the string representation of the numeric flag for diagnostic messages, and
that is not something I like to see happening.

Again, I just opened the internal locking mechanism as it already was
in place
and documented that.

> >       Apply or remove an advisory lock on the open file specified by fd.  
> > The
> >       argument operation is one of the following:
> >
> >           LOCK_SH  Place a shared lock.  More than one  process  may  hold  
> > a
> >                    shared lock for a given file at a given time.
> >
> >           LOCK_EX  Place  an  exclusive  lock.   Only one process may hold 
> > an
> >                    exclusive lock for a given file at a given time.
> >
> >           LOCK_UN  Remove an existing lock held by this process.
> 
> Might be unsupported on some OS. At least *BSD supports in (what
> counts to me ^^).

Maybe that is why DBD::File used numerics, and not macros. This way we
do not depend on missing include files.

> >> Sorry for generating extra wishes ;)
> >
> > No need to be sorry. Wishes keep us sharp!
> 
> Than I wish a pony ;)

http://www.freewebs.com/splendacrest/PonyInBoots.jpg

-- 
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

Reply via email to