Called from the NetProcessor to let us know that a connection has closed down
| 253 | // connection has closed down |
| 254 | // |
| 255 | int |
| 256 | ServerSessionPool::eventHandler(int event, void *data) |
| 257 | { |
| 258 | NetVConnection *net_vc = nullptr; |
| 259 | PoolableSession *s = nullptr; |
| 260 | |
| 261 | switch (event) { |
| 262 | case VC_EVENT_READ_READY: |
| 263 | // The server sent us data. This is unexpected so |
| 264 | // close the connection |
| 265 | /* Fall through */ |
| 266 | case VC_EVENT_EOS: |
| 267 | case VC_EVENT_ERROR: |
| 268 | case VC_EVENT_INACTIVITY_TIMEOUT: |
| 269 | case VC_EVENT_ACTIVE_TIMEOUT: |
| 270 | net_vc = static_cast<NetVConnection *>((static_cast<VIO *>(data))->vc_server); |
| 271 | break; |
| 272 | |
| 273 | default: |
| 274 | ink_release_assert(0); |
| 275 | return 0; |
| 276 | } |
| 277 | |
| 278 | sockaddr const *addr = net_vc->get_remote_addr(); |
| 279 | bool found = false; |
| 280 | |
| 281 | for (auto spot = m_ip_pool.find(addr); spot != m_ip_pool.end() && spot->_ip_link.equal(addr, spot); ++spot) { |
| 282 | if ((s = spot)->get_netvc() == net_vc) { |
| 283 | // if there was a timeout of some kind on a keep alive connection, and |
| 284 | // keeping the connection alive will not keep us above the # of max connections |
| 285 | // to the origin and we are below the min number of keep alive connections to this |
| 286 | // origin, then reset the timeouts on our end and do not close the connection |
| 287 | if ((event == VC_EVENT_INACTIVITY_TIMEOUT || event == VC_EVENT_ACTIVE_TIMEOUT) && s->state == PoolableSession::KA_POOLED && |
| 288 | s->conn_track_group) { |
| 289 | Dbg(dbg_ctl_http_ss, "s->conn_track_group->min_keep_alive_conns : %d", s->conn_track_group->_min_keep_alive_conns); |
| 290 | bool connection_count_below_min = s->conn_track_group->_count <= s->conn_track_group->_min_keep_alive_conns; |
| 291 | |
| 292 | if (connection_count_below_min) { |
| 293 | Dbg(dbg_ctl_http_ss, |
| 294 | "[%" PRId64 "] [session_bucket] session received io notice [%s], " |
| 295 | "resetting timeout to maintain minimum number of connections", |
| 296 | s->connection_id(), HttpDebugNames::get_event_name(event)); |
| 297 | s->get_netvc()->set_inactivity_timeout(s->get_netvc()->get_inactivity_timeout()); |
| 298 | found = true; |
| 299 | break; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | // We've found our server session. Remove it from |
| 304 | // our lists and close it down |
| 305 | Dbg(dbg_ctl_http_ss, "[%" PRId64 "] [session_pool] session %p received io notice [%s]", s->connection_id(), s, |
| 306 | HttpDebugNames::get_event_name(event)); |
| 307 | ink_assert(s->state == PoolableSession::KA_POOLED); |
| 308 | // Out of the pool! Now! |
| 309 | this->removeSession(s); |
| 310 | // Drop connection on this end. |
| 311 | s->do_io_close(); |
| 312 | found = true; |
nothing calls this directly
no test coverage detected