In message_queue_test_05,  it planned to allocate 100 message queues for
stress testing.
But if the system resource of  message queue couldn't meet it, it would
exit without deleting
the allocated message queues. In addition, other test cases couldn't
allocate a new message queue any more.

---------------------------------------------------------------------------------
clashlp1:/testcases # cat /proc/sys/kernel/msgmni
16
medusalp1:/testcases/ltp/testcases/kernel/ipc/ipc_stress
#./message_queue_test_05
./message_queue_test_05: IPC Message Queue TestSuite program

        Creating 100 message queues ...
ERROR [line: 150] msgget failed: Invalid argument

clashlp1:/testcases # ipcs -q

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x00000000 1474560    root       777        0            0
0x00000000 1507329    root       777        0            0
0x00000000 1572866    root       777        0            0
0x00000000 1605635    root       777        0            0
0x00000000 1671172    root       777        0            0
0x00000000 1703941    root       777        0            0
0x00000000 1769478    root       777        0            0
0x00000000 1802247    root       777        0            0
0x00000000 1867784    root       777        0            0
0x00000000 1900553    root       777        0            0
0x00000000 1966090    root       777        0            0
0x00000000 1998859    root       777        0            0
0x00000000 2064396    root       777        0            0
0x00000000 2097165    root       777        0            0
0x00000000 2162702    root       777        0            0
0x00000000 2195471    root       777        0            0
---------------------------------------------------------------------------------

This patch fixed the two problems:
1> Remove the exit(-1); form the sys_error().  Because when removing
queues, it
would continue although some of queues failed in removing.  So It would
free the
held queues as far as possible.

2> Remove all allocated queues if it failed in allocating new queues. So it
would
free all the held queues before exiting the case.

Signed-off-by: Jin Bing Guo <[EMAIL PROTECTED]>
-----------------------------------------
---
ltp-full-20080731.orig/testcases/kernel/ipc/ipc_stress/message_queue_test_05.c
      2007-11-10 03:24:41.000000000 -0600
+++
ltp-full-20080731/testcases/kernel/ipc/ipc_stress/message_queue_test_05.c
2008-08-06 22:04:04.000000000 -0500
@@ -143,7 +143,13 @@
                  if (debug) printf ("\tcreating queue [%d]\n", nqueues);
                  if ((msqid_array [nqueues++]
                        = msgget (IPC_PRIVATE, IPC_CREAT|mode)) < 0)
+                 {
+                             while (nqueues > 0)
+                                   msgctl (msqid_array [--nqueues],
IPC_RMID, 0);
+
                        sys_error ("msgget failed", __LINE__);
+                       exit (-1);
+                 }

                  if (nqueues > MAX_MESSAGE_QUEUES)
                        break;
@@ -240,5 +246,4 @@
 static void error (const char *msg, int line)
 {
      fprintf (stderr, "ERROR [line: %d] %s\n", line, msg);
-     exit (-1);
 }


Best regards!

Jin Bing Guo  郭晋兵
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to