Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46449 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70897 invoked from network); 16 Dec 2009 16:30:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Dec 2009 16:30:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=jerome@loyet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=jerome@loyet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain loyet.net from 209.85.223.195 cause and error) X-PHP-List-Original-Sender: jerome@loyet.net X-Host-Fingerprint: 209.85.223.195 mail-iw0-f195.google.com Received: from [209.85.223.195] ([209.85.223.195:60216] helo=mail-iw0-f195.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 96/FF-13001-90B092B4 for ; Wed, 16 Dec 2009 11:30:02 -0500 Received: by iwn33 with SMTP id 33so801413iwn.29 for ; Wed, 16 Dec 2009 08:29:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.158.205 with SMTP id g13mr17231ibx.30.1260980999543; Wed, 16 Dec 2009 08:29:59 -0800 (PST) In-Reply-To: <4B29029D.5080806@daylessday.org> References: <3bea96c40912160733s20a6bb3bpab6919536ab86bc9@mail.gmail.com> <4B29029D.5080806@daylessday.org> Date: Wed, 16 Dec 2009 17:29:59 +0100 Message-ID: <3bea96c40912160829w3f30f7f2v8bc39c70b17f1e47@mail.gmail.com> To: Antony Dovgal Cc: php-dev Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH] bug: some event from parent might be triggered by children From: jerome@loyet.net (=?ISO-8859-1?B?Suly9G1lIExveWV0?=) Le 16 d=E9cembre 2009 16:54, Antony Dovgal a =E9crit = : > On 16.12.2009 18:33, J=E9r=F4me Loyet wrote: >> hi tony, >> >> this patch correct a behaviour that could happened randomly, depending >> on the event lib used (epoll, poll, kqueue, ...). There is some case >> in which an event created by the parent process can be triggered in a >> child. > > Some case? I had this bug several time doing differents stuff. So I don't have a real case to explain here (I can search). > Could you elaborate? It's related to the missing event_init after forking a child. In fpm_children_make(), we have: fork() event_init() /* to reinit libevent, necessary for epoll */ if (in_event_loop) event_loop_break(); I think the bug appears when event_init has been added recently. As event_init reinitiated the libevent environment, the event_loop_break() call has no more effect as it refers to a new environment. So the main loop is still running and event can be triggered by both parent and children. The solution is to move the event_init just after the call. Moreover, I think the previous patch (which add verification on fpm_globals.child) should be included also as it secure the application, just in case :) ++ Jerome Index: sapi/fpm/fpm/fpm_children.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sapi/fpm/fpm/fpm_children.c (r=E9vision 292214) +++ sapi/fpm/fpm/fpm_children.c (copie de travail) @@ -373,12 +373,12 @@ switch (pid) { case 0 : - event_init(); /* reopen epoll descriptor */ fpm_child_resources_use(child); fpm_globals.is_child =3D 1; if (in_event_loop) { fpm_event_exit_loop(); } + event_init(); /* refresh libevent environme= nt */ fpm_child_init(wp); return 0; > > The patch certainly does no harm, but maybe it's worth investigating why = parent events are triggered in child processes? > > -- > Wbr, > Antony Dovgal > --- > http://pinba.org - realtime statistics for PHP >