diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-01-03 17:03:49 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-01-03 17:03:49 +0100 |
commit | b7c85a2819b3869279a669d5681f574824589c6c (patch) | |
tree | da6639a596bd4d802ce1838582d6a86deac62be6 /proc.c | |
parent | 12931edab795b7caeb70323e2959b5e5503c5980 (diff) |
implement proper flow control for relaying postdata
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -235,6 +235,18 @@ static void proc_relay_write_cb(struct ustream *us, int bytes) if (ustream_pending_data(us, true)) return; + cl->dispatch.data_blocked = false; + us->notify_write = NULL; + client_poll_post_data(cl); +} + +static void proc_relay_write_close_cb(struct ustream *us, int bytes) +{ + struct client *cl = container_of(us, struct client, dispatch.proc.r.sfd.stream); + + if (ustream_pending_data(us, true)) + return; + proc_write_close(cl); } @@ -243,6 +255,10 @@ static void proc_data_send(struct client *cl, const char *data, int len) struct ustream *us = &cl->dispatch.proc.r.sfd.stream; ustream_write(us, data, len, false); + if (ustream_pending_data(us, true)) { + cl->dispatch.data_blocked = true; + us->notify_write = proc_relay_write_cb; + } } static void proc_data_done(struct client *cl) @@ -250,7 +266,7 @@ static void proc_data_done(struct client *cl) struct ustream *us = &cl->dispatch.proc.r.sfd.stream; if (ustream_pending_data(us, true)) { - us->notify_write = proc_relay_write_cb; + us->notify_write = proc_relay_write_close_cb; return; } |