static void peerMonitorCompleted(PeerMonitor * pm) { int state = PEER_ALIVE; peer *p = pm->peer; storeClientUnregister(pm->running.sc, pm->running.e, pm); storeUnlockObject(pm->running.e); requestUnlink(pm->running.req); memFree(pm->running.buf, MEM_4K_BUF); if (pm->running.timeout_set) { eventDelete(peerMonitorTimeout, pm); pm->running.timeout_set = 0; } if (!cbdataValid(pm->peer)) { cbdataFree(pm); return; } /* Figure out if the response was OK or not */ if (pm->running.status != HTTP_OK) { debug(DBG, 1) ("peerMonitor %s: Failed, status != 200 (%d)\n", p->name, pm->running.status); state = PEER_DEAD; } else if (pm->running.size < p->monitor.min) { debug(DBG, 1) ("peerMonitor %s: Failed, reply size %d < min %d\n", p->name, pm->running.size, p->monitor.min); state = PEER_DEAD; } else if (pm->running.size > p->monitor.max && p->monitor.max > 0) { debug(DBG, 1) ("peerMonitor %s: Failed, reply size %d > max %d\n", p->name, pm->running.size, p->monitor.max); state = PEER_DEAD; } else { debug(DBG, 2) ("peerMonitor %s: OK\n", p->name); } p->monitor.state = state; if (state != p->stats.logged_state) { switch (state) { case PEER_ALIVE: debug(DBG, 1) ("Detected REVIVED %s: %s\n", neighborTypeStr(p), p->name); peerClearRR(); break; case PEER_DEAD: debug(DBG, 1) ("Detected DEAD %s: %s\n", neighborTypeStr(p), p->name); break; } p->stats.logged_state = state; } memset(&pm->running, 0, sizeof(pm->running)); eventAdd(pm->name, peerMonitorRequest, pm, (double) (pm->last_probe + pm->peer->monitor.interval - current_dtime), 1); }
static void neighborAliveHtcp(peer * p, const MemObject * mem, const htcpReplyData * htcp) { if (p->stats.logged_state == PEER_DEAD && p->tcp_up) { debug(15, 1) ("Detected REVIVED %s: %s\n", neighborTypeStr(p), p->name); p->stats.logged_state = PEER_ALIVE; peerClearRR(); } p->stats.last_reply = squid_curtime; p->stats.probe_start = 0; p->stats.pings_acked++; p->htcp.counts[htcp->hit ? 1 : 0]++; p->htcp.version = htcp->version; }
void peerConnectSucceded(peer * p) { if (!p->tcp_up) { debug(15, 2) ("TCP connection to %s (%s:%d) succeded\n", p->name, p->host, p->http_port); debug(15, 1) ("Detected REVIVED %s: %s\n", neighborTypeStr(p), p->name); peerMonitorNow(p); p->stats.logged_state = PEER_ALIVE; peerClearRR(); if (!p->n_addresses) ipcache_nbgethostbyname(p->host, peerDNSConfigure, p); } p->tcp_up = p->connect_fail_limit; }
static void neighborAlive(peer * p, const MemObject * mem, const icp_common_t * header) { if (p->stats.logged_state == PEER_DEAD && p->tcp_up) { debug(15, 1) ("Detected REVIVED %s: %s\n", neighborTypeStr(p), p->name); p->stats.logged_state = PEER_ALIVE; peerClearRR(); } p->stats.last_reply = squid_curtime; p->stats.probe_start = 0; p->stats.pings_acked++; if ((icp_opcode) header->opcode <= ICP_END) p->icp.counts[header->opcode]++; p->icp.version = (int) header->version; }
/* This gets called every 5 minutes to clear the round-robin counter. */ static void peerClearRRLoop(void *data) { peerClearRR(); eventAdd("peerClearRR", peerClearRRLoop, data, 5 * 60.0, 0); }