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. ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html