summaryrefslogtreecommitdiffstats
path: root/usr.sbin/slowcgi
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2013-10-18 14:48:54 +0000
committerflorian <florian@openbsd.org>2013-10-18 14:48:54 +0000
commit4404b4d504204a241ddce9940efef697048b5801 (patch)
tree5326f2321beacba00fe1639032d090fa075f27a3 /usr.sbin/slowcgi
parentLogging to syslog works better with openlog(3). (diff)
downloadwireguard-openbsd-4404b4d504204a241ddce9940efef697048b5801.tar.xz
wireguard-openbsd-4404b4d504204a241ddce9940efef697048b5801.zip
Do not fiddle with the response queue directly but go through
a new slowcgi_add_response() function. This ensures that we always do an event_add. OK blambert
Diffstat (limited to 'usr.sbin/slowcgi')
-rw-r--r--usr.sbin/slowcgi/slowcgi.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/usr.sbin/slowcgi/slowcgi.c b/usr.sbin/slowcgi/slowcgi.c
index 9540897fffc..79dfae33e7c 100644
--- a/usr.sbin/slowcgi/slowcgi.c
+++ b/usr.sbin/slowcgi/slowcgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slowcgi.c,v 1.16 2013/10/18 14:47:47 florian Exp $ */
+/* $OpenBSD: slowcgi.c,v 1.17 2013/10/18 14:48:54 florian Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
* Copyright (c) 2013 Florian Obser <florian@openbsd.org>
@@ -157,6 +157,7 @@ void slowcgi_paused(int, short, void *);
void slowcgi_accept(int, short, void *);
void slowcgi_request(int, short, void *);
void slowcgi_response(int, short, void *);
+void slowcgi_add_response(struct request *, struct fcgi_response *);
void slowcgi_timeout(int, short, void *);
void slowcgi_sig_handler(int, short, void *);
size_t parse_record(uint8_t * , size_t, struct request *);
@@ -422,7 +423,7 @@ slowcgi_accept(int fd, short events, void *arg)
event_set(&c->ev, s, EV_READ | EV_PERSIST, slowcgi_request, c);
event_add(&c->ev, NULL);
-
+ event_set(&c->resp_ev, s, EV_WRITE | EV_PERSIST, slowcgi_response, c);
event_set(&c->tmo, s, 0, slowcgi_timeout, c);
event_add(&c->tmo, &timeout);
requests->request = c;
@@ -481,6 +482,13 @@ slowcgi_sig_handler(int sig, short event, void *arg)
}
void
+slowcgi_add_response(struct request *c, struct fcgi_response *resp)
+{
+ TAILQ_INSERT_TAIL(&c->response_head, resp, entry);
+ event_add(&c->resp_ev, NULL);
+}
+
+void
slowcgi_response(int fd, short events, void *arg)
{
struct request *c;
@@ -865,7 +873,7 @@ create_end_record(struct request *c)
resp->data_pos = 0;
resp->data_len = sizeof(struct fcgi_end_request_body) +
sizeof(struct fcgi_record_header);
- TAILQ_INSERT_TAIL(&c->response_head, resp, entry);
+ slowcgi_add_response(c, resp);
}
void
@@ -902,12 +910,7 @@ script_in(int fd, struct event *ev, struct request *c, uint8_t type)
header->content_len = htons(n);
resp->data_pos = 0;
resp->data_len = n + sizeof(struct fcgi_record_header);
- TAILQ_INSERT_TAIL(&c->response_head, resp, entry);
-
- event_del(&c->resp_ev);
- event_set(&c->resp_ev, EVENT_FD(&c->ev), EV_WRITE | EV_PERSIST,
- slowcgi_response, c);
- event_add(&c->resp_ev, NULL);
+ slowcgi_add_response(c, resp);
if (n == 0) {
if (type == FCGI_STDOUT)