Re: file-locking and postmaster.pid - Mailing list pgsql-hackers

From korry
Subject Re: file-locking and postmaster.pid
Date
Msg-id 1148501973.21335.62.camel@sakai.localdomain
Whole thread Raw
In response to Re: file-locking and postmaster.pid  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: file-locking and postmaster.pid
List pgsql-hackers
<br /><blockquote type="CITE"><pre>
<font color="#000000">Certainly on all platforms there must be *some* locking primitive.  We</font>
<font color="#000000">just need to figure out the appropiate parameters to fcntl() or flock()</font>
<font color="#000000">or lockf() on each.</font>
</pre></blockquote> Right. <pre>

</pre><blockquote type="CITE"><pre>
<font color="#000000">The Win32 API for locking seems mighty strange to me.</font>
</pre></blockquote><pre>

</pre> Linux/Unix byte locking is advisory (meaning that one lock can block another lock, but it can't block a read). 
Win32locking is mandatory (at least in the most portable form) so a lock blocks a reader.  To avoid that problem,
youlocka byte that you never intend to read (that is, you lock a byte past the end of the file).  Locking past the
end-of-fileis portable to all Unix/Linux systems that I've seen (that way, you can lock a region of a file before you
growthe file).<br /><br />         -- Korry<br /><br /> 

pgsql-hackers by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: Compression and on-disk sorting
Next
From: Andrew Dunstan
Date:
Subject: Re: file-locking and postmaster.pid