| 320 | } |
| 321 | |
| 322 | int32_t CNetHandler::WaitSend(uint64_t timeout) |
| 323 | { |
| 324 | CSockLink* conn = (CSockLink*)this->_conn_ptr; |
| 325 | if (NULL == conn) |
| 326 | { |
| 327 | MTLOG_ERROR("get sock link handle failed"); |
| 328 | return RC_MEM_ERROR; |
| 329 | } |
| 330 | |
| 331 | int32_t ret = conn->SendData(_req_data, _req_len); |
| 332 | if (ret < 0) |
| 333 | { |
| 334 | MTLOG_ERROR("sock send failed, ret %d[%m]", ret); |
| 335 | return RC_SEND_FAIL; |
| 336 | } |
| 337 | this->SkipSendPos(ret); |
| 338 | |
| 339 | if (_req_len == 0) |
| 340 | { |
| 341 | MTLOG_DEBUG("sock send ok"); |
| 342 | return RC_SUCCESS; |
| 343 | } |
| 344 | |
| 345 | this->SwitchToSend(); |
| 346 | |
| 347 | MtFrame* mtframe = MtFrame::Instance(); |
| 348 | mtframe->WaitNotify(timeout); |
| 349 | |
| 350 | this->SwitchToIdle(); |
| 351 | |
| 352 | if (_err_no != 0) |
| 353 | { |
| 354 | MTLOG_ERROR("send get out errno %d", _err_no); |
| 355 | return _err_no; |
| 356 | } |
| 357 | |
| 358 | if (_req_len == 0) |
| 359 | { |
| 360 | MTLOG_DEBUG("send req ok, len %u", _send_pos); |
| 361 | return 0; |
| 362 | } |
| 363 | else |
| 364 | { |
| 365 | MTLOG_TRACE("send req not ok, left len %u", _req_len); |
| 366 | return RC_SEND_FAIL; |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | int32_t CNetHandler::WaitRecv(uint64_t timeout) |
| 371 | { |
no test coverage detected