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

Function fcntl

co_hook_sys_call.cpp:616–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614
615
616int fcntl(int fildes, int cmd, ...)
617{
618 HOOK_SYS_FUNC( fcntl );
619
620 if( fildes < 0 )
621 {
622 return __LINE__;
623 }
624
625 va_list arg_list;
626 va_start( arg_list,cmd );
627
628 int ret = -1;
629 rpchook_t *lp = get_by_fd( fildes );
630 switch( cmd )
631 {
632 case F_DUPFD:
633 {
634 int param = va_arg(arg_list,int);
635 ret = g_sys_fcntl_func( fildes,cmd,param );
636 break;
637 }
638 case F_GETFD:
639 {
640 ret = g_sys_fcntl_func( fildes,cmd );
641 break;
642 }
643 case F_SETFD:
644 {
645 int param = va_arg(arg_list,int);
646 ret = g_sys_fcntl_func( fildes,cmd,param );
647 break;
648 }
649 case F_GETFL:
650 {
651 ret = g_sys_fcntl_func( fildes,cmd );
652 break;
653 }
654 case F_SETFL:
655 {
656 int param = va_arg(arg_list,int);
657 int flag = param;
658 if( co_is_enable_sys_hook() && lp )
659 {
660 flag |= O_NONBLOCK;
661 }
662 ret = g_sys_fcntl_func( fildes,cmd,flag );
663 if( 0 == ret && lp )
664 {
665 lp->user_flag = param;
666 }
667 break;
668 }
669 case F_GETOWN:
670 {
671 ret = g_sys_fcntl_func( fildes,cmd );
672 break;
673 }

Callers 3

SetNonBlockFunction · 0.85
SetNonBlockFunction · 0.85
socketFunction · 0.85

Calls 2

get_by_fdFunction · 0.85
co_is_enable_sys_hookFunction · 0.85

Tested by

no test coverage detected