posixaio: fix thread problem with using errno

If we fail queueing a read or a write, use aio_error() to
retrieve the right error value. This fixes an issue on
(at least) Solaris where we get EAGAIN due to system
shortage of resources, but treat that as a random type
of error due to using errno.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/engines/posixaio.c b/engines/posixaio.c
index a2b5387..2df26af 100644
--- a/engines/posixaio.c
+++ b/engines/posixaio.c
@@ -196,18 +196,20 @@
 		return FIO_Q_COMPLETED;
 #endif
 	}
-		
+
 	if (ret) {
+		int aio_err = aio_error(aiocb);
+
 		/*
 		 * At least OSX has a very low limit on the number of pending
 		 * IOs, so if it returns EAGAIN, we are out of resources
 		 * to queue more. Just return FIO_Q_BUSY to naturally
 		 * drop off at this depth.
 		 */
-		if (errno == EAGAIN)
+		if (aio_err == EAGAIN)
 			return FIO_Q_BUSY;
 
-		io_u->error = errno;
+		io_u->error = aio_err;
 		td_verror(td, io_u->error, "xfer");
 		return FIO_Q_COMPLETED;
 	}