{
statCounter.syscalls.sock.binds++;
- if (bind(s, inaddr.ai_addr, inaddr.ai_addrlen) == 0)
+ if (bind(s, inaddr.ai_addr, inaddr.ai_addrlen) == 0) {
+ debugs(50, 6, "commBind: bind socket FD " << s << " to " << fd_table[s].local_addr);
return COMM_OK;
+ }
debugs(50, 0, "commBind: Cannot bind socket FD " << s << " to " << fd_table[s].local_addr << ": " << xstrerror());
{
int sock = -1;
+ /* all listener sockets require bind() */
+ flags |= COMM_DOBIND;
+
/* attempt native enabled port. */
sock = comm_openex(sock_type, proto, addr, flags, 0, note);
if (addr.GetPort() > (u_short) 0) {
#ifdef _SQUID_MSWIN_
-
if (sock_type != SOCK_DGRAM)
#endif
-
commSetNoLinger(new_socket);
if (opt_reuseaddr)
comm_set_transparent(new_socket);
}
- if (!addr.IsNoAddr()) {
+ if ( (flags & COMM_DOBIND) || addr.GetPort() > 0 || !addr.IsAnyAddr() ) {
+ if ( !(flags & COMM_DOBIND) && addr.IsAnyAddr() )
+ debugs(5,1,"WARNING: Squid is attempting to bind() port " << addr << " without being a listener.");
+ if ( addr.IsNoAddr() )
+ debugs(5,0,"CRITICAL: Squid is attempting to bind() port " << addr << "!!");
+
if (commBind(new_socket, *AI) != COMM_OK) {
comm_close(new_socket);
addr.FreeAddrInfo(AI);
#define COMM_NOCLOEXEC 0x02
#define COMM_REUSEADDR 0x04
#define COMM_TRANSPARENT 0x08
+#define COMM_DOBIND 0x10
#define safe_free(x) if (x) { xxfree(x); x = NULL; }