MCPcopy Create free account
hub / github.com/apache/trafficserver / _acquire_session

Method _acquire_session

src/proxy/http/HttpSessionManager.cc:438–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436} // namespace
437
438HSMresult_t
439HttpSessionManager::_acquire_session(sockaddr const *ip, CryptoHash const &hostname_hash, HttpSM *sm,
440 TSServerSessionSharingMatchMask match_style, TSServerSessionSharingPoolType pool_type)
441{
442 PoolableSession *to_return = nullptr;
443 HSMresult_t retval = HSM_NOT_FOUND;
444
445 // Extend the mutex window until the acquired Server session is attached
446 // to the SM. Releasing the mutex before that results in race conditions
447 // due to a potential parallel network read on the VC with no mutex guarding
448 {
449 // Now check to see if we have a connection in our shared connection pool
450 EThread *ethread = this_ethread();
451 Ptr<ProxyMutex> pool_mutex =
452 (TS_SERVER_SESSION_SHARING_POOL_THREAD == pool_type) ? ethread->server_session_pool->mutex : m_g_pool->mutex;
453
454 MutexLock mlock;
455 MutexTryLock tlock;
456 bool const locked = lockSessionPool(pool_mutex, ethread, pool_type, &mlock, &tlock);
457
458 if (locked) {
459 if (TS_SERVER_SESSION_SHARING_POOL_THREAD == pool_type) {
460 retval = ethread->server_session_pool->acquireSession(ip, hostname_hash, match_style, sm, to_return);
461 Dbg(dbg_ctl_http_ss, "[acquire session] thread pool search %s", to_return ? "successful" : "failed");
462 } else {
463 retval = m_g_pool->acquireSession(ip, hostname_hash, match_style, sm, to_return);
464 Dbg(dbg_ctl_http_ss, "[acquire session] global pool search %s", to_return ? "successful" : "failed");
465 // At this point to_return has been removed from the pool. Do we need to move it
466 // to the same thread?
467 if (to_return) {
468 UnixNetVConnection *server_vc = dynamic_cast<UnixNetVConnection *>(to_return->get_netvc());
469 if (server_vc) {
470 // Disable i/o on this vc now, but, hold onto the g_pool cont
471 // and the mutex to stop any stray events from getting in
472 server_vc->do_io_read(m_g_pool, 0, nullptr);
473 server_vc->do_io_write(m_g_pool, 0, nullptr);
474 UnixNetVConnection *new_vc = server_vc->migrateToCurrentThread(sm, ethread);
475 // The VC moved, free up the original one
476 if (new_vc != server_vc) {
477 ink_assert(new_vc == nullptr || new_vc->nh != nullptr);
478 if (!new_vc) {
479 // Close out to_return, we were't able to get a connection
480 Metrics::Counter::increment(http_rsb.origin_shutdown_migration_failure);
481 to_return->do_io_close();
482 to_return = nullptr;
483 retval = HSM_NOT_FOUND;
484 } else {
485 // Keep things from timing out on us
486 new_vc->set_inactivity_timeout(new_vc->get_inactivity_timeout());
487 to_return->set_netvc(new_vc);
488 }
489 } else {
490 // Keep things from timing out on us
491 server_vc->set_inactivity_timeout(server_vc->get_inactivity_timeout());
492 }
493 }
494 }
495 }

Callers

nothing calls this directly

Calls 15

this_ethreadFunction · 0.85
lockSessionPoolFunction · 0.85
incrementFunction · 0.85
acquireSessionMethod · 0.80
create_server_txnMethod · 0.80
get_netvcMethod · 0.45
do_io_readMethod · 0.45
do_io_writeMethod · 0.45
do_io_closeMethod · 0.45

Tested by

no test coverage detected