From: reyk Date: Fri, 25 Jul 2014 13:10:18 +0000 (+0000) Subject: Split server and server_config. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9fb8351a2ff5fddc5f38962f1d9df8d7930bdc64;p=openbsd Split server and server_config. --- diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index 35c2d573c79..301d4b26771 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.10 2014/07/25 12:46:23 reyk Exp $ */ +/* $OpenBSD: httpd.h,v 1.11 2014/07/25 13:10:18 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -253,6 +253,7 @@ struct client { u_int32_t clt_id; pid_t clt_pid; void *clt_srv; + void *clt_srv_conf; u_int32_t clt_srv_id; int clt_s; diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c index 2b8f0a03bd5..4380cb60735 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.9 2014/07/25 12:46:23 reyk Exp $ */ +/* $OpenBSD: server.c,v 1.10 2014/07/25 13:10:18 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -316,9 +316,9 @@ server_socket_listen(struct sockaddr_storage *ss, in_port_t port, void server_input(struct client *clt) { - struct server *srv = clt->clt_srv; - evbuffercb inrd = server_read; - evbuffercb inwr = server_write; + struct server_config *srv_conf = clt->clt_srv_conf; + evbuffercb inrd = server_read; + evbuffercb inwr = server_write; if (server_httpdesc_init(clt) == -1) { server_close(clt, @@ -340,7 +340,7 @@ server_input(struct client *clt) } bufferevent_settimeout(clt->clt_bev, - srv->srv_conf.timeout.tv_sec, srv->srv_conf.timeout.tv_sec); + srv_conf->timeout.tv_sec, srv_conf->timeout.tv_sec); bufferevent_enable(clt->clt_bev, EV_READ|EV_WRITE); } @@ -473,6 +473,7 @@ server_accept(int fd, short event, void *arg) clt->clt_fd = -1; clt->clt_toread = TOREAD_UNLIMITED; clt->clt_srv = srv; + clt->clt_srv_conf = &srv->srv_conf; clt->clt_id = ++server_cltid; clt->clt_srv_id = srv->srv_conf.id; clt->clt_pid = getpid(); @@ -545,8 +546,9 @@ server_inflight_dec(struct client *clt, const char *why) void server_close(struct client *clt, const char *msg) { - char ibuf[128], obuf[128], *ptr = NULL; - struct server *srv = clt->clt_srv; + char ibuf[128], obuf[128], *ptr = NULL; + struct server *srv = clt->clt_srv; + struct server_config *srv_conf = clt->clt_srv_conf; SPLAY_REMOVE(client_tree, &srv->srv_clients, clt); @@ -563,13 +565,13 @@ server_close(struct client *clt, const char *msg) memset(&ibuf, 0, sizeof(ibuf)); memset(&obuf, 0, sizeof(obuf)); (void)print_host(&clt->clt_ss, ibuf, sizeof(ibuf)); - (void)print_host(&srv->srv_conf.ss, obuf, sizeof(obuf)); + (void)print_host(&srv_conf->ss, obuf, sizeof(obuf)); if (EVBUFFER_LENGTH(clt->clt_log) && evbuffer_add_printf(clt->clt_log, "\r\n") != -1) ptr = evbuffer_readline(clt->clt_log); log_info("server %s, " "client %d (%d active), %s -> %s:%d, " - "%s%s%s", srv->srv_conf.name, clt->clt_id, server_clients, + "%s%s%s", srv_conf->name, clt->clt_id, server_clients, ibuf, obuf, ntohs(clt->clt_port), msg, ptr == NULL ? "" : ",", ptr == NULL ? "" : ptr); if (ptr != NULL) diff --git a/usr.sbin/httpd/server_file.c b/usr.sbin/httpd/server_file.c index b4c593c0a91..c4814a04ccd 100644 --- a/usr.sbin/httpd/server_file.c +++ b/usr.sbin/httpd/server_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_file.c,v 1.12 2014/07/25 12:46:23 reyk Exp $ */ +/* $OpenBSD: server_file.c,v 1.13 2014/07/25 13:10:18 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -119,14 +119,14 @@ int server_file(struct httpd *env, struct client *clt) { struct http_descriptor *desc = clt->clt_desc; - struct server *srv = clt->clt_srv; + struct server_config *srv_conf = clt->clt_srv_conf; struct media_type *media; const char *errstr = NULL; int fd = -1, ret; char path[MAXPATHLEN]; struct stat st; - if (canonicalize_path(srv->srv_conf.docroot, + if (canonicalize_path(srv_conf->docroot, desc->http_path, path, sizeof(path)) == NULL) { /* Do not echo the uncanonicalized path */ server_abort_http(clt, 500, "invalid request path"); @@ -171,7 +171,7 @@ server_file(struct httpd *env, struct client *clt) } bufferevent_settimeout(clt->clt_file, - srv->srv_conf.timeout.tv_sec, srv->srv_conf.timeout.tv_sec); + srv_conf->timeout.tv_sec, srv_conf->timeout.tv_sec); bufferevent_enable(clt->clt_file, EV_READ); bufferevent_disable(clt->clt_bev, EV_READ); diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index 1d14b7775fb..3fe09262171 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.12 2014/07/25 12:46:23 reyk Exp $ */ +/* $OpenBSD: server_http.c,v 1.13 2014/07/25 13:10:18 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter @@ -518,7 +518,7 @@ server_reset_http(struct client *clt) void server_abort_http(struct client *clt, u_int code, const char *msg) { - struct server *srv = clt->clt_srv; + struct server_config *srv_conf = clt->clt_srv_conf; struct bufferevent *bev = clt->clt_bev; const char *httperr = NULL, *text = ""; char *httpmsg, *extraheader = NULL; @@ -534,7 +534,7 @@ server_abort_http(struct client *clt, u_int code, const char *msg) goto done; /* Some system information */ - if (print_host(&srv->srv_conf.ss, hbuf, sizeof(hbuf)) == NULL) + if (print_host(&srv_conf->ss, hbuf, sizeof(hbuf)) == NULL) goto done; /* RFC 2616 "tolerates" asctime() */ @@ -596,7 +596,7 @@ server_abort_http(struct client *clt, u_int code, const char *msg) code, httperr, tmbuf, HTTPD_SERVERNAME, extraheader == NULL ? "" : extraheader, code, httperr, style, httperr, text, - HTTPD_SERVERNAME, hbuf, ntohs(srv->srv_conf.port)) == -1) + HTTPD_SERVERNAME, hbuf, ntohs(srv_conf->port)) == -1) goto done; /* Dump the message without checking for success */