base: Fix a potential race in PollQueue::setupAsyncIO
There is a potential race between enabling asynchronous IO and selecting the target for the SIGIO signal. This changeset move the F_SETOWN call to before the F_SETFL call that enables SIGIO delivery. This ensures that signals are always sent to the correct process.
This commit is contained in:
parent
0dd6f87e63
commit
c0f367e514
1 changed files with 3 additions and 3 deletions
|
@ -213,13 +213,13 @@ PollQueue::setupAsyncIO(int fd, bool set)
|
|||
else
|
||||
flags &= ~(FASYNC);
|
||||
|
||||
if (fcntl(fd, F_SETFL, flags) == -1)
|
||||
panic("Could not set up async IO");
|
||||
|
||||
if (set) {
|
||||
if (fcntl(fd, F_SETOWN, getpid()) == -1)
|
||||
panic("Could not set up async IO");
|
||||
}
|
||||
|
||||
if (fcntl(fd, F_SETFL, flags) == -1)
|
||||
panic("Could not set up async IO");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue