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
|
@ -213,13 +213,13 @@ PollQueue::setupAsyncIO(int fd, bool set)
|
||||||
else
|
else
|
||||||
flags &= ~(FASYNC);
|
flags &= ~(FASYNC);
|
||||||
|
|
||||||
if (fcntl(fd, F_SETFL, flags) == -1)
|
|
||||||
panic("Could not set up async IO");
|
|
||||||
|
|
||||||
if (set) {
|
if (set) {
|
||||||
if (fcntl(fd, F_SETOWN, getpid()) == -1)
|
if (fcntl(fd, F_SETOWN, getpid()) == -1)
|
||||||
panic("Could not set up async IO");
|
panic("Could not set up async IO");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fcntl(fd, F_SETFL, flags) == -1)
|
||||||
|
panic("Could not set up async IO");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue