lib/waiter: Ensure waiters are consistent during waiter_poll
authorJeremy Kerr <jk@ozlabs.org>
Fri, 17 May 2013 01:38:07 +0000 (09:38 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 21 May 2013 07:29:43 +0000 (15:29 +0800)
commit3461b6ad5cb90f1448360d0eb04dd661ae477610
treebefb7c3b0c861df219fec2a889b04b05184aee4d
parent7911281337857bd0f13e5945f6e70bb4af7388a0
lib/waiter: Ensure waiters are consistent during waiter_poll

We have a bug at the moment: if the waitset's->waiters array is updated
duing waiter_poll() (eg, a client connection is closed, and the client's
callback performs a waiter_remove()), then we may invoke callbacks for
incorrect waiters.

This change uses a consistent waiters array duing execution of
waiter_poll, so that any pollfds returned from poll() will result in
correct callback invocations.

This assumes that a waiter will only ever remove *itself* from the
waitset; otherwise, we may call a free()ed waiter.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
lib/waiter/waiter.c