Brandon Fosdick wrote:
> http://terran-bank.com/mod_dav_userdir_20051028.tar

So maybe I should explain the code a bit. First off, its all C++. Now we wait a 
sec for the C folks to run away screaming...ok, good.

All of the database magic happens in class ServerConfig. It's an enourmous mess 
of a class. Cleaning it up is on the ToDo list, after switching to prepared 
statements. (really, I have a list, it's in OmniOutliner on my pbook) As the 
name implies, this class is created by the usual create server config handler. 
All of the config directive handlers call set_X() methods of ServerConfig.

repository.cc is what you think it is if you're familiar with mod_dav, but it 
mostly passes stuff off to class resource_t, which then passes database 
requests to ServerConfig.
For those not familiar with mod_dav, every request starts with a call to 
get_resource(), which is responsible for creating a structure that represents 
each DAV resource involved in the request. In this case that structure is 
resource_t. 
deliver() is where the downloading happens. It creates a bucket brigade and 
dumps all of the blocks from the database into the brigade. I have no idea if I 
did that right.

hooks.cc is where all of the hooks are registered. Nothing fancy there.

Locks, properties, etc are handled by the appropriately named files. Most of 
the handlers pass through to a class method of some sort. That sounds like it 
would be slow, but almost all of the class methods are inline, so its no worse 
than C. Most of these classes are fairly straightforward. Locks are poorly 
implemented ATM.

stream_t in stream.h is where the upload magic happens. It serves as a buffer 
between mod_dav and the database. Incoming bytes are buffered into 64K blocks 
before being written to MySQL. This would be a great place to use prepared 
statements, but I haven't gotten around to it. When I started this project I 
had never used them outside of PHP, and my focus was on getting something 
working as quickly as possible.

apr_pool_base.h has a base class and a new() operator that helps with using 
pools. I can't tell if the destructors are being called properly, but I haven't 
had any problems with memory leaks, so maybe its working.

The sharp eyed will notice that I have a copy of mod_dav.h in the source. 
That's because the official copy uses the namespace token in two places, and 
therefore barfs in C++. I sent an email to the list about this several months 
ago and didn't get a response. So, I use a modified copy.

I should point out that the usernames are constrained to be positive integers, 
but only because that's what Terran Bank needs. At one point I was maintaining 
a fork that allowed real usernames, but it fell by the side. Mainly because it 
was pointless, I think the only difference was two functions in resource_t. 
Some day I'll add a compile-time config option.

That's the high level overview. Let me know if you want more.

Reply via email to