From: Andreas Sandberg Date: Mon, 7 Oct 2013 14:03:15 +0000 (+0200) Subject: base: Fix a potential race in PollQueue::setupAsyncIO X-Git-Tag: stable_2014_02_15~98 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c0f367e51454dc9d2610bbd3266a80cec7b4ad69;p=gem5.git 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. --- 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