Fix up hangup during md5 authentication that occurs in daemon mode and
authorYugo Nagata <nagata@sraoss.co.jp>
Tue, 14 Feb 2012 06:57:56 +0000 (15:57 +0900)
committerYugo Nagata <nagata@sraoss.co.jp>
Tue, 14 Feb 2012 06:57:56 +0000 (15:57 +0900)
commit4856c8c0507024c21b8529f35ada542620a56fc7
tree9536343e3ba57cca4e01e032709b6d8fb927e072
parent9e219ecc88e5325915a9a8cc78094b590d9a1fcc
Fix up hangup during md5 authentication that occurs in daemon mode and
log_destination is 'syslog'. (reported in [pgpool-hackers: 25]).

Before daemonizing, openlog() opens syslog connection socket and gets
a file descriptor (fd). Then in daemonizing process, the fd is closed
as well as others. After daemonizing, pool_passwd is opened for md5
authentication and the same fd is assigned. In md5 authentication process,
syslog() is called for logging. However it fails since the used fd is
not for socket but for file. So, syslog() closed the fd and reopen new
socket using the same fd again. Then in trying to read pool_passwd, it
fails because the using fd is not for the pool_passwd file but for syslog
connection socket and then gets hangup.

Fix the problem by calling closelog() to close syslog connection safely
before daemonizing and calling openlog() to reopen syslog connection
after daemonizing.
main.c