| 494 | } |
| 495 | |
| 496 | int32_t cache_tcp_send_buff(TRWCache* cache, uint32_t fd, const void* data, uint32_t len) |
| 497 | { |
| 498 | if ((NULL == cache) || (NULL == data)) |
| 499 | { |
| 500 | return -1; |
| 501 | } |
| 502 | |
| 503 | int32_t ret = cache_tcp_send(cache, fd); |
| 504 | if (ret < 0) |
| 505 | { |
| 506 | MTLOG_ERROR("tcp socket[%d] send cache data failed, rc: %d", fd, ret); |
| 507 | return ret; |
| 508 | } |
| 509 | |
| 510 | int32_t send_len = 0; |
| 511 | if (cache->len == 0) |
| 512 | { |
| 513 | mt_hook_syscall(send); |
| 514 | ret = ff_hook_send(fd, data, len, 0); |
| 515 | if (ret >= 0) |
| 516 | { |
| 517 | send_len += ret; |
| 518 | } |
| 519 | else |
| 520 | { |
| 521 | if (errno != EAGAIN) |
| 522 | { |
| 523 | MTLOG_ERROR("tcp socket[%d] send failed, error: %d[%m]", fd, errno); |
| 524 | return -2; |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | int32_t rc = cache_append_data(cache, (char*)data + send_len, len - send_len); |
| 530 | if (rc < 0) |
| 531 | { |
| 532 | MTLOG_ERROR("tcp socket[%d] apend data failed, rc: %d", fd, rc); |
| 533 | return -3; |
| 534 | } |
| 535 | |
| 536 | return send_len; |
| 537 | } |
| 538 | |
| 539 | uint32_t get_data_len(TBuffVecPtr multi) |
| 540 | { |
nothing calls this directly
no test coverage detected