Date: Tue, 24 May 2005 13:36:48 -0400 From: Ed Maste <emaste@phaedrus.sandvine.ca> To: freebsd-stable@freebsd.org Subject: Re: libc_r kqueue fd leak Message-ID: <20050524173648.GA29183@sandvine.com> In-Reply-To: <20050524165907.GA20674@sandvine.com> References: <20050524165907.GA20674@sandvine.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--qcHopEYAB45HaUaB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, May 24, 2005 at 12:59:07PM -0400, Ed Maste wrote: > We discovered a kqueue leak when running one of our 4.x applications on > FreeBSD 5.3 using the compat libc_r. It turns out it's caused by libc_r's > close() failing. I've attached a patch which stops libc_r close() from bailing if fstat() returns an error. This fixes the kqueue leak. This logic would also have to make its way into the compat library via 4.x to fully resolve the issue. -- Ed Maste, Sandvine Incorporated --qcHopEYAB45HaUaB Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="uthread_close.c.patch" --- uthread_close.c.orig 2005-05-24 13:22:14.000000000 -0400 +++ uthread_close.c 2005-05-24 13:21:05.000000000 -0400 @@ -63,8 +63,7 @@ * Lock the file descriptor while the file is closed and get * the file descriptor status: */ - else if (((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) && - ((ret = __sys_fstat(fd, &sb)) == 0)) { + else if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { /* * Check if the file should be left as blocking. * @@ -85,7 +84,8 @@ * using, which would then cause any reads to block * indefinitely. */ - if ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) + if (__sys_fstat(fd, &sb) == 0 && + (S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && (_thread_fd_getflags(fd) & O_NONBLOCK) == 0) { /* Get the current flags: */ flags = __sys_fcntl(fd, F_GETFL, NULL); --qcHopEYAB45HaUaB--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050524173648.GA29183>