| 450 | } |
| 451 | |
| 452 | int32_t cache_tcp_send(TRWCache* cache, uint32_t fd) |
| 453 | { |
| 454 | if ((NULL == cache) || (NULL == cache->pool)) |
| 455 | { |
| 456 | return -1; |
| 457 | } |
| 458 | |
| 459 | if (cache->len == 0) |
| 460 | { |
| 461 | return 0; |
| 462 | } |
| 463 | |
| 464 | int32_t ret = 0, total = 0; |
| 465 | TSkBuffer* item = NULL; |
| 466 | TSkBuffer* tmp = NULL; |
| 467 | TAILQ_FOREACH_SAFE(item, &cache->list, entry, tmp) |
| 468 | { |
| 469 | mt_hook_syscall(send); |
| 470 | ret = ff_hook_send(fd, item->data, item->data_len, 0); |
| 471 | if (ret < 0) |
| 472 | { |
| 473 | break; |
| 474 | } |
| 475 | |
| 476 | total += ret; |
| 477 | if (ret < (int32_t)item->data_len) |
| 478 | { |
| 479 | break; |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | cache_skip_data(cache, total); |
| 484 | if (ret < 0) |
| 485 | { |
| 486 | if (errno != EAGAIN) |
| 487 | { |
| 488 | MTLOG_ERROR("tcp socket send failed, error: %d[%m]", errno); |
| 489 | return -2; |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | return total; |
| 494 | } |
| 495 | |
| 496 | int32_t cache_tcp_send_buff(TRWCache* cache, uint32_t fd, const void* data, uint32_t len) |
| 497 | { |
no test coverage detected