Re: HEADS UP: Win32/OS2/BeOS native ports

From: Matthew Kirkwood <matthew(at)hairy(dot)beasts(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Marc G(dot) Fournier" <scrappy(at)hub(dot)org>, Igor Kovalenko <Igor(dot)Kovalenko(at)motorola(dot)com>, mlw <markw(at)mohawksoft(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: HEADS UP: Win32/OS2/BeOS native ports
Date: 2002-05-07 11:15:32
Message-ID: Pine.LNX.4.33.0205071204590.4713-100000@sphinx.mythic-beasts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 6 May 2002, Tom Lane wrote:

> > As a backend is started up, connect to that socket ... if socket is open
> > when trying to start a new frontend, fail as there are currently other
> > connections attached to it?
>
> But the backends would only have the socket open, they'd not be
> actively listening to it. So how could you tell whether anyone
> had the socket open or not?

It's easy. As startup, the postmaster (or standalone
backend) creates a Unix socket, binds it to the filename
and calls listen on it.

If another backend is running, it'll get EADDRINUSE from
the bind or listen.

Nobody actually needs to connect to the socket. Simple,
race-free, 10 lines of code.

Matthew.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message mlw 2002-05-07 12:42:15 OK, lets talk portability.
Previous Message Alex Shevlakov 2002-05-07 10:48:13 code contribution