MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cache_tcp_send

Function cache_tcp_send

adapter/micro_thread/mt_cache.cpp:452–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450}
451
452int32_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
496int32_t cache_tcp_send_buff(TRWCache* cache, uint32_t fd, const void* data, uint32_t len)
497{

Callers 1

cache_tcp_send_buffFunction · 0.85

Calls 2

cache_skip_dataFunction · 0.85
ff_hook_sendFunction · 0.70

Tested by

no test coverage detected