You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Philippe M. Chiasson" <go...@cpan.org> on 2003/03/25 04:18:47 UTC

Re: [Patch] ap_alloc_listener

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)

Re: [Patch] ap_alloc_listener

Posted by "Philippe M. Chiasson" <go...@cpan.org>.
On Tue, 2003-03-25 at 11:18, Philippe M. Chiasson wrote:
> On Sat, 2003-02-22 at 20:55, Jeff Trawick wrote:
> > Philippe M. Chiasson wrote:
> > 

Realized my previous patch had lines > 78 chars, following patch fixes
that (thank you Stas)

# $Id: ap_alloc_listener.patch,v 1.3 2003/03/25 07:23:18 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.31
diff -u -I'$Id' -I'$Revision' -r1.31 ap_listen.h
--- include/ap_listen.h	3 Feb 2003 17:52:53 -0000	1.31
+++ include/ap_listen.h	25 Mar 2003 07:18:05 -0000
@@ -149,4 +149,7 @@
 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.85
diff -u -I'$Id' -I'$Revision' -r1.85 listen.c
--- server/listen.c	3 Feb 2003 17:53:18 -0000	1.85
+++ server/listen.c	25 Mar 2003 07:18:05 -0000
@@ -266,8 +266,8 @@
 #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 +323,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 +429,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)