From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Evan Weaver Newsgroups: gmane.comp.lang.ruby.mongrel.devel Subject: Re: [PATCH] always set FD_CLOEXEC on sockets post-accept() Date: Wed, 15 Jul 2009 09:31:53 -0700 Message-ID: References: <20090709095624.GA2805@dcvr.yhbt.net> Reply-To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1247675855 25318 80.91.229.12 (15 Jul 2009 16:37:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 15 Jul 2009 16:37:35 +0000 (UTC) To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Original-X-From: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Wed Jul 15 18:37:27 2009 Return-path: Envelope-to: gclrmd-mongrel-development@m.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:from:date:x-google-sender-auth:message-id:subject:to :content-type:content-transfer-encoding; bh=18HJGgtfVKSvZM2ZydISAirsvq97fM0THwwXzdSuL+s=; b=f712Y9PsN3PkrBQAXQbz6OcZpQZYKlHU8rz44WEvH51cXKKcOJn0aW3Q00TDkS1UBU OHIay+had/srPN3/Y57XZI4b03ECmMMhuICH72xuXrn+GNfOgtxzPGTGqtCkKl2YBezM lWgN5vT61eryrpNIqrrwLT8t0F/bf48uBTFdY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; b=IWQS5bqMU6yheSCqP3bXfZDfylAirgAaz1qnsYD8i321PNh8OSO8eynlhi2RPB/w8D RvnkWrCBAfyj3xTiYr2axmVbNAHZ68Liezdts0lGr7H0hKudRqpLqpYdXUBLog/EJSZV xjDAfM4BtdjQQ9EpO/5t8sH0lQtm7yDhnYkys= In-Reply-To: <20090709095624.GA2805-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org> X-Google-Sender-Auth: 6e1a3d99cb976971 X-BeenThere: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 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:144 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1MR7Tz-0002d7-1G for gclrmd-mongrel-development@m.gmane.org; Wed, 15 Jul 2009 18:37:27 +0200 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id E4E661D780F2; Wed, 15 Jul 2009 12:37:21 -0400 (EDT) Received: from mail-gx0-f225.google.com (mail-gx0-f225.google.com [209.85.217.225]) by rubyforge.org (Postfix) with ESMTP id 644971858125 for ; Wed, 15 Jul 2009 12:37:19 -0400 (EDT) Received: by gxk25 with SMTP id 25so4000737gxk.11 for ; Wed, 15 Jul 2009 09:37:18 -0700 (PDT) Received: by 10.151.40.3 with SMTP id s3mr12995689ybj.111.1247675533046; Wed, 15 Jul 2009 09:32:13 -0700 (PDT) List-Post: Luis, is this one of the commits you already accepted for 1.1.6 and friends? Evan On Thu, Jul 9, 2009 at 2:56 AM, Eric Wong wrote: > FD_CLOEXEC is not guaranteed to be inherited by the accept()-ed > descriptors even if the listener socket has this set. =A0This can > be a problem with applications that fork+exec long running > background processes and our client expects us to close > a connection to signal a completed response: the connection > would only be closed when the background process closed it > (when it exited), not when Mongrel closes the socket. > > This issue was discovered with a server other than Mongrel but > the issue here is applicable to Mongrel as well. > --- > > =A0This patch was based on the below branch > =A0(against c365ba16d12a14bdf1cc50a26f67dd3b45f5a4d8) > > =A0> I used git-svn and added it to > =A0> http://github.com/fauna/mongrel/tree/trunk_from_svn, where it can lie > =A0> unchanged for reference. > > =A0P.S.: I know I used to have a commit bit to the Mongrel SVN but I > =A0never really cared for it since I've always preferred the > =A0mailing-patches-around-for-review form of development. =A0Let me know = if > =A0pushing things to git://git.bogomips.org/mongrel.git for you to > =A0pull is preferable in the future. > > =A0P.P.S: not sure if it's common around here, but I've long had mutt > =A0setup to pipe messages to "git am" directly from the index or pager > =A0and also diff syntax hilighting in the mutt pager. =A0It all makes pat= ch > =A0review/testing *much* nicer without having to context switch out of a > =A0terminal/screen. > > =A0lib/mongrel.rb | =A0 =A06 +++++- > =A01 files changed, 5 insertions(+), 1 deletions(-) > > diff --git a/lib/mongrel.rb b/lib/mongrel.rb > index f09a617..0619abe 100644 > --- a/lib/mongrel.rb > +++ b/lib/mongrel.rb > @@ -278,7 +278,11 @@ module Mongrel > =A0 =A0 =A0 =A0 =A0 =A0 =A0 if defined?($tcp_cork_opts) and $tcp_cork_opts > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 client.setsockopt(*$tcp_cork_opts) rescue= nil > =A0 =A0 =A0 =A0 =A0 =A0 =A0 end > - > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0if defined?(Fcntl::FD_CLOEXEC) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0client.fcntl(Fcntl::F_SETFD, Fcntl::FD_C= LOEXEC) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0end > + > =A0 =A0 =A0 =A0 =A0 =A0 =A0 worker_list =3D @workers.list > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 if worker_list.length >=3D @num_processors > -- > Eric Wong > _______________________________________________ > Mongrel-development mailing list > Mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org > http://rubyforge.org/mailman/listinfo/mongrel-development > -- = Evan Weaver