MCPcopy Create free account
hub / github.com/F-Stack/f-stack / GetTcpKeepConn

Method GetTcpKeepConn

adapter/micro_thread/mt_connection.cpp:494–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492}
493
494TcpKeepConn* TcpKeepMgr::GetTcpKeepConn(struct sockaddr_in* dst)
495{
496 TcpKeepConn* conn = NULL;
497 if (NULL == dst)
498 {
499 MTLOG_ERROR("input param dst null, error");
500 return NULL;
501 }
502
503 TcpKeepKey key(dst);
504 TcpKeepKey* conn_list = (TcpKeepKey*)_keep_hash->HashFindData(&key);
505 if ((NULL == conn_list) || (NULL == conn_list->GetFirstConn()))
506 {
507 conn = _mem_queue.AllocPtr();
508 if (conn) {
509 conn->SetDestAddr(dst);
510 }
511 }
512 else
513 {
514 conn = conn_list->GetFirstConn();
515 conn_list->RemoveConn(conn);
516 conn->IdleDetach();
517 }
518
519 return conn;
520}
521
522bool TcpKeepMgr::RemoveTcpKeepConn(TcpKeepConn* conn)
523{

Callers 1

GetConnectionMethod · 0.80

Calls 6

HashFindDataMethod · 0.80
GetFirstConnMethod · 0.80
AllocPtrMethod · 0.80
SetDestAddrMethod · 0.80
RemoveConnMethod · 0.80
IdleDetachMethod · 0.80

Tested by

no test coverage detected