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

Method acquire_session

src/proxy/http/HttpSessionManager.cc:353–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351}
352
353HSMresult_t
354HttpSessionManager::acquire_session(HttpSM *sm, sockaddr const *ip, const char *hostname, ProxyTransaction *ua_txn)
355{
356 PoolableSession *to_return = nullptr;
357 TSServerSessionSharingMatchMask match_style =
358 static_cast<TSServerSessionSharingMatchMask>(sm->t_state.txn_conf->server_session_sharing_match);
359 CryptoHash hostname_hash;
360 HSMresult_t retval = HSM_NOT_FOUND;
361
362 CryptoContext().hash_immediate(hostname_hash, (unsigned char *)hostname, strlen(hostname));
363
364 // First check to see if there is a server session bound
365 // to the user agent session
366 to_return = ua_txn->get_server_session();
367 if (to_return != nullptr) {
368 ua_txn->attach_server_session(nullptr);
369
370 // Since the client session is reusing the same server session, it seems that the SNI should match
371 // Will the client make requests to different hosts over the same SSL session? Though checking
372 // the IP/hostname here seems a bit redundant too
373 //
374 if (ServerSessionPool::match(to_return, ip, hostname_hash, match_style) &&
375 (!(match_style & TS_SERVER_SESSION_SHARING_MATCH_MASK_SNI) ||
376 ServerSessionPool::validate_sni(sm, to_return->get_netvc())) &&
377 (!(match_style & TS_SERVER_SESSION_SHARING_MATCH_MASK_HOSTSNISYNC) ||
378 ServerSessionPool::validate_host_sni(sm, to_return->get_netvc())) &&
379 (!(match_style & TS_SERVER_SESSION_SHARING_MATCH_MASK_CERT) ||
380 ServerSessionPool::validate_cert(sm, to_return->get_netvc()))) {
381 Dbg(dbg_ctl_http_ss, "[%" PRId64 "] [acquire session] returning attached session ", to_return->connection_id());
382 to_return->state = PoolableSession::SSN_IN_USE;
383 sm->create_server_txn(to_return);
384 return HSM_DONE;
385 }
386 // Release this session back to the main session pool and
387 // then continue looking for one from the shared pool
388 Dbg(dbg_ctl_http_ss,
389 "[%" PRId64 "] [acquire session] "
390 "session not a match, returning to shared pool",
391 to_return->connection_id());
392 to_return->release(nullptr);
393 to_return = nullptr;
394 }
395
396 // Otherwise, check the thread pool first
397 if (this->get_pool_type() == TS_SERVER_SESSION_SHARING_POOL_THREAD ||
398 this->get_pool_type() == TS_SERVER_SESSION_SHARING_POOL_HYBRID) {
399 retval = _acquire_session(ip, hostname_hash, sm, match_style, TS_SERVER_SESSION_SHARING_POOL_THREAD);
400 }
401
402 // If you didn't get a match, and the global pool is an option go there.
403 if (retval != HSM_DONE) {
404 if (TS_SERVER_SESSION_SHARING_POOL_GLOBAL == this->get_pool_type() ||
405 TS_SERVER_SESSION_SHARING_POOL_HYBRID == this->get_pool_type()) {
406 retval = _acquire_session(ip, hostname_hash, sm, match_style, TS_SERVER_SESSION_SHARING_POOL_GLOBAL);
407 } else if (TS_SERVER_SESSION_SHARING_POOL_GLOBAL_LOCKED == this->get_pool_type())
408 retval = _acquire_session(ip, hostname_hash, sm, match_style, TS_SERVER_SESSION_SHARING_POOL_GLOBAL_LOCKED);
409 }
410

Callers 1

do_http_server_openMethod · 0.80

Calls 10

get_pool_typeMethod · 0.95
CryptoContextClass · 0.85
create_server_txnMethod · 0.80
matchFunction · 0.50
hash_immediateMethod · 0.45
get_server_sessionMethod · 0.45
attach_server_sessionMethod · 0.45
get_netvcMethod · 0.45
connection_idMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected