Hi !

Fix concurrency issue in msgrcv06. Due to the use of usleep function to
synchronize processes, synchronization issues can occur on a loaded
system. Fix this by using pipes to synchronize processes.

Signed-off-by: Matthieu Fertré <[EMAIL PROTECTED]>

R.

-- 
Renaud Lottiaux

Kerlabs
Bâtiment Germanium
80, avenue des buttes de Coësmes
35700 Rennes - France
Phone : (+33|0)6 80 89 19 34
Fax   : (+33|0)2 99 84 71 71
Email : [EMAIL PROTECTED]
Web   : http://www.kerlabs.com/
Index: cvs/testcases/kernel/syscalls/ipc/msgrcv/Makefile
===================================================================
--- cvs.orig/testcases/kernel/syscalls/ipc/msgrcv/Makefile	2008-03-28 14:54:26.000000000 +0100
+++ cvs/testcases/kernel/syscalls/ipc/msgrcv/Makefile	2008-03-28 15:09:14.000000000 +0100
@@ -16,8 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+CFLAGS += -I../lib -I../../lib -I../../../../../include -Wall
+LDLIBS += -L../../../../../lib -lltp -L.. -lipc -L../.. -ltestsuite
 
 SRCS    = $(wildcard *.c)
 TARGETS = $(patsubst %.c,%,$(SRCS))
Index: cvs/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c
===================================================================
--- cvs.orig/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c	2008-03-28 14:54:26.000000000 +0100
+++ cvs/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c	2008-03-28 15:10:39.000000000 +0100
@@ -47,6 +47,11 @@
  *
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
+ *      14/03/2008 Matthieu Fertré ([EMAIL PROTECTED])
+ *      - Fix concurrency issue. Due to the use of usleep function to
+ *        synchronize processes, synchronization issues can occur on a loaded
+ *        system. Fix this by using pipes to synchronize processes.
+ *
  *
  * RESTRICTIONS
  *	none
@@ -56,6 +61,7 @@
 #include "usctest.h"
 
 #include "ipcmsg.h"
+#include "libtestsuite.h"
 
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -83,6 +89,7 @@
 {
 	int lc;				/* loop counter */
 	char *msg;			/* message returned from parse_opts */
+	int sync_pipes[2];
 
 	/* parse standard options */
 	if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
@@ -95,6 +102,10 @@
 
 	setup();			/* global setup */
 
+	if (create_sync_pipes(sync_pipes) == -1) {
+		tst_brkm(TBROK, cleanup, "cannot create sync pipes");
+	}
+
 	/* The following loop checks looping state if -i option given */
 
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
@@ -126,6 +137,11 @@
 			 * Attempt to read a message without IPC_NOWAIT.
 			 * With no message to read, the child sleeps.
 			 */
+
+			if (notify_startup(sync_pipes) == -1) {
+				tst_brkm(TBROK, cleanup, "notify_startup failed");
+			}
+
 #ifdef UCLINUX
 			if (self_exec(av[0], "d", msg_q_1) < 0) {
 				tst_brkm(TBROK, cleanup, "could not self_exec");
@@ -134,7 +150,11 @@
 			do_child();
 #endif
 		} else {			/* parent */
-			usleep(250000);
+
+			if (wait_son_startup(sync_pipes) == -1) {
+				tst_brkm(TBROK, cleanup, "wait_son_startup failed");
+			}
+			sleep(1);
 
 			/* remove the queue */
 			rm_queue(msg_q_1);
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to