difference between the APR_BLOCK_READ and APR_NONBLOCK_READ?

2007-04-09 Thread li xu

Hi all,
  I am now using mod_echo.c.The module works well,but i find that
after i telnet to the apache server,i could not exit the telnet
program(even the escape character '^]')..So i change the source code
of mod_echo.c(APR_BLOCK_READ to APR_NONBLOCK_READ).
But,as soon as i type something in the telnet ,the server closes my
connection.That's not what i want..

I want to know what the difference between the APR_BLOCK_READ and
APR_NONBLOCK_READ.
Could anyone help me with that?and i want to know why..

Thanks in advance.


Re: one module per task

2007-04-09 Thread Sam Carleton

On 4/9/07, Joe Lewis [EMAIL PROTECTED] wrote:

Sam Carleton wrote:
 When Apache sees

 Location /coolapp
   SetHandler mod_my_cool_app
 Location

 How does it know that mod_my_cool_app is associated with
 mod_my_cool_app.so?  Is it purely from the LoadModule or is there
 something in the module that I am missing?

It doesn't.  Simply mod_my_cool_app.so has a function which checks the
handler, and either completes the request or returns 'DECLINED so that
another module can handle the request.


Joe,

Oh, that explains the first line of my hander looking something like this:

if (strcmp(r-handler, mod_my_cool_app))  return DECLINED;

I get it now!  This also explains why one is able to place the hander
at the very first, first, middle, end or very end of the chain.
Slowly, oh so slowly, it begins to come clearer (mind you when it
starts off looking like mudd, clearer doesn't mean too muchgrin).

Thanks!

Sam


Re: server side includes

2007-04-09 Thread Nick Kew
On Mon, 09 Apr 2007 23:31:32 +0300
Issac Goldstand [EMAIL PROTECTED] wrote:

 You'd probably just use output filters to parse the output stream and
 add content according to what you find...  I don't have a C example,
 but do have a Perl example (string parsing is just s much more
 trivial with Perl than C) at
 http://search.cpan.org/src/ISAAC/Apache-UploadMeter-0.9915/lib/Apache/UploadMeter.pm
 (search for ### Output filters).  One replaces a custom tag, and
 one simply includes HTML at the beginning of head

You can't just do that in any language unless you make a BIG performance
sacrifice.  The basic problem is that head, or any other pattern of
more than one byte, might be split over more than one call to your
filter function.  Techniques for dealing with that are of course
described in my book.


 Sam Carleton wrote:
  As I sit here on hold, I started thinking about my little apache
  module again.  I recall reading in Writing Apache Modules in Perl
  and C how with Perl it is quick and easy to create a server side

That book is very, very old.  Apache 1.x didn't have filters, so
SSI was altogether more primitive.

  include handler, I think that is what it was called.  How would one
  go about doing that in a C module?  Are there any examples?

... and I don't know what it refers to as an SSI handler (I expect
a primitive mod_include alternative).

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/


Temporary files directory

2007-04-09 Thread David Wortham

Hi guys,
  More issues with temporary files.

  I'm trying to find a place (directory) to use for writing a set of
long-term temp files (cache files).  So far, I have found these two calls:
ap_server_root_relative(p, logs/) and
apr_temp_dir_get((const char**)temp_dir, p);

Problems:
(1) Neither guarantees that the directory exists
(2) There is no guarantee that the user Apache is running as will have
permissions to write to this directory (even if I create it... as root) **
**Apache must run as root to access port 80 (the usual case), but can be set
to switch to another user (apache | nobody | some other user) before the
multiple child processes are created.
If I create a directory, I can set permissions, but I can not set the
permissions of the components of the path necessary to traverse to the temp
directory.

My question is:
How does Apache write to the access and error logs?  Can I use the same code
to write to the same directory?*
* I need to write to my own file(s) not write to existing log files (my
cache files are serialized structs).
Does anyone else know of a well-tested module that can handle user-switching
and writing to logs gracefully?


Thanks,
Dave
--
David Wortham
Senior Web Applications Developer
Unspam Technologies, Inc.
1901 Prospector Dr. #30
Park City, UT 84060
(435) 513-0672


Re: Temporary files directory

2007-04-09 Thread Chris Kukuchka
I'm trying to find a place (directory) to use for writing a set of
 long-term temp files (cache files).

Why not just have a configuration directive which would allow the user to 
specify where these cache file reside?  That way each setup could intelligently 
set the value to match their environment.  You could then report an error 
during startup if the directory cannot be accessed.

 How does Apache write to the access and error logs?

Configuration directive--user tells Apache where they want the logs.

  Can I use the same code
 to write to the same directory?*

The log directory is typically used for logs.

Regards,

Chris Kukuchka
Sequoia Group, Inc.

P.S.  While you are creating configuration directives for where to place the 
cache files, you might also want to provide some means to reign in the disk 
usage for the cache--a max size perhaps.




Re: Temporary files directory

2007-04-09 Thread Graham Dumpleton

On 10/04/07, Chris Kukuchka [EMAIL PROTECTED] wrote:

  Can I use the same code
 to write to the same directory?*

The log directory is typically used for logs.


But also used by mod_cgid for UNIX sockets to communicate with daemon
process. This though can be overridden using ScriptSock directive.

Graham