From cbf005ba666d772bc3266b4717b12de55a105d36 Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Fri, 2 Mar 2007 11:32:41 +0000 Subject: when the http read callback changes and some data is still left in the input buffer, we call the new callback to handle the remaining data. this change makes sure that we only do this after the read callback was actually changed (read header -> read content, read content -> read header, read chunks...) to avoid a possible loop which could happen in some rare cases. --- usr.sbin/hoststated/relay.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'usr.sbin/hoststated') diff --git a/usr.sbin/hoststated/relay.c b/usr.sbin/hoststated/relay.c index d407e8d1047..dfdf2982634 100644 --- a/usr.sbin/hoststated/relay.c +++ b/usr.sbin/hoststated/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.14 2007/02/27 13:38:58 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.15 2007/03/02 11:32:40 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter @@ -899,6 +899,8 @@ relay_read_httpcontent(struct bufferevent *bev, void *arg) size, cre->toread); if (con->done) goto done; + if (EVBUFFER_LENGTH(src) && bev->readcb != relay_read_httpcontent) + bev->readcb(bev, arg); bufferevent_enable(bev, EV_READ); return; done: @@ -993,7 +995,7 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg) if (con->done) goto done; - if (EVBUFFER_LENGTH(src)) + if (EVBUFFER_LENGTH(src) && bev->readcb != relay_read_httpchunks) bev->readcb(bev, arg); bufferevent_enable(bev, EV_READ); return; @@ -1270,7 +1272,7 @@ next: } if (con->done) goto done; - if (EVBUFFER_LENGTH(src)) + if (EVBUFFER_LENGTH(src) && bev->readcb != relay_read_http) bev->readcb(bev, arg); bufferevent_enable(bev, EV_READ); return; -- cgit v1.2.3