fusefs: fix running multiple daemons concurrently
When a FUSE daemon dies or closes /dev/fuse, all of that daemon's pending
requests must be terminated. Previously that was done in /dev/fuse's
.d_close method. However, d_close only gets called on the *last* close of
the device. That means that if multiple daemons were running concurrently,
all but the last daemon to close would leave their I/O hanging around. The
problem was easily visible just by running "kyua -v parallelism=2 test" in
fusefs's test directory.
Fix this bug by terminating a daemon's pending I/O during /dev/fuse's
cdvpriv dtor method instead. That method runs on every close of a file.
Also, fix some potential races in the tests:
- Clear SA_RESTART when registering the daemon's signal handler so read(2) will return EINTR.
- Wait for the daemon to die before unmounting the mountpoint, so we won't see an unwanted FUSE_DESTROY operation in the mock file system.
Sponsored by: The FreeBSD Foundation