-/* $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 <reyk@openbsd.org>
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;
-/* $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 <reyk@openbsd.org>
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,
}
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);
}
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();
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);
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)
-/* $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 <reyk@openbsd.org>
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");
}
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);
-/* $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 <reyk@openbsd.org>
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;
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() */
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 */