httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@cpan.org>
Subject Re: [Patch] ap_alloc_listener
Date Tue, 25 Mar 2003 03:18:47 GMT
On Sat, 2003-02-22 at 20:55, Jeff Trawick wrote:
> Philippe M. Chiasson wrote:
> 
> > In trying to write a protocol module for a protocol type != TCP, I had
> > to duplicate the logic of both alloc_listener and find_default_family
> > from server/listen.c.
> >
> > I believe that if a module wants to push a new listener socket on
> > ap_listeners, the module should simply do:
> >
> > ap_alloc_listener(process, hostname, port, type);
> 
> 
> +1 in concept

Thanks, that's great. With this patch applied, mod_udp would have
significantly less redundant code.
 
> > The following patch exposes alloc_listener as ap_alloc_listener and
> > takes an extra type argument.
> >
> > Index: server/listen.c
> > ===================================================================
> > RCS file: /home/cvspublic/httpd-2.0/server/listen.c,v
> > retrieving revision 1.84
> > diff -u -b -B -r1.84 listen.c
> > --- server/listen.c	22 Nov 2002 12:23:10 -0000	1.84
> > +++ server/listen.c	3 Feb 2003 12:10:27 -0000
> > @@ -266,8 +266,7 @@
> >  #endif
> >  }
> >
> > -
> > -static const char *alloc_listener(process_rec *process, char *addr, 
> > apr_port_t port)
> > +const char *ap_alloc_listener(process_rec *process, char *addr, 
> > apr_port_t port, int type)
> 
> 
> you need to use AP_DECLARE here too, as in
> 
> AP_DECLARE(const char *) ap_alloc_listener(blah blah blah)

Corrected

# $Id: ap_alloc_listener.patch,v 1.2 2003/03/25 03:16:27 gozer Exp $
This patch has been submitted to the asf for inclusion.

Once applied, define AP_ALLOC_LISTENER in mod_udp_listen.h

Index: include/ap_listen.h
===================================================================
RCS file: /home/cvspublic/httpd-2.0/include/ap_listen.h,v
retrieving revision 1.30
diff -u -b -B -r1.30 ap_listen.h
--- include/ap_listen.h	13 Mar 2002 20:47:42 -0000	1.30
+++ include/ap_listen.h	3 Feb 2003 12:10:27 -0000
@@ -149,4 +149,6 @@
 AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
   "Send buffer size in bytes")
 
+AP_DECLARE(const char*) ap_alloc_listener(process_rec *process, char *addr, apr_port_t port,
int type);
+
 #endif
Index: server/listen.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/listen.c,v
retrieving revision 1.84
diff -u -b -B -r1.84 listen.c
--- server/listen.c	22 Nov 2002 12:23:10 -0000	1.84
+++ server/listen.c	3 Feb 2003 12:10:27 -0000
@@ -266,8 +266,7 @@
 #endif
 }
 
-
-static const char *alloc_listener(process_rec *process, char *addr, apr_port_t port)
+AP_DECLARE(const char *) ap_alloc_listener(process_rec *process, char *addr, apr_port_t port,
int type)
 {
     ap_listen_rec **walk;
     ap_listen_rec *new;
@@ -323,7 +322,7 @@
     }
     if ((status = apr_socket_create(&new->sd,
                                     new->bind_addr->family,
-                                    SOCK_STREAM, process->pool))
+                                    type, process->pool))
         != APR_SUCCESS) {
         ap_log_perror(APLOG_MARK, APLOG_CRIT, status, process->pool,
                       "alloc_listener: failed to get a socket for %s", addr);
@@ -429,7 +428,7 @@
         return "Port must be specified";
     }
 
-    return alloc_listener(cmd->server->process, host, port);
+    return ap_alloc_listener(cmd->server->process, host, port, SOCK_STREAM);
 }
 
 const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg)

Mime
View raw message