Uploaded as xinli-its6925-110630.patch.
Sorry, apparently I never received this message. It is not clear why you conditioned it based on HAVE_GETADDRINFO; this seems to be repeated also throughout the original code.
The patch is not fine in slapd/daemon.c (the original code seems to be broken as well where inet_ntop(3) is already used), since peeraddr is set by inet_ntop(3) to point to the buffer addr[], and is used also when addr[] gets out of scope (#ifdef HAVE_TCPD). Fixing.
The patch and the fixes are in git's master. In the commit log I forgot to mention that many of those fixes, significantly that for LDAP_CONNECTIONLESS, are blind. Please test and report.
p.