From owner-svn-src-head@freebsd.org Sat Feb 27 13:24:48 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F3FA2AB64BC; Sat, 27 Feb 2016 13:24:47 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smarthost1.greenhost.nl (smarthost1.greenhost.nl [195.190.28.81]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BD8E88BB; Sat, 27 Feb 2016 13:24:47 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smtp.greenhost.nl ([213.108.104.138]) by smarthost1.greenhost.nl with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1aZecB-0004MQ-PW; Sat, 27 Feb 2016 14:09:01 +0100 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, "Pedro F. Giffuni" Subject: Re: svn commit: r296109 - head/libexec/rlogind References: <201602262002.u1QK2298094838@repo.freebsd.org> Date: Sat, 27 Feb 2016 14:08:47 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Ronald Klop" Message-ID: In-Reply-To: <201602262002.u1QK2298094838@repo.freebsd.org> User-Agent: Opera Mail/12.16 (FreeBSD) X-Authenticated-As-Hash: 398f5522cb258ce43cb679602f8cfe8b62a256d1 X-Virus-Scanned: by clamav at smarthost1.samage.net X-Spam-Level: / X-Spam-Score: -0.2 X-Spam-Status: No, score=-0.2 required=5.0 tests=ALL_TRUSTED, BAYES_50 autolearn=disabled version=3.4.0 X-Scan-Signature: bb59c828db3c430e2c178cb0ddebf9e4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Feb 2016 13:24:48 -0000 Hi, I'm not a FreeBSD commiter, but read these commits to stay informed about what is happening. This commit (and the one for talk) mentions _what_ is changed, but not _why_ it is changed. I'm curious why this is better. Mind to share any comments on this? Regards, Ronald. On Fri, 26 Feb 2016 21:02:02 +0100, Pedro F. Giffuni wrote: > Author: pfg > Date: Fri Feb 26 20:02:01 2016 > New Revision: 296109 > URL: https://svnweb.freebsd.org/changeset/base/296109 > > Log: > rlogin(1): Replace select(2) with poll(2). > Obtanied from: NetBSD (CVS Rev. 1.27 - 1.28) > > Modified: > head/libexec/rlogind/rlogind.c > > Modified: head/libexec/rlogind/rlogind.c > ============================================================================== > --- head/libexec/rlogind/rlogind.c Fri Feb 26 19:49:04 2016 (r296108) > +++ head/libexec/rlogind/rlogind.c Fri Feb 26 20:02:01 2016 (r296109) > @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -350,34 +351,27 @@ protocol(int f, int p) > nfd = f + 1; > else > nfd = p + 1; > - if (nfd > FD_SETSIZE) { > - syslog(LOG_ERR, "select mask too small, increase FD_SETSIZE"); > - fatal(f, "internal error (select mask too small)", 0); > - } > for (;;) { > - fd_set ibits, obits, ebits, *omask; > + struct pollfd set[2]; > - FD_ZERO(&ebits); > - FD_ZERO(&ibits); > - FD_ZERO(&obits); > - omask = (fd_set *)NULL; > - if (fcc) { > - FD_SET(p, &obits); > - omask = &obits; > - } else > - FD_SET(f, &ibits); > + set[0].fd = p; > + set[0].events = POLLPRI; > + set[1].fd = f; > + set[1].events = 0; > + if (fcc) > + set[0].events |= POLLOUT; > + else > + set[1].events |= POLLIN; > if (pcc >= 0) { > - if (pcc) { > - FD_SET(f, &obits); > - omask = &obits; > - } else > - FD_SET(p, &ibits); > + if (pcc) > + set[1].events |= POLLOUT; > + else > + set[0].events |= POLLIN; > } > - FD_SET(p, &ebits); > - if ((n = select(nfd, &ibits, omask, &ebits, 0)) < 0) { > + if ((n = poll(set, 2, INFTIM)) < 0) { > if (errno == EINTR) > continue; > - fatal(f, "select", 1); > + fatal(f, "poll", 1); > } > if (n == 0) { > /* shouldn't happen... */ > @@ -385,18 +379,16 @@ protocol(int f, int p) > continue; > } > #define pkcontrol(c) ((c)&(TIOCPKT_FLUSHWRITE|TIOCPKT_NOSTOP|TIOCPKT_DOSTOP)) > - if (FD_ISSET(p, &ebits)) { > + if (set[0].revents & POLLPRI) { > cc = read(p, &cntl, 1); > if (cc == 1 && pkcontrol(cntl)) { > cntl |= oobdata[0]; > send(f, &cntl, 1, MSG_OOB); > - if (cntl & TIOCPKT_FLUSHWRITE) { > + if (cntl & TIOCPKT_FLUSHWRITE) > pcc = 0; > - FD_CLR(p, &ibits); > - } > } > } > - if (FD_ISSET(f, &ibits)) { > + if (set[1].revents & POLLIN) { > fcc = read(f, fibuf, sizeof(fibuf)); > if (fcc < 0 && errno == EWOULDBLOCK) > fcc = 0; > @@ -422,11 +414,10 @@ protocol(int f, int p) > goto top; /* n^2 */ > } > } > - FD_SET(p, &obits); /* try write */ > } > } > - if (FD_ISSET(p, &obits) && fcc > 0) { > + if (set[0].revents & POLLOUT && fcc > 0) { > cc = write(p, fbp, fcc); > if (cc > 0) { > fcc -= cc; > @@ -434,7 +425,7 @@ protocol(int f, int p) > } > } > - if (FD_ISSET(p, &ibits)) { > + if (set[0].revents & POLLIN) { > pcc = read(p, pibuf, sizeof (pibuf)); > pbp = pibuf; > if (pcc < 0 && errno == EWOULDBLOCK) > @@ -443,7 +434,6 @@ protocol(int f, int p) > break; > else if (pibuf[0] == 0) { > pbp++, pcc--; > - FD_SET(f, &obits); /* try write */ > } else { > if (pkcontrol(pibuf[0])) { > pibuf[0] |= oobdata[0]; > @@ -452,18 +442,8 @@ protocol(int f, int p) > pcc = 0; > } > } > - if ((FD_ISSET(f, &obits)) && pcc > 0) { > + if (set[1].revents & POLLOUT && pcc > 0) { > cc = write(f, pbp, pcc); > - if (cc < 0 && errno == EWOULDBLOCK) { > - /* > - * This happens when we try write after read > - * from p, but some old kernels balk at large > - * writes even when select returns true. > - */ > - if (!FD_ISSET(p, &ibits)) > - sleep(5); > - continue; > - } > if (cc > 0) { > pcc -= cc; > pbp += cc; > _______________________________________________ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"