From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 8 22:59:54 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C990ACAF for ; Wed, 8 Jan 2014 22:59:54 +0000 (UTC) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8EA211A32 for ; Wed, 8 Jan 2014 22:59:54 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 5F1DE3592E2 for ; Wed, 8 Jan 2014 23:59:52 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 17D6528497; Wed, 8 Jan 2014 23:59:52 +0100 (CET) Date: Wed, 8 Jan 2014 23:59:52 +0100 From: Jilles Tjoelker To: freebsd-hackers@freebsd.org Subject: [patch] libc/resolv: use poll() instead of kqueue() Message-ID: <20140108225951.GB87058@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jan 2014 22:59:54 -0000 The resolver in libc creates a kqueue for watching a single file descriptor. This can be done using poll() which should be lighter on the kernel and reduce possible problems with rlimits (file descriptors, kqueues). Index: lib/libc/include/port_before.h =================================================================== --- lib/libc/include/port_before.h (revision 260048) +++ lib/libc/include/port_before.h (working copy) @@ -5,7 +5,7 @@ #define _LIBC 1 #define DO_PTHREADS 1 -#define USE_KQUEUE 1 +#define USE_POLL 1 #define ISC_SOCKLEN_T socklen_t #define ISC_FORMAT_PRINTF(fmt, args) \ Index: lib/libc/resolv/res_send.c =================================================================== --- lib/libc/resolv/res_send.c (revision 260048) +++ lib/libc/resolv/res_send.c (working copy) @@ -77,7 +77,7 @@ __FBSDID("$FreeBSD$"); */ #include "port_before.h" -#ifndef USE_KQUEUE +#if !defined(USE_KQUEUE) && !defined(USE_POLL) #include "fd_setsize.h" #endif @@ -963,7 +963,7 @@ send_dg(res_state statp, timeout.tv_nsec/1000000; pollfd.fd = s; pollfd.events = POLLRDNORM; - n = poll(&pollfd, 1, polltimeout); + n = _poll(&pollfd, 1, polltimeout); #endif /* USE_POLL */ if (n == 0) {