diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-11-21 22:50:30 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-11-21 22:50:31 +0100 |
commit | cd66639800ee2882a0867ec54868502eb9b893d8 (patch) | |
tree | b1fae68cc97bab2407e7b8584d39bc664a37fd92 /client.c | |
parent | aec143997b9aba65f7ea702d7cd42b553afe335f (diff) |
uhttpd: fix crashes in the ubus plugin
The ubus plugin calls blocking ubus functions that loop back into
uloop_run. Protect the client data structure with refcounting to ensure
that the outer uloop_run call does not clean up the data that the inner
uloop_run call is still processing.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -463,6 +463,11 @@ void uh_client_read_cb(struct client *cl) static void client_close(struct client *cl) { + if (cl->refcount) { + cl->state = CLIENT_STATE_CLEANUP; + return; + } + client_done = true; n_clients--; uh_dispatch_done(cl); @@ -482,7 +487,7 @@ void uh_client_notify_state(struct client *cl) { struct ustream *s = cl->us; - if (!s->write_error) { + if (!s->write_error && cl->state != CLIENT_STATE_CLEANUP) { if (cl->state == CLIENT_STATE_DATA) return; |