s3-aio-fork: Fix a segfault in vfs_aio_fork
authorVolker Lendecke <vl@samba.org>
Sat, 31 Mar 2012 11:37:20 +0000 (13:37 +0200)
committerKarolin Seeger <kseeger@samba.org>
Fri, 22 Jun 2012 19:39:00 +0000 (21:39 +0200)
commitdccc0d5b8565ec057ff4c41b8724d325212c734c
tree2575b326a80b783058f5106d77e54f87e6edebf0
parentbddc1ad3d5f8ce6d6730675f94f2eb713ca6c133
s3-aio-fork: Fix a segfault in vfs_aio_fork

aio_suspend does not signal the main process with a signal, it just waits. The
aio_fork module does not use the signal at all, it directly calls back into the
main smbd by calling smbd_aio_complete_aio_ex. This is an abstraction
violation, but the alternative would have been to use signals where they are
not needed. However, in wait_for_aio_completion this bites us: With aio_fork we
call handle_aio_completed twice on the same aio_ex struct: Once from the call
to handle_aio_completion within the aio_fork module and once from the code in
wait_for_aio_completion.

This patch fixes it in a pretty bad way by introducing flag variables and more
state. But the mid-term plan is to replace the posix aio calls from the vfs and
do pread_send/recv and pwrite_send/recv at the vfs layer, so this will
significantly change anyway.

Thanks to Kirill Malkin <kirill.malkin@starboardstorage.com> for reporting this
crash!

The last 2 patches address bug #8836 (aio_fork segfaults on "smbcontrol
close-share").
(cherry picked from commit b4abc44a370b8196c72d58a2ed4d8c9bcbc49d17)
source3/modules/vfs_aio_fork.c