Return-Path: Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 92499 invoked by uid 500); 3 Feb 2003 12:27:05 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 92486 invoked from network); 3 Feb 2003 12:27:04 -0000 Subject: [Patch] ap_alloc_listener From: "Philippe M. Chiasson" To: dev@httpd.apache.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 (1.0.8-10) Date: 03 Feb 2003 20:27:01 +0800 Message-Id: <1044275221.1647.19.camel@shou.sg.ectoplasm.org> Mime-Version: 1.0 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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); The following patch exposes alloc_listener as ap_alloc_listener and takes an extra type argument. 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) +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) -------------------------------------------------------------------------------- Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B) http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5 Q: It is impossible to make anything foolproof because fools are so ingenious. perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'