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

Method CacheTcpKeepConn

adapter/micro_thread/mt_connection.cpp:546–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544}
545
546bool TcpKeepMgr::CacheTcpKeepConn(TcpKeepConn* conn)
547{
548 struct sockaddr_in* dst = conn->GetDestAddr();
549 if ((dst->sin_addr.s_addr == 0) || (dst->sin_port == 0))
550 {
551 MTLOG_ERROR("sock addr, invalid, %x:%d", dst->sin_addr.s_addr, dst->sin_port);
552 return false;
553 }
554
555 TcpKeepKey key(dst);
556 TcpKeepKey* conn_list = (TcpKeepKey*)_keep_hash->HashFindData(&key);
557 if (!conn_list)
558 {
559 conn_list = new TcpKeepKey(conn->GetDestAddr());
560 if (!conn_list) {
561 MTLOG_ERROR("new conn list failed, error");
562 return false;
563 }
564 _keep_hash->HashInsert(conn_list);
565 }
566
567 if (!conn->IdleAttach())
568 {
569 MTLOG_ERROR("conn IdleAttach failed, error");
570 return false;
571 }
572
573 conn->ConnReuseClean();
574 conn_list->InsertConn(conn);
575
576
577 return true;
578
579}
580
581void TcpKeepMgr::FreeTcpKeepConn(TcpKeepConn* conn, bool force_free)
582{

Callers

nothing calls this directly

Calls 6

HashFindDataMethod · 0.80
HashInsertMethod · 0.80
IdleAttachMethod · 0.80
ConnReuseCleanMethod · 0.80
InsertConnMethod · 0.80
GetDestAddrMethod · 0.45

Tested by

no test coverage detected