Magnus Hagander <[EMAIL PROTECTED]> writes:
> +             sprintf(mutexName,"postgresql.interlock.%i", portNumber);

That won't do; it should be legal for two postmasters to listen on
different IP addresses using the same port number.  So you need to
include some representation of the IP address being bound to.

> +             if (GetLastError() == ERROR_ALREADY_EXISTS)
> +                     ereport(FATAL,
> +                                     (errcode(ERRCODE_LOCK_FILE_EXISTS),
> +                                      errmsg("interlock mutex \"%s\" already 
> exists", mutexName),
> +                                      errhint("Is another postgres listening 
> on port %i", portNumber)));

ereport(FATAL) is quite inappropriate here.  Do the same thing that
bind() failure would do, ie, ereport(LOG) and continue the loop.
Also, you probably need to think about cleaning up the mutex in
case one of the later steps of socket-acquisition fails.  We should
only be holding locks on addresses we've successfully bound.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate

Reply via email to