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

Method read

adapter/micro_thread/micro_thread.cpp:1164–1208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1162}
1163
1164ssize_t MtFrame::read(int fd, void *buf, size_t nbyte, int timeout)
1165{
1166 MtFrame* mtframe = MtFrame::Instance();
1167 utime64_t start = mtframe->GetLastClock();
1168 MicroThread* thread = mtframe->GetActiveThread();
1169 utime64_t now = 0;
1170
1171 if(fd<0 || !buf || nbyte<1)
1172 {
1173 errno = EINVAL;
1174 MTLOG_ERROR("read failed, errno: %d (%m)", errno);
1175 return -10;
1176 }
1177
1178 ssize_t n = 0;
1179 mt_hook_syscall(read);
1180 while ((n = ff_hook_read(fd, buf, nbyte)) < 0)
1181 {
1182 now = mtframe->GetLastClock();
1183 if ((int)(now - start) > timeout)
1184 {
1185 errno = ETIME;
1186 return -1;
1187 }
1188
1189 if (errno == EINTR) {
1190 continue;
1191 }
1192
1193 if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) {
1194 MTLOG_ERROR("read failed, errno: %d", errno);
1195 return -2;
1196 }
1197
1198 KqueuerObj epfd;
1199 epfd.SetOsfd(fd);
1200 epfd.EnableInput();
1201 epfd.SetOwnerThread(thread);
1202 if (!mtframe->KqueueSchedule(NULL, &epfd, timeout)) {
1203 return -3;
1204 }
1205 }
1206
1207 return n;
1208}
1209
1210ssize_t MtFrame::write(int fd, const void *buf, size_t nbyte, int timeout)
1211{

Callers 15

receive_headerFunction · 0.45
_listFunction · 0.45
apply_templateFunction · 0.45
open_inputFunction · 0.45
read_inputFunction · 0.45
has-hugepages.pyFile · 0.45
get-test-suites.pyFile · 0.45
opae_acc_reg_readFunction · 0.45
igbvf_mbx_processFunction · 0.45
eth_igb_get_eepromFunction · 0.45

Calls 7

GetLastClockMethod · 0.80
GetActiveThreadMethod · 0.80
SetOsfdMethod · 0.80
EnableInputMethod · 0.80
ff_hook_readFunction · 0.70
SetOwnerThreadMethod · 0.45
KqueueScheduleMethod · 0.45

Tested by

no test coverage detected