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

Method WaitConnect

adapter/micro_thread/mt_net.cpp:275–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275int32_t CNetHandler::WaitConnect(uint64_t timeout)
276{
277 CSockLink* conn = (CSockLink*)this->_conn_ptr;
278 if (NULL == conn)
279 {
280 MTLOG_ERROR("get sock link handle failed");
281 return RC_MEM_ERROR;
282 }
283
284 int32_t fd = conn->CreateSock();
285 if (fd < 0)
286 {
287 MTLOG_ERROR("create sock failed, ret %d[%m]", fd);
288 return RC_ERR_SOCKET;
289 }
290
291 if (conn->Connect())
292 {
293 MTLOG_DEBUG("sock conncet ok");
294 return RC_SUCCESS;
295 }
296
297 this->SwitchToConn();
298
299 MtFrame* mtframe = MtFrame::Instance();
300 mtframe->WaitNotify(timeout);
301
302 this->SwitchToIdle();
303
304 if (_err_no != 0)
305 {
306 MTLOG_ERROR("connect get out errno %d", _err_no);
307 return _err_no;
308 }
309
310 if (conn->Connected())
311 {
312 MTLOG_DEBUG("connect ok");
313 return 0;
314 }
315 else
316 {
317 MTLOG_TRACE("connect not ok, maybe timeout");
318 return RC_CONNECT_FAIL;
319 }
320}
321
322int32_t CNetHandler::WaitSend(uint64_t timeout)
323{

Callers 1

SendRecvMethod · 0.95

Calls 6

SwitchToConnMethod · 0.95
SwitchToIdleMethod · 0.95
CreateSockMethod · 0.80
ConnectMethod · 0.80
WaitNotifyMethod · 0.80
ConnectedMethod · 0.80

Tested by

no test coverage detected