/* * peerProbeConnect will be called on dead peers by neighborUp */ static int peerProbeConnect(peer * p) { int fd; time_t ctimeout = p->connect_timeout > 0 ? p->connect_timeout : Config.Timeout.peer_connect; int ret = squid_curtime - p->stats.last_connect_failure > ctimeout * 10; if (p->test_fd != -1) return ret; /* probe already running */ if (squid_curtime - p->stats.last_connect_probe == 0) return ret; /* don't probe to often */ fd = comm_open(SOCK_STREAM, IPPROTO_TCP, getOutgoingAddr(NULL), 0, COMM_NONBLOCKING, p->name); if (fd < 0) return ret; commSetTimeout(fd, ctimeout, peerProbeConnectTimeout, p); p->test_fd = fd; p->stats.last_connect_probe = squid_curtime; commConnectStart(p->test_fd, p->host, p->http_port, peerProbeConnectDone, p, NULL); return ret; }
static int private_openIdleConn( int idle,FwdState *fwdState,char* name,char* domain, int ctimeout) { if(fwdState->request->protocol == PROTO_HTTP || fwdState->request->protocol == PROTO_HTTPS ) { struct in_addr outgoing; unsigned short tos; debug(151,3)("mod_server_persist_connections-->private_openIdleConn : Opening idle connections for '%s' \n",name); outgoing = getOutgoingAddr(fwdState->request); tos = getOutgoingTOS(fwdState->request); int fd = fwdState->client_fd; persist_config *cfg = cc_get_mod_param(fd,mod); unsigned short port; port = fwdState->request->port; debug(151,3)("mod_server_persist_connections-->private_openIdleConn : cfg->server_ips == %s cfg->idle == %d idle = %d name == %s \n",cfg->server_ips,cfg->idle,idle,name); while (idle < cfg->idle && strstr(cfg->server_ips,name)) { private_openAnIdleConn(name, port , outgoing, tos, cfg->time_out,fwdState); idle++; } } return 0; }