Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: (qmail 42575 invoked from network); 21 Apr 2010 14:29:08 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 Apr 2010 14:29:08 -0000 Received: (qmail 6691 invoked by uid 500); 21 Apr 2010 14:29:07 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 6660 invoked by uid 500); 21 Apr 2010 14:29:07 -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 6652 invoked by uid 99); 21 Apr 2010 14:29:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Apr 2010 14:29:07 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [206.190.38.101] (HELO web50703.mail.re2.yahoo.com) (206.190.38.101) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 21 Apr 2010 14:28:58 +0000 Received: (qmail 505 invoked by uid 60001); 21 Apr 2010 14:28:37 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1271860117; bh=c6X2Y58DUUI/gc9EhoaJasfXCgOAgxeDv9d9HJIRpxU=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=1ff5gdSHwRkTIoAEtiiLWCTou8fGERFmlQQT9nJt6ACMWRKNFde25jpyrEldubiJjduOBsCIvar9FSuxDif2w+pFBrqVdOQ1f/gFZMF9OYds5Be026VfY6fM7pQxLFbE9DwDGo+QpzmIjJJ8uG7X5+1e2Z18BpADZxpivGJ/Ldk= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=3pLiVxqQY3vJUca/xZ6UJEmCwQPoUs7J4ZzghsAGJYxujuEidY4L/B9Yms0cYe6ibXBQHqO/c/C6QEpPfXDCLOs9USZEMpU64h9+OfCghv9FVQ/BMZO+iAUSNyyQXO36rdHcHsqbAHM2N0O8PR6DHRgI7SAPzKGYu0wikhC3rpk=; Message-ID: <131372.99463.qm@web50703.mail.re2.yahoo.com> X-YMail-OSG: zZz5yaQVM1lRBfhIRBpgab9fh8nCRoNuDnmVZf0y64NQAS0 3fK57X5_h5rBJym0XorNvS0m9HCQZe7HAAl8XD04t.vvSLSp.x3y8kke_fzW KoIgKBOwICXEGxnqRqyA94jUC.RGZiij3KDEgq5qVNQLV2Ge7_jPjfiGL5bg BhPid_oyx_k5FzuKO1uLBDTg1EPiYgJrQ3pdpOB8wcL8YVdV3HrL0x6heSEI x.HAY.frgHjhTd2E_ImYCfivv8uH..TXu4W002yEx.783yKJMl.h_67iYgbC E5pYCuqh4HewGx_L449IR3.tDGsSri0vSQoxG1r1sA4UsesA907OS97K4CuK nDckN6pad8dfzX6QDO3YEKzXsipw- Received: from [194.237.142.7] by web50703.mail.re2.yahoo.com via HTTP; Wed, 21 Apr 2010 07:28:36 PDT X-Mailer: YahooMailRC/348.5 YahooMailWebService/0.8.102.267879 References: <120632.3523.qm@web50704.mail.re2.yahoo.com> <377280.88925.qm@web50703.mail.re2.yahoo.com> <45730.82430.qm@web50706.mail.re2.yahoo.com> <769008.31452.qm@web50705.mail.re2.yahoo.com> <303850.41306.qm@web50708.mail.re2.yahoo.com> Date: Wed, 21 Apr 2010 07:28:36 -0700 (PDT) From: alin vasile Subject: Re: Process lifetime and hooks to use To: modules-dev@httpd.apache.org In-Reply-To: <303850.41306.qm@web50708.mail.re2.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-385057457-1271860116=:99463" X-Virus-Checked: Checked by ClamAV on apache.org --0-385057457-1271860116=:99463 Content-Type: text/plain; charset=us-ascii Also this is how I configured the structure in the post_config handler: sample_config.sample_time = 60; sample_config.sample_log_file_name = "/home/alin/webserver_node1/logs/sampler.log"; apr_file_open(&sample_config.sample_log_file_handler, sample_config.sample_log_file_name, REWRITELOG_FLAGS, REWRITELOG_MODE, p); ________________________________ From: alin vasile To: modules-dev@httpd.apache.org Sent: Wed, April 21, 2010 5:22:32 PM Subject: Re: Process lifetime and hooks to use you can access the config in the child process too, but not in the monitor hook. Below is a sample of global variables with the monitor hook: typedef struct data_config_t { const char *sample_log_file_name; apr_file_t *sample_log_file_handler; int sample_time; } data_config_t; static data_config_t sample_config; static int process_sampler (apr_pool_t* p) { // do some work // note that you have access to the sample_config variable return OK; } //in the register_hooks handler put : ap_hook_monitor(process_sampler, NULL, NULL, APR_HOOK_LAST); ________________________________ From: Some Guy To: modules-dev@httpd.apache.org Sent: Wed, April 21, 2010 5:02:11 PM Subject: Re: Process lifetime and hooks to use Alin, Thank you for your time, patience, and help. I guess I'm still a little confused on the mechanism used to move the data from the configuration to a place that the monitor hook could use. I can only access the config in the parent process via the post_config hook (or am I wrong?). If that's the case, then I need to store the variables in some static global field. However, the data that the post config hook gives me might come from a pool that gets cleaned, so I need a way to make sure the global fields aren't dangling. That's why I was considering making my own independent pool and duplicating the variables so I can store it into global variables without worrying about their lifetime. Their life would be based on the independent global pool that I create in the post config hook / monitor hook (whichever comes first). SB On Wed, Apr 21, 2010 at 9:25 AM, alin vasile wrote: > you can use the memory pool passed to the monitor, but that pool never gets > cleaned, so you'll have to make sure that there are no memory leaks. > the docs don't say anything if the monitor hook runs after post_config... > > > > > ________________________________ > From: Some Guy > To: modules-dev@httpd.apache.org > Sent: Wed, April 21, 2010 3:37:47 PM > Subject: Re: Process lifetime and hooks to use > > I need to get it from the configuration file. If the post config hook runs > prior to the ap monitor hook, then that would work. But what memory is all > of that data allocated from? I don't want them disappearing on me. > > On Wed, Apr 21, 2010 at 4:22 AM, alin vasile >wrote: > > > why don't you create global variables and put there the configuration > data? > > > > > > > > > > ________________________________ > > From: Some Guy > > To: modules-dev@httpd.apache.org > > Sent: Wed, April 21, 2010 1:44:06 AM > > Subject: Re: Process lifetime and hooks to use > > > > Thanks for your comments. Is a possible solution to the configuration > > problem to keep a global reference to a pool that I create (w/o a > parent)? > > I can then use that pool to duplicate some of the string data I need from > > the configuration and store those in my globals as well. > > > > I'll need to think of a way to document the code so people know what the > > heck I'm doing too. People who aren't familiar with apache modules are > > going to think I'm on crack. > > > > SB > > > > On Mon, Apr 19, 2010 at 5:00 PM, alin vasile > >wrote: > > > > > > > > > > > comments inline > > > > > > > > > > > > > > > ________________________________ > > > From: Some Guy > > > To: modules-dev@httpd.apache.org > > > Sent: Mon, April 19, 2010 3:04:02 PM > > > Subject: Re: Process lifetime and hooks to use > > > > > > I think my understanding of the monitor hook is fine. I can just use > the > > > passed in pool as my context and use the userdata_set/get APIs as I > > > periodically fetch / update a file. > > > >>[alin vasile] the pool is used to allocate the memory from. You'll > need > > > global variables to store the pointers. See Nick.s response > > > > > > What I'll need to play with is to see > > > how I can set this up as a configuration parameter. If the post_config > > > hook > > > gets called in the parent process with the apr_pool_t* passed in also > > being > > > the same one that monitor gets, then that would work. > > > >> [alin vasile] I'm not sure of that. > > > > > > The child hooks I think are the issue when dealing with the various > MPMs, > > > but it might not be a problem anymore since I can just use the pool > > passed > > > into child_init as the store for my lock and cache. Is the same pool > > > passed > > > in child_init accessible in the request handler via > > > request->server->process->pool ? > > > > > > I see a lot of modules using these static variables and globals all > over > > - > > > is this safe? Aren't the modules existing in multiple process spaces? > > How > > > does the author know which static variables are going to be safe to > > access > > > in each hook? I guess any statics assigned in the child_init are safe > to > > > use in the request handlers and other threads spawned in the > child_init. > > > And for the parent process it's probably best to just use the pool? > > > >> [alin vasile] You can't init static variables in child_init. don't > > > declare them static and, if needed, protect their read/write with locks > > > > > > Thanks, > > > > > > SB > > > > > > On Mon, Apr 19, 2010 at 1:41 AM, alin vasile > > >wrote: > > > > > > > It depends what you want to do in this hook. > > > > > > > > --- On Sun, 4/18/10, Some Guy wrote: > > > > > > > > From: Some Guy > > > > Subject: Re: Process lifetime and hooks to use > > > > To: modules-dev@httpd.apache.org > > > > Date: Sunday, April 18, 2010, 5:51 PM > > > > > > > > Ah great. I know what I should do with that. Any insight on the > > > > differences in MPMs and what to watch out for? > > > > > > > > On Sun, Apr 18, 2010 at 12:22 PM, William A. Rowe Jr. > > > > wrote: > > > > > > > > > On 4/18/2010 2:34 AM, alin vasile wrote: > > > > > > the monitor hook gets only a pointer to an apr_pool_t structure. > > > > > > > > > > Take a look at apr_pool_data_* API's, that should provide you all > of > > > the > > > > > context and persistence you need. > > > > > > > > > > You will never see anything about servers, connections or requests > > > > because > > > > > this is running in the *parent*, it is blissfully unaware of > specific > > > > > requests > > > > > and is therefore immune from being hijaaked by remote code > execution > > > and > > > > > less > > > > > severe but destabilizing attacks on the request processing code > > itself. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --0-385057457-1271860116=:99463--