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

Function cache_tcp_send_buff

adapter/micro_thread/mt_cache.cpp:496–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494}
495
496int32_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
539uint32_t get_data_len(TBuffVecPtr multi)
540{

Callers

nothing calls this directly

Calls 3

cache_tcp_sendFunction · 0.85
cache_append_dataFunction · 0.85
ff_hook_sendFunction · 0.70

Tested by

no test coverage detected