#include "http_log.h"
#include "mpm_common.h"
+APLOG_USE_MODULE(core);
+
AP_DECLARE_DATA ap_listen_rec *ap_listeners = NULL;
static ap_listen_rec *old_listeners;
}
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;
}
if (found_listener) {
+ if (ap_listeners->slave != dummy) {
+ return "Cannot define a slave on the same IP:port as a Listener";
+ }
return NULL;
}
last->next = new;
last = new;
}
+ new->slave = dummy;
}
return NULL;
#endif
if (make_sock(pool, lr) == APR_SUCCESS) {
++num_open;
- lr->active = 1;
}
else {
#if APR_HAVE_IPV6
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)
{
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[])
{
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,