Skip to contentSkip to conversation

postponing close() after aio_write() has finished

PATCH New Cyril Hrubis 1 participant 1 message May 25, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 postponing close() after aio_write() has finished

Hi,
in aio_return/1-1.c close() is called after asynchronous I/O write was queued. This according to POSIX may end up in one of two ends and it's implementation specified. One end is writing the file correctly while the other one is behave like aio_cancel() was called.
(http://www.opengroup.org/onlinepubs/9699919799/functions/close.html)
Test mentoined above rely on finishing asynchronous I/O correctly in this case. To fix that you must postpone close() after asynchronous I/O has finished.

Signed-of-by [email protected]
Signature · 2 lines
Cyril Hrubis
[email protected]
testcases/open_posix_testsuite/conformance/interfaces/aio_return/1-1.c +3 -2
Index: ltp-full-20090430/testcases/open_posix_testsuite/conformance/interfaces/aio_return/1-1.c
===================================================================
@@ -75,12 +75,11 @@ int main()
 		exit(PTS_FAIL);
 	}
 
-	close(fd);
-
 	do {
 		retval = aio_error( &aiocb);
 		if (retval == -1)
 		{
+			close(fd);
 			printf(TNAME " Error at aio_error(): %s\n",
 				strerror(errno));
 			exit(PTS_FAIL);
@@ -90,11 +89,13 @@ int main()
 	retval = aio_return(&aiocb);
 	if (retval != BUF_SIZE)
 	{
+		close(fd);
 		printf(TNAME " Error at aio_return(): %s\n",
 		       strerror(errno));
 		exit(PTS_FAIL);
 	}
 	
+	close(fd);
 	printf ("Test PASSED\n");
 	return PTS_PASS;
 }

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list