| 397 | } |
| 398 | |
| 399 | bool TcpKeepConn::IdleAttach() |
| 400 | { |
| 401 | if (_osfd < 0) { |
| 402 | MTLOG_ERROR("obj %p attach failed, fd %d error", this, _osfd); |
| 403 | return false; |
| 404 | } |
| 405 | |
| 406 | if (_keep_flag & TCP_KEEP_IN_KQUEUE) { |
| 407 | MTLOG_ERROR("obj %p repeat attach, error", this); |
| 408 | return true; |
| 409 | } |
| 410 | |
| 411 | _keep_ntfy.DisableOutput(); |
| 412 | _keep_ntfy.EnableInput(); |
| 413 | |
| 414 | CTimerMng* timer = MtFrame::Instance()->GetTimerMng(); |
| 415 | if ((NULL == timer) || !timer->start_timer(this, _keep_time)) |
| 416 | { |
| 417 | MTLOG_ERROR("obj %p attach timer failed, error", this); |
| 418 | return false; |
| 419 | } |
| 420 | |
| 421 | if (MtFrame::Instance()->KqueueAddObj(&_keep_ntfy)) |
| 422 | { |
| 423 | _keep_flag |= TCP_KEEP_IN_KQUEUE; |
| 424 | return true; |
| 425 | } |
| 426 | else |
| 427 | { |
| 428 | MTLOG_ERROR("obj %p attach failed, error", this); |
| 429 | return false; |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | bool TcpKeepConn::IdleDetach() |
| 434 | { |
no test coverage detected