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

Method connect

adapter/micro_thread/micro_thread.cpp:1067–1116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1065}
1066
1067int MtFrame::connect(int fd, const struct sockaddr *addr, int addrlen, int timeout)
1068{
1069 MtFrame* mtframe = MtFrame::Instance();
1070 utime64_t start = mtframe->GetLastClock();
1071 MicroThread* thread = mtframe->GetActiveThread();
1072 utime64_t now = 0;
1073
1074 if(fd<0 || !addr || addrlen<1)
1075 {
1076 errno = EINVAL;
1077 MTLOG_ERROR("connect failed, errno: %d (%m)", errno);
1078 return -10;
1079 }
1080
1081 int n = 0;
1082 mt_hook_syscall(connect);
1083 while ((n = ff_hook_connect(fd, addr, addrlen)) < 0)
1084 {
1085 now = mtframe->GetLastClock();
1086 if ((int)(now - start) > timeout)
1087 {
1088 errno = ETIME;
1089 return -1;
1090 }
1091
1092 if (errno == EISCONN)
1093 {
1094 return 0;
1095 }
1096
1097 if (errno == EINTR) {
1098 continue;
1099 }
1100
1101 if (errno != EINPROGRESS) {
1102 MTLOG_ERROR("connect failed, errno: %d", errno);
1103 return -2;
1104 }
1105
1106 KqueuerObj epfd;
1107 epfd.SetOsfd(fd);
1108 epfd.EnableOutput();
1109 epfd.SetOwnerThread(thread);
1110 if (!mtframe->KqueueSchedule(NULL, &epfd, timeout)) {
1111 return -3;
1112 }
1113 }
1114
1115 return n;
1116}
1117
1118int MtFrame::accept(int fd, struct sockaddr *addr, socklen_t *addrlen, int timeout)
1119{

Callers 7

fm10k_setup_mbx_serviceFunction · 0.80
_connectMethod · 0.80
setupFunction · 0.80
handle_socketFunction · 0.80
registerMethod · 0.80
connTLSConnectFunction · 0.80
connConnectFunction · 0.80

Calls 7

GetLastClockMethod · 0.80
GetActiveThreadMethod · 0.80
SetOsfdMethod · 0.80
EnableOutputMethod · 0.80
ff_hook_connectFunction · 0.70
SetOwnerThreadMethod · 0.45
KqueueScheduleMethod · 0.45

Tested by

no test coverage detected