aio-posix: fix concurrent access to poll_disable_cnt
commitd7be5dd19c0df7f76e1b42f0c2cbbabefa1974cb
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 12 Sep 2018 17:10:38 +0000 (12 19:10 +0200)
committerFam Zheng <famz@redhat.com>
Wed, 26 Sep 2018 02:46:21 +0000 (26 10:46 +0800)
treebe99efc03f1c05806d4e180b2f4feb1166dfa975
parentc5e4e49258e9b89cb34c085a419dd9f862935c48
aio-posix: fix concurrent access to poll_disable_cnt

It is valid for an aio_set_fd_handler to happen concurrently with
aio_poll.  In that case, poll_disable_cnt can change under the heels
of aio_poll, and the assertion on poll_disable_cnt can fail in
run_poll_handlers.

Therefore, this patch simply checks the counter on every polling
iteration.  There are no particular needs for ordering, since the
polling loop is terminated anyway by aio_notify at the end of
aio_set_fd_handler.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20180912171040.1732-2-pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
util/aio-posix.c