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

Method DispathUdp

adapter/micro_thread/mt_net.cpp:1276–1332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1274}
1275
1276int32_t CSockLink::DispathUdp()
1277{
1278 CHECK_SESSION_CALLBACK check_session = NULL;
1279 CNetHandler* item = TAILQ_FIRST(&_wait_recv);
1280 if (NULL == item)
1281 {
1282 MTLOG_DEBUG("recv data with no wait item, maybe wrong pkg recv");
1283 }
1284 else
1285 {
1286 check_session = item->GetSessionCallback();
1287 if (NULL == check_session)
1288 {
1289 MTLOG_TRACE("recv data with no session callback, err");
1290 }
1291 }
1292
1293 uint64_t sid = 0;
1294 uint32_t need_len = 0;
1295 int32_t ret = 0;
1296 TSkBuffer* block = NULL;
1297 while ((block = TAILQ_FIRST(&_recv_cache.list)) != NULL)
1298 {
1299 if (check_session == NULL)
1300 {
1301 MTLOG_DEBUG("no recv wait, skip first block");
1302 cache_skip_data(&_recv_cache, block->data_len);
1303 continue;
1304 }
1305
1306 need_len = 0;
1307 ret = check_session(block->data, block->data_len, &sid, &need_len);
1308 if ((ret <= 0) || (ret > (int32_t)block->data_len))
1309 {
1310 MTLOG_DEBUG("maybe wrong pkg come, skip it");
1311 cache_skip_data(&_recv_cache, block->data_len);
1312 continue;
1313 }
1314
1315 CNetHandler* session = this->FindSession(sid);
1316 if (NULL == session)
1317 {
1318 MTLOG_DEBUG("session id %llu, find failed, maybe timeout", sid);
1319 cache_skip_data(&_recv_cache, block->data_len);
1320 }
1321 else
1322 {
1323 MTLOG_DEBUG("session id %llu, find ok, wakeup it", sid);
1324 this->NotifyThread(session, 0);
1325 session->SwitchToIdle();
1326 cache_skip_first_buffer(&_recv_cache);
1327 session->SetRespBuff(block);
1328 }
1329 }
1330
1331 return 0;
1332}
1333

Callers 1

RecvDispathMethod · 0.95

Calls 7

FindSessionMethod · 0.95
NotifyThreadMethod · 0.95
cache_skip_dataFunction · 0.85
cache_skip_first_bufferFunction · 0.85
SwitchToIdleMethod · 0.80
SetRespBuffMethod · 0.80
GetSessionCallbackMethod · 0.45

Tested by

no test coverage detected