Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 46839 invoked from network); 8 Feb 2007 11:03:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Feb 2007 11:03:49 -0000 Received: (qmail 41456 invoked by uid 500); 8 Feb 2007 11:03:55 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 41242 invoked by uid 500); 8 Feb 2007 11:03:55 -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 41233 invoked by uid 99); 8 Feb 2007 11:03:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Feb 2007 03:03:55 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=MSGID_FROM_MTA_HEADER,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of laronfin@hotmail.com designates 65.54.246.211 as permitted sender) Received: from [65.54.246.211] (HELO bay0-omc3-s11.bay0.hotmail.com) (65.54.246.211) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Feb 2007 03:03:43 -0800 Received: from hotmail.com ([65.55.139.98]) by bay0-omc3-s11.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Thu, 8 Feb 2007 03:03:22 -0800 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 8 Feb 2007 03:03:22 -0800 Message-ID: Received: from 65.55.139.123 by by134fd.bay134.hotmail.msn.com with HTTP; Thu, 08 Feb 2007 11:03:18 GMT X-Originating-IP: [192.100.124.219] X-Originating-Email: [laronfin@hotmail.com] X-Sender: laronfin@hotmail.com In-Reply-To: <5280fae50702071319o5af0d484j5e3873d076882695@mail.gmail.com> From: =?gb2312?B?1cUg1emyqQ==?= To: modules-dev@httpd.apache.org Subject: RE: Whitescreens when using a dir-conf merge function Date: Thu, 08 Feb 2007 11:03:18 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=gb2312; format=flowed X-OriginalArrivalTime: 08 Feb 2007 11:03:22.0634 (UTC) FILETIME=[BF9A76A0:01C74B70] X-Virus-Checked: Checked by ClamAV on apache.org Hi, I have gone through your code quickly. It seems there is some problem in your merge function: > rbl_handler* from_rbl_handler; > rbl_handler* to_rbl_handler; here you haven't pcalloc the memory for it. However late you pass these pointers to the function: >static void apr_copy_rbhlcpy(apr_pool_t* p, rbl_handler* >from_rbl_handler, >rbl_handler* to_rbl_handler) In this function you use pointer to accept parmaters. Should you use double pointer?(e.g.rbl_handler* from_rbl_handler). My suggestion is that you allocate the memory in your merge function and then in apr_copy_rbhlcpy try to use double pointer. I am not so sure whether it is the reason. but you can have a try. br frankie >From: "David Wortham" >Reply-To: modules-dev@httpd.apache.org >To: modules-dev@httpd.apache.org >Subject: Whitescreens when using a dir-conf merge function >Date: Wed, 7 Feb 2007 14:19:26 -0700 > >Hi all, > I'm adding a merge function (for use with directory-based >configuration >and server-based configuration). > >When I finished the function, I noticed that it was causing >whitescreens >(empty responses). > >As you can see below, I allocate memory via 'apr_pcalloc' and then >I: >(1) loop through each existing 'rbl_handler' from the parentdir_cfg, >copying >it to the new_dir_cfg, then >(2) loop through each existing 'rbl_handler' from the subdir_cfg, >copying it >to the new_dir_cfg. > >With my current directive configuration, there are no directives to >copy (so >the loops fail the first conditional and are never entered), but >Apache >whitescreens nonetheless. There are no errors or warnings on >compile. > >Am I allocating memory correctly, or perhaps my concept of merging >(and when >the merge function is called) is bad? > > > >The relevant code follows: > >/* start code snippet */ > >// since memcpy was causing errors, I coded this function to do the >same >(only much slower) >static void apr_copy_rbhlcpy(apr_pool_t* p, rbl_handler* >from_rbl_handler, >rbl_handler* to_rbl_handler) >{ > if (from_rbl_handler) > { > to_rbl_handler->category_bs = >from_rbl_handler->category_bs; > to_rbl_handler->score_lb = >from_rbl_handler->score_lb; > to_rbl_handler->score_ub = >from_rbl_handler->score_ub; > to_rbl_handler->days_lb = from_rbl_handler->days_lb; > to_rbl_handler->days_ub = from_rbl_handler->days_ub; > to_rbl_handler->verb_bs = from_rbl_handler->verb_bs; > to_rbl_handler->action_string = >(from_rbl_handler->action_string)?apr_pstrdup(p, >from_rbl_handler->action_string):NULL; > } >} > >// the merge function >static void* my_merge_dir_conf (apr_pool_t* p, void* parent_dirv, >void* >subdirv) >{ > httpbl_dir_cfg* parent_dir = (httpbl_dir_cfg *) >parent_dirv; > httpbl_dir_cfg* subdir = (httpbl_dir_cfg *) >subdirv; > httpbl_dir_cfg* new_dir_cfg = (httpbl_dir_cfg *) >apr_palloc >(p, sizeof(httpbl_dir_cfg)); > > int i = 0; // i = the >num_of_rbl_handlers already written in the new_dir_cfg array > int j = 0; // j = the >num_of_rbl_handlers read from from_rbl_handler > new_dir_cfg->default_action = >subdir->default_action; > new_dir_cfg->is_404_recording_enabled = >subdir->is_404_recording_enabled; > new_dir_cfg->is_exempt = subdir->is_exempt; > new_dir_cfg->is_httpbl_enabled = >subdir->is_httpbl_enabled; > new_dir_cfg->something = >(subdir->something)?apr_pstrdup(p, subdir->something):NULL; > new_dir_cfg->the_rbl_handlers = (rbl_handler >**)apr_pcalloc( >p, (MAX_RBL_DIRECTIVES)*sizeof(rbl_handler*) ); > new_dir_cfg->num_of_rbl_handlers = 0; > > rbl_handler* from_rbl_handler; > rbl_handler* to_rbl_handler; > // fill in rbl directives starting with the parent, then the >child >(returning an error string if more than MAX_RBL_DIRECTIVES >rbl_handlers are >created/attempted > for (i = 0; i < parent_dir->num_of_rbl_handlers && >new_dir_cfg->num_of_rbl_handlers <= MAX_RBL_DIRECTIVES; i++) > { > from_rbl_handler = parent_dir->the_rbl_handlers[i]; > to_rbl_handler = new_dir_cfg->the_rbl_handlers[i]; > > if (from_rbl_handler) > { > apr_copy_rbhlcpy(p, from_rbl_handler, to_rbl_handler); >// memcpy(to_rbl_handler, from_rbl_handler, >sizeof(rbl_handler)); >// try a direct memory copy > (new_dir_cfg->num_of_rbl_handlers)++; > } > } > for (j = 0; j < subdir->num_of_rbl_handlers && >new_dir_cfg->num_of_rbl_handlers < MAX_RBL_DIRECTIVES; j++) > { > from_rbl_handler = subdir->the_rbl_handlers[j]; > to_rbl_handler = new_dir_cfg->the_rbl_handlers[i]; > > if (from_rbl_handler) > { > apr_copy_rbhlcpy(p, from_rbl_handler, to_rbl_handler); >// memcpy(to_rbl_handler, from_rbl_handler, >sizeof(rbl_handler)); >// try a direct memory copy > (new_dir_cfg->num_of_rbl_handlers)++; > i++; > } > } > > return new_dir_cfg; >} > > >/* end code snippet */ > >Dave _________________________________________________________________ �����������ѽ��н�������ʹ�� Live Messenger; http://get.live.com/messenger/overview