summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas@sandberg.pp.se>2013-10-07 16:03:15 +0200
committerAndreas Sandberg <andreas@sandberg.pp.se>2013-10-07 16:03:15 +0200
commitc0f367e51454dc9d2610bbd3266a80cec7b4ad69 (patch)
tree2eb387b9703f9d79d8d4291dd8516f19fa29a07a /src
parent0dd6f87e63edcafdb2df9b582d768bfca9e78d6a (diff)
downloadgem5-c0f367e51454dc9d2610bbd3266a80cec7b4ad69.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/base/pollevent.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/base/pollevent.cc b/src/base/pollevent.cc
index 67708c129..cb44d8728 100644
--- a/src/base/pollevent.cc
+++ b/src/base/pollevent.cc
@@ -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