Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 73266 invoked from network); 15 Oct 2007 19:49:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Oct 2007 19:49:36 -0000 Received: (qmail 95893 invoked by uid 500); 15 Oct 2007 19:49:23 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 95866 invoked by uid 500); 15 Oct 2007 19:49:23 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 95857 invoked by uid 99); 15 Oct 2007 19:49:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Oct 2007 12:49:23 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [209.73.178.138] (HELO web60315.mail.yahoo.com) (209.73.178.138) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 15 Oct 2007 19:49:24 +0000 Received: (qmail 11998 invoked by uid 60001); 15 Oct 2007 19:49:02 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=feaNoR9RlWnXComLee2phk+272C3lHjyjLjBLQAFjetvj11dJQswCEhbw3Dl/gpEL/WWCdsu/0L5WhMhnx7oKBRc+OoBRR4IKEIajAo8qbEYCuvFAT31qzz/q3igma0kduRObC0xsll2j5Fpi80Vvrx383Cqdt/hcHzxtGck/sw=; X-YMail-OSG: DIFBkY0VM1ll1YsrTsaMtgBfNkf5FqeWtEtoZ8jav9pMgpVyOtKlnZBAGtR6zwcmgA-- Received: from [89.40.131.46] by web60315.mail.yahoo.com via HTTP; Mon, 15 Oct 2007 12:49:01 PDT X-Mailer: YahooMailRC/814.05 YahooMailWebService/0.7.134.12 Date: Mon, 15 Oct 2007 12:49:01 -0700 (PDT) From: Marin Cosmin Subject: Re: [Unload module] To: modules-dev@httpd.apache.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-ID: <812162.9999.qm@web60315.mail.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org Thank you very much for your promptness.=0A=0AI've tested and segfaults if = I unload the module. In order to resolve this problem I use a flag which is= true if everything went fine, and false if didn't, but I thought that you = can unload the module if something goes wrong.=0A=0AI'm using "post_config= " to initialize some structures some of them=0Abased on the configuration r= ead form httpd.conf . Here is the place=0Awhere I get some shared memory, a= nd mutex. In the same hook I=0Aused apr_pool_cleanup_register but doesn't = work. After apache exits "ipcs" command shows my shm & mutex. ipcrm helps t= o clear IPCs. =0A=0A=0AIndeed all IPC used by children, after exit are free= d (due to apr_pool_cleanup_register), but the main process, the parent of t= hese children doesn't de-allocates & destroies the shm segment for example.= The children only detach the sahred memory, but the main process should de= stroy it. This segment is created by main httpd process at startup and used= by all other httpd's children.=0A=0ASorry if I'm not very clear ...=0A=0AM= y problem is that I don't know how to make the main httpd process, which ru= ns as root, to dealocate some IPC at exit, that were created at its startu= p.=0A=0AThank you again.=0A=0AHave I nice day!=0A=0A----- Original Message = ----=0AFrom: Joe Lewis =0ATo: modules-dev@httpd.apache.o= rg=0ASent: Monday, October 15, 2007 9:04:35 PM=0ASubject: Re: [Unload modul= e]=0A=0A=0AMarin Cosmin wrote:=0A> Hello,=0A>=0A> I'm working on an Apache = module that will log some statistics in a=0A file.=0A> My problem is that I= have no ideea about what should I do to unload=0A the module.=0A> In ap_ho= ok_post_config hook I initialize some structures, use open()=0A for some fi= les ...=0A> If I get an error during this phase how can I unload the module= ?=0A>=0A> =0A=0AI'm not sure that unloading the module is a good idea. I= 'd suggest=0A using=0Aone of the *open_logs or *post_config hooks - and ret= urn an appropriate=0Aerror code if failure occurs. If you find that apache = continues to=0A load,=0Athen you may want to set a flag in a configuration = structure that you=0Acan use to determine if you had success earlier. (For = example, so that=0Ayou don't try to write statistics to a file that failed = to open=0A earlier).=0A=0A> Where should I destroy IPCS ? =0A> I used apr_p= ool_cleanup_register here but the behaviuor isn't the=0A desired one.=0A>= =0A> Using apr_pool_cleanup_register in ap_hook_child_init seems to work.= =0A> =0A=0AThat is where you want it - when the child starts, each child = needs to=0Abe able to clean up after itself, hence wait until the child sta= rts to=0Aregister that one.=0A=0AThis is a bit more clear when comparing wo= rker vs. prefork MPM's - each=0Achild process has to take care of it's own = in order to prevent memory=0Aleaks, etc.=0A=0AJoe=0A-- =0AJoseph Lewis =0A"Divide the fire, and you will sooner put it out." -= Publius Syrus=0A=0A=0A=0A=0A=0A =0A_________________________________= ___________________________________________________=0ABuilding a website is= a piece of cake. Yahoo! Small Business gives you all the tools to get onli= ne.=0Ahttp://smallbusiness.yahoo.com/webhosting