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

Method WaitSend

adapter/micro_thread/mt_net.cpp:322–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322int32_t CNetHandler::WaitSend(uint64_t timeout)
323{
324 CSockLink* conn = (CSockLink*)this->_conn_ptr;
325 if (NULL == conn)
326 {
327 MTLOG_ERROR("get sock link handle failed");
328 return RC_MEM_ERROR;
329 }
330
331 int32_t ret = conn->SendData(_req_data, _req_len);
332 if (ret < 0)
333 {
334 MTLOG_ERROR("sock send failed, ret %d[%m]", ret);
335 return RC_SEND_FAIL;
336 }
337 this->SkipSendPos(ret);
338
339 if (_req_len == 0)
340 {
341 MTLOG_DEBUG("sock send ok");
342 return RC_SUCCESS;
343 }
344
345 this->SwitchToSend();
346
347 MtFrame* mtframe = MtFrame::Instance();
348 mtframe->WaitNotify(timeout);
349
350 this->SwitchToIdle();
351
352 if (_err_no != 0)
353 {
354 MTLOG_ERROR("send get out errno %d", _err_no);
355 return _err_no;
356 }
357
358 if (_req_len == 0)
359 {
360 MTLOG_DEBUG("send req ok, len %u", _send_pos);
361 return 0;
362 }
363 else
364 {
365 MTLOG_TRACE("send req not ok, left len %u", _req_len);
366 return RC_SEND_FAIL;
367 }
368}
369
370int32_t CNetHandler::WaitRecv(uint64_t timeout)
371{

Callers 1

SendRecvMethod · 0.95

Calls 5

SkipSendPosMethod · 0.95
SwitchToSendMethod · 0.95
SwitchToIdleMethod · 0.95
WaitNotifyMethod · 0.80
SendDataMethod · 0.45

Tested by

no test coverage detected