aio_cancel: wait for requests which are already in progress

If request is already in progress, wait for it to complete,
so it doesn't race with exit of testcase (aiocb is allocated
on main's stack), to avoid aio_cancel_1-1 and 2-1 sporadically
crashing.

For example:
  Core was generated by `./aio_cancel_2-1.run-test '.
  Program terminated with signal 11, Segmentation fault.

  (gdb) bt
  #0  0x00003fffa6e81158 in __GI__exit (status=0)
  #1  0x00003fffa6df3054 in __run_exit_handlers (...)
  #2  0x00003fffa6df3134 in __GI_exit (status=<optimized out>)
  #3  0x00003fffa6dd4588 in generic_start_main (main=0x10000bbc ...)
  #4  0x00003fffa6dd4774 in __libc_start_main (...)
  #5  0x0000000000000000 in ?? ()

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
2 files changed