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

Method mt_multi_recvfrom

adapter/micro_thread/mt_concurrent.cpp:309–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307}
308
309int NS_MICRO_THREAD::mt_multi_recvfrom(IMtActList& req_list, int timeout)
310{
311 utime64_t start_ms = MtFrame::Instance()->GetLastClock();
312 utime64_t end_ms = start_ms + timeout;
313 utime64_t curr_ms = 0;
314
315 int ret = 0;
316 IMtAction* action = NULL;
317 IMtConnection* net_handler = NULL;
318
319 while (1)
320 {
321 IMtActList wait_list;
322 for (IMtActList::iterator it = req_list.begin(); it != req_list.end(); ++it)
323 {
324 action = *it;
325 if (action->GetErrno() != ERR_NONE) {
326 continue;
327 }
328
329 if (MULTI_FLAG_FIN == action->GetMsgFlag())
330 {
331 continue;
332 }
333
334 net_handler = action->GetIConnection();
335 if (NULL == net_handler)
336 {
337 action->SetErrno(ERR_FRAME_ERROR);
338 MTLOG_ERROR("Invalid param, conn %p null!!", net_handler);
339 return -2;
340 }
341
342 ret = net_handler->RecvData();
343 if (ret < 0)
344 {
345 action->SetErrno(ERR_RECV_FAIL);
346 MTLOG_ERROR("MultiItem msg recv failed: %p", net_handler);
347 continue;
348 }
349 else if (ret == 0)
350 {
351 wait_list.push_back(action);
352 continue;
353 }
354 else
355 {
356 action->SetMsgFlag(MULTI_FLAG_FIN);
357 action->SetCost(MtFrame::Instance()->GetLastClock() - start_ms);
358 }
359 }
360
361 curr_ms = MtFrame::Instance()->GetLastClock();
362 if (curr_ms > end_ms)
363 {
364 MTLOG_DEBUG("Recv data timeout, curr %llu, start: %llu", curr_ms, start_ms);
365 for (IMtActList::iterator it = wait_list.begin(); it != wait_list.end(); ++it)
366 {

Callers

nothing calls this directly

Calls 8

GetLastClockMethod · 0.80
GetErrnoMethod · 0.80
GetMsgFlagMethod · 0.80
GetIConnectionMethod · 0.80
SetErrnoMethod · 0.80
SetMsgFlagMethod · 0.80
SetCostMethod · 0.80
RecvDataMethod · 0.45

Tested by

no test coverage detected