static int should_keep_alive(HttpStateData * httpState, int * keep_alive) { debug(151,6)("mod_server_persist_connections : should_keep_alive enter, keep_alive == %d\n",*keep_alive); if(*keep_alive == 0) return 0; persist_config *cfg = cc_get_global_mod_param(mod); char* ipaddr = fd_table[httpState->fd].ipaddr; int port = fd_table[httpState->fd].remote_port; hash_link *hptr; hptr = pconnLookup(ipaddr, port, NULL, NULL, 0); debug(151,6)("mod_server_persist_connections : should_keep_alive hptr == %p ipaddr = %s\n",hptr,ipaddr); if (hptr != NULL) { struct _pconn *p = (struct _pconn*)hptr; debug(151,6)("mod_server_persist_connections : should_keep_alive p->nfds == %d cfg->max_conn == %d \n",p->nfds,cfg->max_conn); if(p->nfds > cfg->max_conn) { debug(151,6)("mod_server_persist_connections : should_keep_alive p->nfds == %d is larger than cfg->max_conn == %d ,so we set keep_alive flag to zerooooooooooooooooooooooooooooooo\n",p->nfds,cfg->max_conn); *keep_alive = 0; } } return 0; }
int pconnPop(const char *host, u_short port, const char *domain, struct in_addr *client_address, u_short client_port, int *idle) { struct _pconn *p; hash_link *hptr; int fd = -1; assert(table != NULL); hptr = pconnLookup(host, port, domain, client_address, client_port); if (hptr != NULL) { p = (struct _pconn *) hptr; assert(p->nfds > 0); fd = p->fds[p->nfds - 1]; if (idle) *idle = p->nfds - 1; pconnRemoveFD(p, fd); commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0); commSetTimeout(fd, -1, NULL, NULL); } return fd; }