Re: ap_rwrite

2008-05-29 Thread Mike O'Leary
Samuel,

Thanks for taking the time to respond.  My question was more about how the
Apache socket API works.  I'm actually not experiencing any problems.  I was
just wondering if the ap_rwrite call could return some value less than the
number of bytes requested to be written.  I wanted to know if I need to put
a loop around all of my ap_rwrite calls to verify that all the data is
sent.  I'll probably just add the loop to make sure, but I'm not sure if
I'll need it.

Thanks,
Mike

On Tue, May 27, 2008 at 1:21 PM, Samuel Gomez [EMAIL PROTECTED]
wrote:

 Hello Mike.

 Two notes on your topic.

 1.- In httpd.h there is a constant called MAX_STRING_LEN . Maybe is playing
 some role here. Did you notice if buffer printing gets cut just when exceeds
 the number of bytes defined in MAX_STRING_LEN ?

 2.- For string printing, I use ap_rputs()
 http://httpd.apache.org/dev/apidoc/apidoc_ap_rputs.html
 Not based in any special reason. Simply it is the funcion I saw on some
 tutorials and I use it. Test it. I always use it for printing short strings,
 but maybe is useful also in your case.

 Samuel




 Mike O'Leary wrote:

 Hello,

 I am writing an Apache module using Apache 2.2.3 and, from what I
 understand, the sockets are non-blocking.  My questions is about ap_rwrite
 having the signature below:

 AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);

 Is it possible that ap_rwrite returns some value less than nbyte, but not
 -1?  This would mean that I would need to loop, passing some byte offset
 into buf and reducing nbyte until all of the content was sent.  If it is
 not
 possible for ap_rwrite to return some value less than nbyte other than -1,
 is there some internal mechanism that is looking to enforce a specific
 transfer rate and will time out and return -1 from ap_rwrite if this rate
 is
 not achieved?  If this is not the case, then aren't the sockets blocking?

 Thanks in advance!

 -Mike







Re: ap_rwrite

2008-05-29 Thread Mike O'Leary
Chris,

Thanks for the info.  I assume that ap_rwrite is writing directly to the
client which you mention is bad.  What is the preferred method and why is
the ap_rwrite not preferred?  Pardon me, I'm a newb.

Thanks,
Mike

On Thu, May 29, 2008 at 4:52 PM, Chris Kukuchka [EMAIL PROTECTED]
wrote:

 Mike O'Leary wrote:

 I was just wondering if the ap_rwrite call could return some value less
 than the
 number of bytes requested to be written.  I wanted to know if I need to
 put
 a loop around all of my ap_rwrite calls to verify that all the data is
 sent.

 Mike,

 In answer to your question, yes, a loop is in order.  Something like this:

 while (n_bytes  0)
   {
 int n = (ap_rwrite (data, n_bytes, r));
 if (n  0)
{
  /* error writing to client */
}
 n_bytes -= n;
 data += n;
   }

 Further, keep in mind if you are writing an Apache 2 module, you should
 *not* be writing directly to the client.  Also, there may be a more specific
 mailing list available for questions regarding the ap* utilities.

 Chris Kukuchka
 Sequoia Group, Inc.






Connection Pool Module

2007-12-14 Thread Mike O'Leary
I am looking to write an Apache module that maintains a pool of socket
connections to a back-end server.  When a request for the module comes in, a
connection from the pool would be grabbed and the data sent to the back-end
server.  I want persistent connections to the back-end server; constantly
reconnecting would be very painful.

Anyone know of how I could get this to work?  From what I've read, I don't
see that this is possible, but throwing it out in the hopes that someone
here knows.  I appreciate any help you can give.


Mike