Skip to content

Commit 36b4e6f

Browse files
[PAL] Make flagcxP2pAccept blocking (flagos-ai#468)
1 parent 746347b commit 36b4e6f

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

flagcx/adaptor/net/ibrc_p2p_adaptor.cc

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -422,23 +422,24 @@ static flagcxResult_t flagcxP2pAccept(void *listenComm, void **recvComm) {
422422
struct flagcxP2pRecvComm *comm;
423423
FLAGCXCHECK(flagcxCalloc(&comm, 1));
424424

425-
// TCP accept (blocking with timeout)
426-
FLAGCXCHECK(flagcxSocketInit(&comm->sock));
427-
FLAGCXCHECK(flagcxSocketAccept(&comm->sock, &lComm->sock));
428-
int ready = 0;
429-
auto acceptStart = std::chrono::steady_clock::now();
425+
// TCP accept (blocking, no timeout)
426+
flagcxResult_t res;
427+
int ready;
428+
FLAGCXCHECKGOTO(flagcxSocketInit(&comm->sock), res, accept_fail);
429+
FLAGCXCHECKGOTO(flagcxSocketAccept(&comm->sock, &lComm->sock), res,
430+
accept_fail);
431+
ready = 0;
430432
while (!ready) {
431-
FLAGCXCHECK(flagcxSocketReady(&comm->sock, &ready));
433+
FLAGCXCHECKGOTO(flagcxSocketReady(&comm->sock, &ready), res, accept_fail);
432434
if (!ready) {
433-
if (std::chrono::steady_clock::now() - acceptStart >
434-
std::chrono::seconds(30)) {
435-
WARN("NET/IB_P2P : accept socket ready timed out after 30s");
436-
free(comm);
437-
return flagcxSystemError;
438-
}
439435
std::this_thread::sleep_for(std::chrono::milliseconds(1));
440436
}
441437
}
438+
if (0) {
439+
accept_fail:
440+
free(comm);
441+
return res;
442+
}
442443

443444
// Set up PD, CQ, QP
444445
FLAGCXCHECK(

0 commit comments

Comments
 (0)