Sent a new patch for these problem.

1>  Add a cleanup() to remove the created message queues at premature exit.
2>  Change the default number of message queues from 100 to 10. Because the
maxmum on RHEL/SLES/Ubuntu is 16.


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-12 22:39:50.000000000 -0500
@@ -82,7 +82,7 @@

 #ifdef _LINUX_
 #define    MAX_MESSAGE_QUEUES 128
-#define    DEFAULT_MESSAGE_QUEUES 100
+#define    DEFAULT_MESSAGE_QUEUES 10
 #else
 #define    MAX_MESSAGE_QUEUES 4096
 #define    DEFAULT_MESSAGE_QUEUES 1000
@@ -97,11 +97,12 @@
  * parse_args (): Parse command line arguments
  * sys_error (): System error message function
  * error (): Error message function
+ * cleanup (): Cleanup function for the test
  */
 static void parse_args (int, char **);
 static void sys_error (const char *, int);
 static void error (const char *, int);
-
+static void cleanup (int qnum);
 /*
  * Global variables
  *
@@ -143,7 +144,10 @@ int main (int argc, char **argv)
                  if (debug) printf ("\tcreating queue [%d]\n", nqueues);
                  if ((msqid_array [nqueues++]
                        = msgget (IPC_PRIVATE, IPC_CREAT|mode)) < 0)
+                 {
+                       cleanup(nqueues);
                        sys_error ("msgget failed", __LINE__);
+                 }

                  if (nqueues > MAX_MESSAGE_QUEUES)
                        break;
@@ -158,12 +162,7 @@ int main (int argc, char **argv)
      }
      printf ("\n\tAll message queues created successfully\n");

-     while (nqueues > 0) {
-           if (msgctl (msqid_array [--nqueues], IPC_RMID, 0) < 0)
-                 sys_error ("msgctl (IPC_RMID) failed", __LINE__);
-           if (debug) printf ("\tremoved queue  [%d]\n", nqueues);
-     }
-
+        cleanup(nqueues);
      printf ("\nsuccessful!\n");
      return (0);
 }
@@ -242,3 +241,27 @@ static void error (const char *msg, int
      fprintf (stderr, "ERROR [line: %d] %s\n", line, msg);
      exit (-1);
 }
+
+
+/*---------------------------------------------------------------------+
+|                              cleanup()                               |
+| ==================================================================== |
+| cleanup() - performs all message queues cleanup for this test at     |
+|             completion or premature exit.                            |
+|             Remove the temporary message queues created.             |
+|                                                                      |
++---------------------------------------------------------------------*/
+void cleanup(int qnum)
+{
+        /*
+         *  Remove the allocated message queues.
+         */
+        while (qnum > 0) {
+           if (msqid_array [--qnum] < 0)
+                 continue;
+                if (msgctl (msqid_array [qnum], IPC_RMID, 0) < 0)
+                        sys_error ("msgctl (IPC_RMID) failed", __LINE__);
+                if (debug) printf ("\tremoved queue  [%d]\n", qnum);
+        }
+}
+


(See attached file: Fix_free_mq_message_queue_test_05.patch)



Best regards!

Jin Bing Guo  郭晋兵





                                                                       
             Subrata Modak                                             
             <[EMAIL PROTECTED]                                         
             et.ibm.com>                                                To
                                       Jin Bing Guo/China/[EMAIL PROTECTED]    
             08/11/2008 07:13                                           cc
             PM                        ltp-list                        
                                       <[email protected]>
                                                                   Subject
             Please respond to         Re: [LTP]  [PATCH] Fixed message
             [EMAIL PROTECTED]         queue leak  in                  
                 t.ibm.com             message_queue_test_05           
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       





On Mon, 2008-08-11 at 18:21 +0800, Jin Bing Guo wrote:
> Sorry for the format error of my patch. I resent it by an attachment .
> Please check it.
>
>
> Signed-off-by: Jin Bing Guo <[EMAIL PROTECTED]>

However, i do not see any problem that this patch solves now. Even after
apply the patch, i see the error popping up:


Before Patching:

# ./testcases/bin/message_queue_test_05
./testcases/bin/message_queue_test_05: IPC Message Queue TestSuite
program

        Creating 100 message queues ...
ERROR [line: 146] msgget failed: No space left on device

# echo $?
255


After Patching:

# ./testcases/bin/message_queue_test_05
./testcases/bin/message_queue_test_05: IPC Message Queue TestSuite
program

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

# echo $?
255

Can you please relook into this once again and send me the patch that
solves this issue as  ?

Regards--
Subrata

> ---
> Fix_free_mq_message_queue_test_05.patch
>
>
> (See attached file: Fix_free_mq_message_queue_test_05.patch)
>
> Best regards!
>
> Jin Bing Guo 郭晋兵
>
> Linux for System p Test
> IBM China Systems & Technology Laboratory in Beijing
> Tel: +86-10-82454439
> Email: [EMAIL PROTECTED]
> -------------------------------------
> "Do today what others won't so tomorrow you do what other's can't"
>
>
>
> Inactive hide details for Subrata Modak ---08/11/2008 04:58:02
> PM---Problem with this once as well:Subrata Modak ---08/11/2008
> 04:58:02 PM---Problem with this once as well:
>
>                                 Subrata Modak
<[EMAIL PROTECTED]>
>
>                                 08/11/2008 04:43 PM
>                                 Please respond to
>                                 [EMAIL PROTECTED]
>
>
>                To
>
> Jin Bing
> Guo/China/[EMAIL PROTECTED]
>
>                cc
>
> ltp-list
> <[email protected]>
>
>           Subject
>
> Re: [LTP] [PATCH]
> Fixed message
> queue leak in
> message_queue_test_05
>
>
>
> Problem with this once as well:
>
> $ patch --dry-run -p1 < ../11_08_2008-\([EMAIL PROTECTED]
> \)-003_message_queue_test05.patch
> missing header for unified diff at line 175 of patch
> can't find file to patch at input line 175
> Perhaps you used the wrong -p or --strip option?
> The text leading up to this was:
> --------------------------
> .........................
>
> .......................
> --------------------------
> File to patch: testcases/kernel/ipc/ipc_stress/message_queue_test_05.c
> patching file testcases/kernel/ipc/ipc_stress/message_queue_test_05.c
> patch: **** malformed patch at line 182: IPC_RMID, 0);
>
>
> Can you please resend this as well ?
>
> Regards--
> Subrata
>
>
> On Thu, 2008-08-07 at 14:39 +0800, Jin Bing Guo wrote:
> > 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
>
>
>
>

<<inline: graycol.gif>>

<<inline: pic06697.gif>>

<<inline: ecblank.gif>>

Attachment: Fix_free_mq_message_queue_test_05.patch
Description: Binary data

-------------------------------------------------------------------------
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