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

Function recvfrom

co_hook_sys_call.cpp:459–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457}
458
459ssize_t recvfrom(int socket, void *buffer, size_t length,
460 int flags, struct sockaddr *address,
461 socklen_t *address_len)
462{
463 HOOK_SYS_FUNC( recvfrom );
464 if( !co_is_enable_sys_hook() )
465 {
466 return g_sys_recvfrom_func( socket,buffer,length,flags,address,address_len );
467 }
468
469 rpchook_t *lp = get_by_fd( socket );
470 if( !lp || ( O_NONBLOCK & lp->user_flag ) )
471 {
472 return g_sys_recvfrom_func( socket,buffer,length,flags,address,address_len );
473 }
474
475 int timeout = ( lp->read_timeout.tv_sec * 1000 )
476 + ( lp->read_timeout.tv_usec / 1000 );
477
478
479 struct pollfd pf = { 0 };
480 pf.fd = socket;
481 pf.events = ( POLLIN | POLLERR | POLLHUP );
482 poll( &pf,1,timeout );
483
484 ssize_t ret = g_sys_recvfrom_func( socket,buffer,length,flags,address,address_len );
485 return ret;
486}
487
488ssize_t send(int socket, const void *buffer, size_t length, int flags)
489{

Callers

nothing calls this directly

Calls 3

co_is_enable_sys_hookFunction · 0.85
get_by_fdFunction · 0.85
pollFunction · 0.85

Tested by

no test coverage detected