From 0bac6c35e98920e56130d4ed067ccd7245422bc0 Mon Sep 17 00:00:00 2001 From: reyk Date: Fri, 25 Jul 2014 23:30:58 +0000 Subject: [PATCH] Differentiate servers by address and port, not just by address. --- usr.sbin/httpd/config.c | 4 ++-- usr.sbin/httpd/httpd.h | 4 ++-- usr.sbin/httpd/server.c | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/usr.sbin/httpd/config.c b/usr.sbin/httpd/config.c index eb9e003ae8f..762a7a392a5 100644 --- a/usr.sbin/httpd/config.c +++ b/usr.sbin/httpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.4 2014/07/25 16:23:19 reyk Exp $ */ +/* $OpenBSD: config.c,v 1.5 2014/07/25 23:30:58 reyk Exp $ */ /* * Copyright (c) 2011 - 2014 Reyk Floeter @@ -249,7 +249,7 @@ config_getserver(struct httpd *env, struct imsg *imsg) /* Check if server with matching listening socket already exists */ if ((srv = server_byaddr((struct sockaddr *) - &srv_conf.ss)) != NULL) { + &srv_conf.ss, srv_conf.port)) != NULL) { /* Add "host" to existing listening server */ close(imsg->fd); return (config_getserver_config(env, diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index f88a46f2ca6..df34b477c98 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.14 2014/07/25 23:23:39 reyk Exp $ */ +/* $OpenBSD: httpd.h,v 1.15 2014/07/25 23:30:58 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -388,7 +388,7 @@ int server_bufferevent_add(struct event *, int); int server_bufferevent_write(struct client *, void *, size_t); void server_inflight_dec(struct client *, const char *); struct server * - server_byaddr(struct sockaddr *); + server_byaddr(struct sockaddr *, in_port_t); SPLAY_PROTOTYPE(client_tree, client, clt_nodes, server_client_cmp); diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c index 18fe06ca8a6..3ef140137c2 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.12 2014/07/25 23:23:39 reyk Exp $ */ +/* $OpenBSD: server.c,v 1.13 2014/07/25 23:30:58 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -182,12 +182,13 @@ server_purge(struct server *srv) } struct server * -server_byaddr(struct sockaddr *addr) +server_byaddr(struct sockaddr *addr, in_port_t port) { struct server *srv; TAILQ_FOREACH(srv, env->sc_servers, srv_entry) { - if (sockaddr_cmp((struct sockaddr *)&srv->srv_conf.ss, + if (port == srv->srv_conf.port && + sockaddr_cmp((struct sockaddr *)&srv->srv_conf.ss, addr, srv->srv_conf.prefixlen) == 0) return (srv); } -- 2.20.1