httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tyler MacDonald <ty...@yi.org>
Subject Re: listener from a conn_rec?
Date Thu, 12 Apr 2007 20:10:35 GMT
Here's what I came up with... of course, it falls apart as soon as you have
more than one protocol on the same port (maybe with different bind addresses
or whatever), but doing that is a bad idea anyways, isn't it? :-)

static const char* what_protocol_am_i(conn_rec* c) {
  apr_port_t port = c->local_addr->port;
  ap_listen_rec* cur;
  char* rv;
  char* p;
  int i;
  for(cur = ap_listeners; cur != NULL; cur = cur->next) {
    if(cur->bind_addr->port == port) {
      rv = apr_pstrdup(c->pool, cur->protocol);
      for(p=rv;*p;p++)
        *p = tolower(*p);
      return rv;
    }
  }
  return NULL;
}

This would be *way* simpler if there was just a conn_rec.listener record...

	Cheers,
		Tyler




Tyler MacDonald <tyler@yi.org> wrote:
> Hi,
> 
> 	Given a connection record, how do I determine what listener
> originally accepted the connection? I've dug around the API documentation a
> bit and can't find a clear path back to my listener from a connection, but
> it would sure be nice to know, for example, what protocol was assigned to a
> listener that dispatched my conn_rec...
> 
> 	TIA,
> 		Tyler
> 

-- 

Mime
View raw message