bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] flock implementation (version 2)


From: Paolo Bonzini
Subject: Re: [PATCH] flock implementation (version 2)
Date: Fri, 03 Oct 2008 15:23:58 +0200
User-agent: Thunderbird 2.0.0.17 (Macintosh/20080914)

Thanks!

> +static BOOL
> +do_lock_shared (HANDLE h, int non_blocking)

> +static BOOL
> +do_lock_exclusive (HANDLE h, int non_blocking)

There's quite some duplication here.  However, with the other changes
below it might become acceptable.

> +     case ERROR_LOCK_VIOLATION:
> +       /* EWOULDBLOCK is not available on MinGW. */

If you use the errno module, EWOULDBLOCK is added.  However, it is
better to make it a synonym of EAGAIN as it is on POSIX platforms.

> +  /* Start offset is 0. */
> +  memset (&ovlp, 0, sizeof ovlp);
> +  ovlp.Offset = 0;
> +  ovlp.OffsetHigh = 0;
> +  ovlp.hEvent = 0;

No need to set fields to zero.

> +  memset (&fl, 0, sizeof fl);
> +  fl.l_whence = SEEK_SET;
> +  fl.l_start = 0;
> +  fl.l_len = 0;                      /* Special case -- means whole file. */

Likewise (even SEEK_SET is zero).

> +  return fcntl (fd, cmd, &fl);

You need to change EACCES to EWOULDBLOCK here if fcntl F_SETLK fails.
Thanks!

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]