Date: Sat, 13 Jun 2009 10:47:20 GMT From: Zhao Shuai <zhaoshuai@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 164258 for review Message-ID: <200906131047.n5DAlK1H004711@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=164258 Change 164258 by zhaoshuai@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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906131047.n5DAlK1H004711>