MCPcopy Create free account
hub / github.com/Tencent/libco / recv

Function recv

co_hook_sys_call.cpp:539–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537}
538
539ssize_t recv( int socket, void *buffer, size_t length, int flags )
540{
541 HOOK_SYS_FUNC( recv );
542
543 if( !co_is_enable_sys_hook() )
544 {
545 return g_sys_recv_func( socket,buffer,length,flags );
546 }
547 rpchook_t *lp = get_by_fd( socket );
548
549 if( !lp || ( O_NONBLOCK & lp->user_flag ) )
550 {
551 return g_sys_recv_func( socket,buffer,length,flags );
552 }
553 int timeout = ( lp->read_timeout.tv_sec * 1000 )
554 + ( lp->read_timeout.tv_usec / 1000 );
555
556 struct pollfd pf = { 0 };
557 pf.fd = socket;
558 pf.events = ( POLLIN | POLLERR | POLLHUP );
559
560 int pollret = poll( &pf,1,timeout );
561
562 ssize_t readret = g_sys_recv_func( socket,buffer,length,flags );
563
564 if( readret < 0 )
565 {
566 co_log_err("CO_ERR: read fd %d ret %ld errno %d poll ret %d timeout %d",
567 socket,readret,errno,pollret,timeout);
568 }
569
570 return readret;
571
572}
573
574extern int co_poll_inner( stCoEpoll_t *ctx,struct pollfd fds[], nfds_t nfds, int timeout, poll_pfn_t pollfunc);
575

Callers

nothing calls this directly

Calls 4

co_is_enable_sys_hookFunction · 0.85
get_by_fdFunction · 0.85
pollFunction · 0.85
co_log_errFunction · 0.85

Tested by

no test coverage detected