summaryrefslogtreecommitdiffstats
path: root/server/vhost.c
diff options
context:
space:
mode:
authorPaul Querna <pquerna@apache.org>2005-04-25 07:23:18 +0200
committerPaul Querna <pquerna@apache.org>2005-04-25 07:23:18 +0200
commit03c53e0a5b820a75eb3dcdb4e88eed65fbf6b47c (patch)
tree3bde970b89d65487426e9a8cb4c7be6e636bea25 /server/vhost.c
parentRemove ap_method_list_do and ap_method_list_vdo as previously mentioned dev@h... (diff)
downloadapache2-03c53e0a5b820a75eb3dcdb4e88eed65fbf6b47c.tar.xz
apache2-03c53e0a5b820a75eb3dcdb4e88eed65fbf6b47c.zip
Add ap_vhost_iterate_given_conn() as I had previously mentioned on the mailing list.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@164538 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/vhost.c')
-rw-r--r--server/vhost.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/server/vhost.c b/server/vhost.c
index 199465de9e..6bb27bd80a 100644
--- a/server/vhost.c
+++ b/server/vhost.c
@@ -977,6 +977,56 @@ AP_DECLARE(void) ap_update_vhost_from_headers(request_rec *r)
}
}
+/**
+ * For every virtual host on this connection, call func_cb.
+ */
+AP_DECLARE(int) ap_vhost_iterate_given_conn(conn_rec *conn,
+ ap_vhost_iterate_conn_cb func_cb,
+ void* baton)
+{
+ server_rec *s;
+ server_rec *last_s;
+ name_chain *src;
+ apr_port_t port;
+ int rv = 0;
+
+ if (conn->vhost_lookup_data) {
+ last_s = NULL;
+ port = conn->local_addr->port;
+
+ for (src = conn->vhost_lookup_data; src; src = src->next) {
+ server_addr_rec *sar;
+
+ /* We only consider addresses on the name_chain which have a
+ * matching port.
+ */
+ sar = src->sar;
+ if (sar->host_port != 0 && port != sar->host_port) {
+ continue;
+ }
+
+ s = src->server;
+
+ if (s == last_s) {
+ /* we've already done a callback for this vhost. */
+ continue;
+ }
+
+ last_s = s;
+
+ rv = func_cb(baton, conn, s);
+
+ if (rv != 0) {
+ break;
+ }
+ }
+ }
+ else {
+ rv = func_cb(baton, conn, conn->base_server);
+ }
+
+ return rv;
+}
/* Called for a new connection which has a known local_addr. Note that the
* new connection is assumed to have conn->server == main server.