After aio_suspend, wait all aio_write operations to complete.

If don't do that, it fails with "Segmentation fault" on routerstation(mips)
board randomly about in 1000 continuous test. The reason may be some
aio_writes don't complete before close the file, that cause some resouse
don't be released and finally cause segment fault.

Signed-off-by: Kang Kai <[email protected]>
---
 .../conformance/interfaces/aio_suspend/3-1.c       |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git 
a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/3-1.c 
b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/3-1.c
index 15120e1..e8e9705 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/3-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/3-1.c
@@ -46,6 +46,7 @@ int main()
        struct aiocb aiocb[NAIOCB];
        const struct aiocb *list[NENT];
        int i;
+       int ret;
 
        if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
                return PTS_UNSUPPORTED;
@@ -87,6 +88,17 @@ int main()
                exit(PTS_FAIL);
        }
 
+       for (i = 0; i < NAIOCB; ++i) {
+               do {
+                       usleep(10000);
+                       ret = aio_error(&aiocb[i]);
+               } while (ret == EINPROGRESS);
+               if (aio_return(&aiocb[i]) == -1) {
+                       printf(TNAME " Error at aio_return(): %s\n", 
strerror(errno));
+                       exit(PTS_FAIL);
+               }
+       }
+
        close(fd);
        printf("Test PASSED\n");
        return PTS_PASS;
-- 
1.7.5.4


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to