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

Method DispathTcp

adapter/micro_thread/mt_net.cpp:1183–1274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1181}
1182
1183int32_t CSockLink::DispathTcp()
1184{
1185 CHECK_SESSION_CALLBACK check_session = this->GetSessionCallback();
1186 if (NULL == check_session)
1187 {
1188 MTLOG_ERROR("recv data with no session callback, err");
1189 return -1;
1190 }
1191
1192 uint32_t need_len = 0;
1193 uint64_t sid = 0;
1194 int32_t ret = 0;
1195 while (_recv_cache.len > 0)
1196 {
1197 this->ExtendRecvRsp();
1198 if (NULL == _rsp_buff)
1199 {
1200 MTLOG_ERROR("alloc memory, error");
1201 _errno = RC_MEM_ERROR;
1202 return -3;
1203 }
1204
1205 need_len = 0;
1206 ret = check_session(_rsp_buff->data, _rsp_buff->data_len, &sid, &need_len);
1207
1208 if (ret < 0)
1209 {
1210 MTLOG_ERROR("user check resp failed, ret %d", ret);
1211 _errno = RC_CHECK_PKG_FAIL;
1212 return -1;
1213 }
1214
1215 if (ret == 0)
1216 {
1217 if ((need_len == 0) && (_rsp_buff->data_len == _rsp_buff->size))
1218 {
1219 MTLOG_DEBUG("recv default buff full[%u], but user no set need length", _rsp_buff->size);
1220 need_len = _rsp_buff->size * 2;
1221 }
1222
1223 if ((need_len <= _rsp_buff->size) || (need_len > 100*1024*1024))
1224 {
1225 MTLOG_DEBUG("maybe need wait more data: %u", need_len);
1226 return 0;
1227 }
1228
1229 _rsp_buff = reserve_sk_buffer(_rsp_buff, need_len);
1230 if (NULL == _rsp_buff)
1231 {
1232 MTLOG_ERROR("no more memory, error");
1233 _errno = RC_MEM_ERROR;
1234 return -3;
1235 }
1236
1237 if (_rsp_buff->data_len >= _recv_cache.len)
1238 {
1239 MTLOG_DEBUG("maybe need wait more data, now %u", _recv_cache.len);
1240 return 0;

Callers 1

RecvDispathMethod · 0.95

Calls 9

GetSessionCallbackMethod · 0.95
ExtendRecvRspMethod · 0.95
FindSessionMethod · 0.95
NotifyThreadMethod · 0.95
reserve_sk_bufferFunction · 0.85
cache_skip_dataFunction · 0.85
delete_sk_bufferFunction · 0.85
SwitchToIdleMethod · 0.80
SetRespBuffMethod · 0.80

Tested by

no test coverage detected