| 544 | } |
| 545 | |
| 546 | bool 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 | |
| 581 | void TcpKeepMgr::FreeTcpKeepConn(TcpKeepConn* conn, bool force_free) |
| 582 | { |
nothing calls this directly
no test coverage detected