You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ni...@apache.org on 2009/08/20 01:55:14 UTC
svn commit: r806010 - in /httpd/httpd/trunk: include/ap_listen.h
server/listen.c
Author: niq
Date: Wed Aug 19 23:55:14 2009
New Revision: 806010
URL: http://svn.apache.org/viewvc?rev=806010&view=rev
Log:
Don't require all listeners to be created equal ...
Modified:
httpd/httpd/trunk/include/ap_listen.h
httpd/httpd/trunk/server/listen.c
Modified: httpd/httpd/trunk/include/ap_listen.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_listen.h?rev=806010&r1=806009&r2=806010&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_listen.h (original)
+++ httpd/httpd/trunk/include/ap_listen.h Wed Aug 19 23:55:14 2009
@@ -34,6 +34,7 @@
extern "C" {
#endif
+typedef struct ap_slave_t ap_slave_t;
typedef struct ap_listen_rec ap_listen_rec;
typedef apr_status_t (*accept_function)(void **csd, ap_listen_rec *lr, apr_pool_t *ptrans);
@@ -68,6 +69,8 @@
* The default protocol for this listening socket.
*/
const char* protocol;
+
+ ap_slave_t *slave;
};
/**
@@ -92,6 +95,7 @@
* Loop through the global ap_listen_rec list and close each of the sockets.
*/
AP_DECLARE_NONSTD(void) ap_close_listeners(void);
+AP_DECLARE_NONSTD(int) ap_close_listeners_selected(ap_slave_t*);
/* Although these functions are exported from libmain, they are not really
* public functions. These functions are actually called while parsing the
Modified: httpd/httpd/trunk/server/listen.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/listen.c?rev=806010&r1=806009&r2=806010&view=diff
==============================================================================
--- httpd/httpd/trunk/server/listen.c (original)
+++ httpd/httpd/trunk/server/listen.c Wed Aug 19 23:55:14 2009
@@ -234,7 +234,8 @@
}
static const char *alloc_listener(process_rec *process, char *addr,
- apr_port_t port, const char* proto)
+ apr_port_t port, const char* proto,
+ void *dummy)
{
ap_listen_rec **walk, *last;
apr_status_t status;
@@ -269,6 +270,9 @@
}
if (found_listener) {
+ if (ap_listeners->slave != dummy) {
+ return "Cannot define a slave on the same IP:port as a Listener";
+ }
return NULL;
}
@@ -326,6 +330,7 @@
last->next = new;
last = new;
}
+ new->slave = dummy;
}
return NULL;
@@ -581,6 +586,22 @@
lr->active = 0;
}
}
+AP_DECLARE_NONSTD(int) ap_close_selected_listeners(ap_slave_t *slave)
+{
+ ap_listen_rec *lr;
+ int n = 0;
+
+ for (lr = ap_listeners; lr; lr = lr->next) {
+ if (lr->slave != slave) {
+ apr_socket_close(lr->sd);
+ lr->active = 0;
+ }
+ else {
+ ++n;
+ }
+ }
+ return n;
+}
AP_DECLARE(void) ap_listen_pre_config(void)
{
@@ -589,7 +610,10 @@
ap_listenbacklog = DEFAULT_LISTENBACKLOG;
}
-
+/* Hack: populate an extra field
+ * When this gets called from a Listen directive, dummy is null.
+ * So we can use non-null dummy to pass a data pointer without conflict
+ */
AP_DECLARE_NONSTD(const char *) ap_set_listener(cmd_parms *cmd, void *dummy,
int argc, char *const argv[])
{
@@ -636,7 +660,7 @@
ap_str_tolower(proto);
}
- return alloc_listener(cmd->server->process, host, port, proto);
+ return alloc_listener(cmd->server->process, host, port, proto, dummy);
}
AP_DECLARE_NONSTD(const char *) ap_set_listenbacklog(cmd_parms *cmd,
Re: svn commit: r806010 - in /httpd/httpd/trunk: include/ap_listen.h server/listen.c
Posted by Nick Kew <ni...@webthing.com>.
On 20 Aug 2009, at 21:07, Ruediger Pluem wrote:
>
>
> On 08/20/2009 01:55 AM, niq@apache.org wrote:
>> Author: niq
>> Date: Wed Aug 19 23:55:14 2009
>> New Revision: 806010
>>
>> URL: http://svn.apache.org/viewvc?rev=806010&view=rev
>> Log:
>> Don't require all listeners to be created equal ...
>>
>> Modified:
>> httpd/httpd/trunk/include/ap_listen.h
>> httpd/httpd/trunk/server/listen.c
>
> What is the idea or use case for this change? Currently I am having
> trouble figuring this out.
Think perchild. No, that's not what I'm working on (wait-and-see),
but it's somewhat analagous with child processes.
Basically I want to spawn children that'll have different roles,
to be determined at child startup. And they may also sit at
different nodes of a virtual network. The children are basically
HTTPD slaves, and need to be able to re-use existing
MPM code (any MPM) but have their own dedicated listeners.
--
Nick Kew
Re: svn commit: r806010 - in /httpd/httpd/trunk: include/ap_listen.h
server/listen.c
Posted by Ruediger Pluem <rp...@apache.org>.
On 08/20/2009 01:55 AM, niq@apache.org wrote:
> Author: niq
> Date: Wed Aug 19 23:55:14 2009
> New Revision: 806010
>
> URL: http://svn.apache.org/viewvc?rev=806010&view=rev
> Log:
> Don't require all listeners to be created equal ...
>
> Modified:
> httpd/httpd/trunk/include/ap_listen.h
> httpd/httpd/trunk/server/listen.c
What is the idea or use case for this change? Currently I am having
trouble figuring this out.
Regards
RĂ¼diger