From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jos Backus Newsgroups: gmane.comp.lang.ruby.mongrel.devel Subject: Re: Mongrel doesn't set close-on-exec on its listen socket Date: Tue, 4 Nov 2008 12:41:59 -0800 Message-ID: <20081104204159.GA48584@lizzy.catnook.local> References: <20080722163104.GA82787@lizzy.catnook.local> <20080818215844.GA1441@yp-box.dyndns.org> <20080819030844.GA53303@lizzy.catnook.local> <20080820082737.GA2403@yp-box.dyndns.org> Reply-To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1225831779 11495 80.91.229.12 (4 Nov 2008 20:49:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Nov 2008 20:49:39 +0000 (UTC) To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Original-X-From: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Tue Nov 04 21:50:42 2008 Return-path: Envelope-to: gclrmd-mongrel-development@m.gmane.org X-Greylist: delayed 393 seconds by postgrey-1.31 at rubycentral.org; Tue, 04 Nov 2008 15:48:17 EST Content-Disposition: inline In-Reply-To: <20080820082737.GA2403-G9TX8C5UF5wdbCeoMzGj59i2O/JbrIOy@public.gmane.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-BeenThere: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.mongrel.devel:66 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1KxSrD-0001mN-I8 for gclrmd-mongrel-development@m.gmane.org; Tue, 04 Nov 2008 21:50:35 +0100 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 19A3E16780E0; Tue, 4 Nov 2008 15:49:26 -0500 (EST) Received: from lizzy.dyndns.org (209-204-188-132.dsl.static.sonic.net [209.204.188.132]) by rubyforge.org (Postfix) with SMTP id B465D16780E0 for ; Tue, 4 Nov 2008 15:48:17 -0500 (EST) Received: (qmail 48728 invoked by uid 1000); 4 Nov 2008 20:41:59 -0000 List-Post: On Wed, Aug 20, 2008 at 01:27:37AM -0700, Eric Wong wrote: > Jos Backus wrote: > > On Mon, Aug 18, 2008 at 02:59:21PM -0700, Eric Wong wrote: > > > This probably works: > > > > > > diff --git a/lib/mongrel.rb b/lib/mongrel.rb > > > index 8b5dfe2..027bfdb 100644 > > > --- a/lib/mongrel.rb > > > +++ b/lib/mongrel.rb > > > @@ -91,6 +91,9 @@ module Mongrel > > > > > > tries = 0 > > > @socket = TCPServer.new(host, port) > > > + if defined?(Fcntl::FD_CLOEXEC) > > > + @socket.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) > > > + end > > > > > > @classifier = URIClassifier.new > > > @host = host > > > > Looks reasonable to me. Thanks, Eric. Can somebody commit, please? > > I've just committed it, r1036 to trunk. Thanks for the report! Thanks Eric. The patch is probably incomplete, as I just noticed a problem: /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:94:in `initialize': uninitialized constant Mongrel::HttpServer::Fcntl (NameError) That code doesn't have the defined? test. But even if it did, it wouldn't work as `fcntl' hadn't been require'd so the Fcntl::FD_CLOEXEC constant couldn't be available until it was (if it was available). So the right thing to do is to also apply this patch which explicitly require's `fcntl': --- mongrel.rb- 2008-11-04 15:39:01.000000000 -0500 +++ mongrel.rb 2008-11-04 15:26:38.000000000 -0500 @@ -7,6 +7,7 @@ require 'etc' require 'uri' require 'stringio' +require 'fcntl' # Compiled Mongrel extension require 'http11' -- Jos Backus jos at catnook.com