Skip to content

Commit cabc52d

Browse files
committed
Merge branch 'io_uring-7.0' into for-next
* io_uring-7.0: io_uring/poll: fix multishot recv missing EOF on wakeup race
2 parents 2d1373e + a68ed2d commit cabc52d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

io_uring/poll.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw)
272272
atomic_andnot(IO_POLL_RETRY_FLAG, &req->poll_refs);
273273
v &= ~IO_POLL_RETRY_FLAG;
274274
}
275+
v &= IO_POLL_REF_MASK;
275276
}
276277

277278
/* the mask was stashed in __io_poll_execute */
@@ -304,8 +305,13 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw)
304305
return IOU_POLL_REMOVE_POLL_USE_RES;
305306
}
306307
} else {
307-
int ret = io_poll_issue(req, tw);
308+
int ret;
308309

310+
/* multiple refs and HUP, ensure we loop once more */
311+
if ((req->cqe.res & (POLLHUP | POLLRDHUP)) && v != 1)
312+
v--;
313+
314+
ret = io_poll_issue(req, tw);
309315
if (ret == IOU_COMPLETE)
310316
return IOU_POLL_REMOVE_POLL_USE_RES;
311317
else if (ret == IOU_REQUEUE)
@@ -321,7 +327,6 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw)
321327
* Release all references, retry if someone tried to restart
322328
* task_work while we were executing it.
323329
*/
324-
v &= IO_POLL_REF_MASK;
325330
} while (atomic_sub_return(v, &req->poll_refs) & IO_POLL_REF_MASK);
326331

327332
io_napi_add(req);

0 commit comments

Comments
 (0)