[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modules
Subject:    RE: [apache-modules] bucket destroy doubt!
From:       "Honnavalli, Jyothi" <jyothi_honnavalli () merck ! com>
Date:       2004-05-13 14:26:44
Message-ID: 2F07B8A0EC85D511B34700508BB22A8208343EF7 () uswsmx24 ! merck ! com
[Download RAW message or body]

Thank you very very much!!

Thanks and Regards,
Jyothishree Honnavalli
Consultant, EWI
Merck & Co. Inc.
jyothi_honnavalli@merck.com


-----Original Message-----
From: howard J meadows [mailto:h_j_meadows@lycos.com] 
Sent: Wednesday, May 12, 2004 5:50 PM
To: apache-modules@covalent.net
Cc: jyothi_honnavalli@merck.com
Subject: RE: [apache-modules] bucket destroy doubt!


Hi Jyothishree,

Just going on what my filter does (working it out from mod_include and
mod_deflate).

apr_brigade_create is what I use to init my filter before the
APR_BRIGADE_FOREACH(e, bb)  loop.

eg.


typedef struct f_context_
{
    apr_bucket_brigade *bb;
} f_context;


static int my_filter(ap_filter_t *f, apr_bucket_brigade *bb)
{
   f_context *ctx = f->ctx;       // The filter context 
   apr_bucket *e;

   if (ctx == NULL) 
   {
      f->ctx = ctx = apr_pcalloc(f->r->pool, sizeof(*ctx));
      ctx->bb = apr_brigade_create(f->r->pool, 
   }

   APR_BRIGADE_FOREACH(e, bb)
   {
      apr_bucket *b;

       // variables used later
      const char* pInBuffer;
      char* pOutBuffer; 
      apr_size_t iInLen;
      int iOutLen;

      // my check for the EOS bucket then looks something like this

      if (APR_BUCKET_IS_EOS(e)) 
      { 
            /* end of stream - get out */
         b = apr_bucket_eos_create(f->c->bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
         APR_BUCKET_REMOVE(e);
         return ap_pass_brigade(f->next,ctx->bb); 
      } 
 
      // I'm not sure if you need this bit      

      if (APR_BUCKET_IS_FLUSH(e))
      {
         b = apr_bucket_flush_create(f->c->bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
         ap_pass_brigade(f->next, ctx->bb);
         continue;
      }

      // You don't need to create a whole new brigade if you 
      // want to edit the contents of a bucket.
      // What I do is call apr_bucket_read to get the data 
      // and ap_fwrite to put it back.

      if (!APR_BUCKET_IS_EOS(e))
      {
         apr_bucket_read(e, &pInBuffer, &iInLen, APR_NONBLOCK_READ);
         my_process((char*)pInBuffer, (int)iInLen, &pOutBuffer, &iOutLen);
	 ap_fwrite(f->next, ctx->bb, pOutBuffer, iOutLen);          
         ap_pass_brigade(f->next,ctx->bb);
         continue;
      }


      // at the end of my filter (outside the  APR_BRIGADE_FOREACH loop)
      // I have apr_brigade_destroy to destroy the original brigade 
      // which I would have now completely replaced with my own.
   }
   apr_brigade_destroy(bb);
   return APR_SUCCESS;	
}


It looks like you are creating multiple bucket brigades for every bucket
pass, filters work by processing all brigades before the current one - hence
the probability of recursion.
If you still have problems it would help if you mentioned what type of
filter you are using (eg.RESOURCE, TRANSCODE, etc)

HTH


Howard


--

--------- Original Message ---------

DATE: Wed, 12 May 2004 15:49:34
From: "Honnavalli, Jyothi" <jyothi_honnavalli@merck.com>
To: "'apache-modules@covalent.net'"
<apache-modules@covalent.net>,"'h_j_meadows@lycos.com'"
<h_j_meadows@lycos.com>
Cc: 

> Hi Howard,
> Thanks for your reply. Here is my print_and_pass_data() function.  I'm
just
> trying to pass each bucket as a  separate brigade to the next filter. Is it
> wrong? Do you know why exactly apr_brigade_create will cause problems ?
What
> if I have to tweak the buckets? I will need to create a temporary brigade
to
> store all the buckets and pass them after I get the EOS bucket? Plz do let
> me know how I can do this. 
> 
> static int print_and_pass_data(char *data){
> apr_bucket *b;
> 	apr_bucket_brigade *mybb;
> 	ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "BUCKET DATA = %s",
> data);
> 	c =  r->connection;
> 	b = apr_bucket_transient_create(data, sizeof(data),
> c->bucket_alloc);
> mybb = apr_brigade_create(r->pool, c->bucket_alloc);
> APR_BRIGADE_INSERT_TAIL(mybb, b);
> 	if (( rv= ap_pass_brigade(fltr,mybb)) != APR_SUCCESS) {
> 		ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "FAILED DATA
> ap_pass_brigade() ");
> 		apr_brigade_destroy(mybb);
> 		return rv;
> 	}
> 
> apr_brigade_destroy(mybb);
> return rv;
> }
> 
> Thanks and Regards,
> Jyothishree Honnavalli
> Consultant, EWI
> Merck & Co. Inc.
> jyothi_honnavalli@merck.com
> 
> 
> -----Original Message-----
> From: howard J meadows [mailto:h_j_meadows@lycos.com] 
> Sent: Wednesday, May 12, 2004 3:02 PM
> To: apache-modules@covalent.net
> Subject: Re: [apache-modules] bucket destroy doubt!
> 
> 
> Hi,
> 
> I may be wrong, but I think you should call apr_bucket_eos_create rather
> than apr_brigade_create
> 
> apr_brigade_create probably makes it look like a new document you are
> dealing with as it will cause recursion 
> 
> HTH
> 
> Meadows
> 
> --
> 
> --------- Original Message ---------
> 
> DATE: Wed, 12 May 2004 12:01:48
> From: "Honnavalli, Jyothi" <jyothi_honnavalli@merck.com>
> To: "'apache-modules@covalent.net'" <apache-modules@covalent.net>
> Cc: 
> 
> > Hi there,
> > In the following code snippets, My module goes through 1st brigade
> > completely, does the process_and_pass_data() till it gets EOS bucket.
After
> > that, when it get the next bucket (next document), it prints the bucket
> > count and segments faults. What is it that I am doing wrong here. Does
this
> > have anything to do with the bucket destroy ?
> > I tried it and removing bucket destroy or APR_BUCKET_REMOVE(e)  doesn't
> help
> > in any way.
> > 
> > Also, does this have anything to do with the settings in httpd.conf where
> we
> > specify the number of child processes. Following the code snippets is the
> > settings used.
> > 
> > Kindly help.
> > -- Newbie for a long time now!!
> > 
> > 	APR_BRIGADE_FOREACH(e, bb) {
> > 		ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "BUCKET COUNT =
> > %d", i++);
> > 
> > 		APR_BUCKET_REMOVE(e);
> > 
> > 		if (APR_BUCKET_IS_FLUSH(e)) {
> > 		    apr_bucket_destroy(e);
> > 		    continue;
> > 		}
> > 		if (APR_BUCKET_IS_EOS(e)) {
> > 			   mybb = apr_brigade_create(arg->pool,
> > c->bucket_alloc);
> > 			   APR_BRIGADE_INSERT_TAIL(mybb, e);
> > 			   ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "GOT
> > EOS BUCKET !" );
> > 			   return  ap_pass_brigade(f->next,mybb);
> > 		}
> > 
> > 		if (!APR_BUCKET_IS_EOS(e)) {
> > 		      	if ((rv = apr_bucket_read(e, &str, &len,
> > APR_NONBLOCK_READ)) == APR_SUCCESS){
> > 	            	rv= process_and_pass_data(str , len);
> > 			apr_bucket_destroy(e);
> > 	        	}
> > 	 }
> > 
> > process_and_pass_data() : is the module which does modification to the
data
> > and sends it across to the next filter as a separate brigade.
> > 
> > [Wed May 12 11:53:51 2004] [debug] mod_test.c(251): [client 54.23.43.53]
> GOT
> > EOS BUCKET !
> > [Wed May 12 11:53:52 2004] [debug] mod_parse.c(158): [client 54.23.43.53]
> In
> > APR_BRIGADE_FOREACH  2
> > [Wed May 12 11:53:53 2004] [notice] child pid 15668 exit signal
> Segmentation
> > fault (11)
> > 
> > <IfModule prefork.c>
> > ServerLimit 1024
> > StartServers         75
> > MinSpareServers      50
> > MaxSpareServers     300
> > MaxClients         1024
> > MaxRequestsPerChild  0
> > </IfModule>
> > 
> > 
> > # worker MPM
> > # StartServers: initial number of server processes to start
> > # MaxClients: maximum number of simultaneous client connections
> > # MinSpareThreads: minimum number of worker threads which are kept spare
> > # MaxSpareThreads: maximum number of worker threads which are kept spare
> > # ThreadsPerChild: constant number of worker threads in each server
process
> > # MaxRequestsPerChild: maximum number of requests a server process serves
> > <IfModule worker.c>
> > StartServers         2
> > MaxClients         150
> > MinSpareThreads     25
> > MaxSpareThreads     75
> > ThreadsPerChild     25
> > MaxRequestsPerChild  0
> > </IfModule>
> > 
> > # perchild MPM
> > # NumServers: constant number of server processes
> > # StartThreads: initial number of worker threads in each server process
> > # MinSpareThreads: minimum number of worker threads which are kept spare
> > # MaxSpareThreads: maximum number of worker threads which are kept spare
> > # MaxThreadsPerChild: maximum number of worker threads in each server
> > process
> > # MaxRequestsPerChild: maximum number of connections per server process
> > <IfModule perchild.c>
> > NumServers           5
> > StartThreads         5
> > MinSpareThreads      5
> > MaxSpareThreads     10
> > MaxThreadsPerChild  20
> > MaxRequestsPerChild  0
> > </IfModule>
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > --------------------------------------------------------------------------
-
> ---
> > Notice:  This e-mail message, together with any attachments, contains
> information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New
> Jersey, USA 08889), and/or its affiliates (which may be known outside the
> United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as
> Banyu) that may be confidential, proprietary copyrighted and/or legally
> privileged. It is intended solely for the use of the individual or entity
> named on this message.  If you are not the intended recipient, and have
> received this message in error, please notify us immediately by reply
e-mail
> and then delete it from your system.
> > --------------------------------------------------------------------------
-
> ---
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
> > For additional commands, e-mail: apache-modules-help@covalent.net
> > 
> > 
> 
> 
> 
> ____________________________________________________________
> Find what you are looking for with the Lycos Yellow Pages
> http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.as
p
> ?SRC=lycos10
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
> For additional commands, e-mail: apache-modules-help@covalent.net
> 
> 
> 
> 
> ---------------------------------------------------------------------------
---
> Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New
Jersey, USA 08889), and/or its affiliates (which may be known outside the
United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as
Banyu) that may be confidential, proprietary copyrighted and/or legally
privileged. It is intended solely for the use of the individual or entity
named on this message.  If you are not the intended recipient, and have
received this message in error, please notify us immediately by reply e-mail
and then delete it from your system.
> ---------------------------------------------------------------------------
---
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
> For additional commands, e-mail: apache-modules-help@covalent.net
> 
> 



____________________________________________________________
Find what you are looking for with the Lycos Yellow Pages
http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp
?SRC=lycos10

---------------------------------------------------------------------
To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
For additional commands, e-mail: apache-modules-help@covalent.net




------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains information of \
Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), \
and/or its affiliates (which may be known outside the United States as Merck Frosst, \
Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, \
proprietary copyrighted and/or legally privileged. It is intended solely for the use \
of the individual or entity named on this message.  If you are not the intended \
recipient, and have received this message in error, please notify us immediately by \
                reply e-mail and then delete it from your system.
------------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
For additional commands, e-mail: apache-modules-help@covalent.net


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic