PERFORCE change 164258 for review

Zhao Shuai zhaoshuai at FreeBSD.org
Sat Jun 13 10:47:22 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=164258

Change 164258 by zhaoshuai at zhaoshuai on 2009/06/13 10:46:37

	find a bug when testing fifo select.

Affected files ...

.. //depot/projects/soc2009/fifo/fifo_test/functionality/select.c#3 edit

Differences ...

==== //depot/projects/soc2009/fifo/fifo_test/functionality/select.c#3 (text+ko) ====

@@ -1,7 +1,10 @@
 /*
  * Basic FIFO select test.
  *
- * 1. select on read descriptor - OK
+ * 1. select on read descriptor - XXX
+ *	if writer exits before us, "top" shows that we are busy
+ *	consuming CPU rather than sleep.
+ *
  * 2. select on write descriptor - OK
  */
 
@@ -20,11 +23,9 @@
 
 	FD_ZERO(&rset);
 	FD_ZERO(&wset);
+	fd = open(FIFO_PATH, O_RDONLY | O_NONBLOCK);
 	/*
-	fd = open(FIFO_PATH, O_RDONLY | O_NONBLOCK);
-	*/
 	fd = open(FIFO_PATH, O_WRONLY | O_NONBLOCK);
-	/*
 	fd = open(FIFO_PATH, O_WRONLY); 
 	*/
 	if (fd < 0) {
@@ -35,24 +36,24 @@
 		FD_SET(fd, &rset);
 		FD_SET(fd, &wset);
 
+		ret = select(fd+1, &rset, NULL, NULL, NULL);
 		/*
-		ret = select(fd+1, &rset, NULL, NULL, NULL);
+		ret = select(fd+1, NULL, &wset, NULL, NULL);
 		*/
-		ret = select(fd+1, NULL, &wset, NULL, NULL);
 		if (ret > 0) {
-			/*
 			if (FD_ISSET(fd, &rset)) {
 				n = read(fd, buf, BUF_SIZE);
 				printf("%s", buf);
 				memset(buf, 0, n);
 			}
-			*/
+			/*
 			if (FD_ISSET(fd, &wset)) {
 				n = read(0, buf, BUF_SIZE);
 				if (n <= 0)
 					return (0);
 				write(fd, buf, n);
 			}
+			*/
 		} else if (ret < 0) { /* select error */
 			perror("select error");
 			return (2);


More information about the p4-projects mailing list