Re: file-locking and postmaster.pid

From: korry <korry(at)appx(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: file-locking and postmaster.pid
Date: 2006-05-24 20:19:33
Message-ID: 1148501973.21335.62.camel@sakai.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Certainly on all platforms there must be *some* locking primitive. We
> just need to figure out the appropiate parameters to fcntl() or flock()
> or lockf() on each.

Right.

> The Win32 API for locking seems mighty strange to me.

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

-- Korry

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2006-05-24 20:30:12 Re: file-locking and postmaster.pid
Previous Message Jim C. Nasby 2006-05-24 20:12:32 Re: Compression and on-disk sorting