httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Marr <gr...@alum.wpi.edu>
Subject Re: mod_smtpd design.
Date Fri, 01 Jul 2005 16:21:35 GMT
At 11:34 AM 7/1/2005, Rian A Hunter wrote:
>Quoting Garrett Rooney <rooneg@electricjellyfish.net>:
> > Rian Hunter wrote:
> > > type misc_smtp_handler(request_rec *r) {
> > >     smtpd_request_rec *smtp_data;
> > >
> > >     if (strncmp("http", r->protocol_name, 4)) {
> > >         // decline to handle, this module doesn't handle
> > >         // http requests.
> > >     }
> > >     //then get smtpd specific data
> > >     smtp_data = get_smtpd_request(r);
> > >
> > >     // do some handlin'
> > > }
> > >
> > > The advantage to this approach is a less bulky (but more all
> > > encompassing) request_rec with support for an arbitrary amount 
> of
> > > protocols and protocol specific data.
> >
> > Rather than inserting dozens of strcmps all throught the 
> processing, I'd
> > prefer to store an int identifying the protocol, and just have a 
> simple
> > compare.  No reason to burn CPU on the strcmp if we don't have to.
> >
> > -garrett
> >
>
>The reason I suggested a strcmp is that it gives freedom to module 
>developers to
>set and implement any protocol they like. Doing integer comparisons 
>would
>require us to maintain a list of "official" integer->protocol 
>mappings, but
>there may be other ways to approach it without having that 
>constraint. Maybe we
>can use the official iana port description list to specifiy 
>protocols like 80
>means http, 25 means smtp, 143 means imap etc.

It doesn't need to be a compile-time mapping.  There could be a 
per-process mapping from string to integer.  On load, each module 
calls a function to register the protocols that they're interested 
in.  If the protocol has already been registered, its integer is 
returned.  If not, it is given the next slot in the protocol table, 
and the new integer is returned.


Mime
View raw message