Skip to content

Commit

Permalink
runtime: avoid deadlock when doing blocking accept()
Browse files Browse the repository at this point in the history
Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
  • Loading branch information
Jafaral committed Feb 10, 2022
1 parent ea95fb6 commit d8a7ad0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/runtime/fxposix.ri
Original file line number Diff line number Diff line change
Expand Up @@ -2321,8 +2321,11 @@ void post_if_ready(dptr ldp, dptr f, fd_set *fdsp)
*/
if (status & Fs_Listen) {
fromlen = sizeof(from);
if ((fd = accept(fd, (struct sockaddr *)&from, &fromlen)) < 0)
return;
DEC_NARTHREADS;
fd = accept(fd, (struct sockaddr *)&from, &fromlen);
INC_NARTHREADS_CONTROLLED;
if (fd < 0)
return;
BlkD(*f,File)->fd.fd = fd;
BlkLoc(*f)->File.status = Fs_Socket | Fs_Read | Fs_Write;
}
Expand Down

0 comments on commit d8a7ad0

Please sign in to comment.