From: Mike Mascari <mascarm@mascari.com>
To: Alfred Perlstein <bright@wintelcom.net>
Cc: Jan Wieck <JanWieck@Yahoo.com>
Cc: PostgreSQL HACKERS <pgsql-hackers@postgresql.org>
Subject: Re: fcntl(SETLK) [was Re: 2nd update on TOAST]
Date: Sat, 08 Jul 2000 08:54:48 -0400
Message-ID: <39672498.140BBC13@mascari.com> (raw)
References: <13925.963010847@sss.pgh.pa.us>
<200007081115.NAA30848@hot.jw.home>
<20000708055138.D25571@fw.wintelcom.net>
Alfred Perlstein wrote:
>
> * Jan Wieck <JanWieck@t-online.de> [000708 05:47] wrote:
> > Tom Lane wrote:
> > >
> > > Bruce and I were just talking by phone about this, and we realized that
> > > there is a completely different approach to making that decision: if you
> > > want to know whether there's an old postmaster connected to a socket
> > > file, try to connect to the old postmaster! In other words, pretend to
> > > be a client and see if your connection attempt is answered. (You don't
> > > have to try to log in, just see if you get a connection.) This might
> > > also answer Peter's concern about socket files that belong to
> > > non-Postgres programs, although I doubt that's really a big issue.
> > >
> > > There are some potential pitfalls here, like what if the old postmaster
> > > is there but overloaded? But on the whole it seems like it might be
> > > a cleaner answer than fooling around with lockfiles, and certainly safer
> > > than relying on fcntl(SETLK) to work on a socket file. Comments anyone?
> >
> > Like it.
>
> my $pgsocket = "/tmp/.s.PGSQL.5432";
>
> # try to connect to the postmaster
> socket(SOCK, PF_UNIX, SOCK_STREAM, 0)
> or die "unable to create unix domain socket: $!";
>
> connect(SOCK, sockaddr_un($pgsocket))
> and errexit("postmaster is running you must shut it down");
>
> oh yeah... :)
>
> -Alfred
I don't get this. Isn't there a race condition here?
Just curious,
Mike Mascari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: mascarm@mascari.com, bright@wintelcom.net, JanWieck@Yahoo.com
Subject: Re: fcntl(SETLK) [was Re: 2nd update on TOAST]
In-Reply-To: <39672498.140BBC13@mascari.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox