From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 12 18:15:46 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 138CB106568F; Mon, 12 Oct 2009 18:15:46 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id E2A658FC0C; Mon, 12 Oct 2009 18:15:45 +0000 (UTC) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id 5217F46B03; Mon, 12 Oct 2009 14:15:45 -0400 (EDT) Date: Mon, 12 Oct 2009 19:15:45 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Ivan Voras In-Reply-To: <9bbcef730910121028q7185cb47sd5780fbb0b8f59ad@mail.gmail.com> Message-ID: References: <20091012152248.GJ79298@elvis.mu.org> <9bbcef730910121028q7185cb47sd5780fbb0b8f59ad@mail.gmail.com> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-hackers@freebsd.org, Alfred Perlstein Subject: Re: "global" TCP_NODELAY? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Oct 2009 18:15:46 -0000 On Mon, 12 Oct 2009, Ivan Voras wrote: > 2009/10/12 Alfred Perlstein : >> * Ivan Voras [091012 04:29] wrote: >>> I'm trying to work around some extreme brain damageness in PHP (yes, it >>> sucks) which doesn't have a way to set TCP_NODELAY on stream sockets so >>> I'm wondering what are my other options? Is there a way to set TCP_NODELAY >>> system-wide? >> >> Ivan, many people write php extensions, maybe you can do that? > > While writing PHP extensions isn't hard (I've done it before), I'm not yet > convinced it's worth the effort in this case - I don't know if TCP_NODELAY > will help at all. I'll think about it if time permits. Create a libc wrapper that calls setsockopt(2) whenever socket(2) is called to create a TCP socket in php, and inject it using LD_PRELOAD. This is a similar trick to what things like socks proxy library wrappers use, is easy to hack together, and avoids having to modify the kernel. When it doesn't work, move on, and if it does, change php :-). Robert N M Watson Computer Laboratory University of Cambridge