Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Aug 2003 21:58:46 +0200
From:      Andre Albsmeier <andre.albsmeier@siemens.com>
To:        othermark <atkin901@yahoo.com>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: stable libmilter leaks kqueue descriptors?
Message-ID:  <20030810195846.GA65889@curry.mchp.siemens.de>
In-Reply-To: <slrnbj7ppq.5pb.atkin901@adkinson245.f5net.com>
References:  <slrnbidfm6.11jf.atkin901@adkinson245.f5net.com> <slrnbifq2n.13vk.atkin901@adkinson245.f5net.com> <20030808133657.GA42855@curry.mchp.siemens.de> <slrnbj7ppq.5pb.atkin901@adkinson245.f5net.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 08-Aug-2003 at 18:08:31 +0000, othermark wrote:
> I'm glad I'm not 'seeing' things.  If you have a good enough idea
> of where the leakage is occuring, could you file a PR against -STABLE?
> I'd like to see this fixed soon.  I'm not even sure that the pr I
> referenced is the exact problem, but seems likely.

The PR seems to be the right one for our problem. I have
simply stolen the patch from -current and did the HIDDEN_SYSCALLS
additionally (see below). This might be complete nonsense but
it fixed my problem here. I hope someone commits the real
fix to -STABLE r.s.n. This is what I did:

--- lib/libc_r/Makefile.ORI	Wed Oct 23 08:23:54 2002
+++ lib/libc_r/Makefile	Fri Aug  8 15:38:08 2003
@@ -30,7 +30,7 @@
 	execve.o fchflags.o fchmod.o fchown.o fcntl.o \
 	flock.o fpathconf.o fstat.o fstatfs.o fsync.o getdirentries.o \
 	getlogin.o getpeername.o getsockname.o getsockopt.o ioctl.o \
-	kevent.o listen.o \
+	kevent.o kqueue.o listen.o \
 	msync.o nanosleep.o open.o poll.o read.o readv.o recvfrom.o \
 	recvmsg.o sched_yield.o select.o sendfile.o sendmsg.o sendto.o \
 	setsockopt.o shutdown.o sigaction.o \
--- lib/libc_r/uthread/Makefile.inc.ORI	Wed May 28 10:35:18 2003
+++ lib/libc_r/uthread/Makefile.inc	Fri Aug  8 14:23:16 2003
@@ -71,6 +71,7 @@
 	uthread_join.c \
 	uthread_kern.c \
 	uthread_kevent.c \
+	uthread_kqueue.c \
 	uthread_kill.c \
 	uthread_listen.c \
 	uthread_main_np.c \
--- lib/libc_r/uthread/uthread_kqueue.c.ORI	Fri Aug  8 14:23:31 2003
+++ lib/libc_r/uthread/uthread_kqueue.c	Fri Aug  8 15:39:07 2003
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2003 Mark Peek <mp@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <sys/event.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pthread.h>
+#include "pthread_private.h"
+
+__weak_reference(_kqueue, kqueue);
+
+int
+_kqueue(void)
+{
+	int fd;
+
+	/* Create a kqueue: */
+	if ((fd = __sys_kqueue()) < 0) {
+		/* Error creating socket. */
+
+	/* Initialise the entry in the file descriptor table: */
+	} else if (_thread_fd_table_init(fd) != 0) {
+		__sys_close(fd);
+		fd = -1;
+	}
+	return (fd);
+}

	-Andre

> 
> In article <20030808133657.GA42855@curry.mchp.siemens.de>, 
> Andre Albsmeier wrote:
> 
> > I have a self-written milter app. Today I upgraded to the recent
> > -STABLE and now it eats KQUEUE filedscriptors like crazy. I tried
> > to MFC the fix in lib/libc_r/uthread/uthread_kqueue.c but I always
> > get complaints about multiple definition of `_kqueue':
> > 
> > building shared library libc_r.so.4
> > kqueue.So: In function `_kqueue':
> > kqueue.So(.text+0x14): multiple definition of `_kqueue'
> > uthread_kqueue.So(.text+0x0): first defined here
> > *** Error code 1
> > 
> > Seems it conflicts with /usr/obj/lib/libc_r/kqueue.S
> > which is generated everytime from scratch during the build.
> > 
> > I assume that I have to add kqueue.o to HIDDEN_SYSCALLS
> > but I am not sure if this is correct and what it will break :-)
> 
> ---
> Mark
> atkin901 at NOSPAM yahoo dot com
> (!wired)?(coffee++):(wired);
> 
> _______________________________________________
> freebsd-stable@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-stable
> To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"

-- 
Win98: useless extension to a minor patch release for 32-bit extensions and
       a graphical shell for a 16-bit patch to an 8-bit operating system
       originally coded for a 4-bit microprocessor, written by a 2-bit
       company that can't stand for 1 bit of competition.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030810195846.GA65889>