From b63202344bf2e01c2054858212a9737f39170a15 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 4 Sep 2014 13:10:59 +0200 Subject: [PATCH] http: do not call uclient_http_disconnect from uclient_notify_eof directly Depending on the context, it can lead to crashes Signed-off-by: Felix Fietkau --- uclient-http.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/uclient-http.c b/uclient-http.c index 1569cda..ff1bcc4 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -159,6 +159,18 @@ static void uclient_http_error(struct uclient_http *uh, int code) uclient_backend_set_error(&uh->uc, code); } +static void uclient_http_request_disconnect(struct uclient *cl) +{ + struct uclient_http *uh = container_of(cl, struct uclient_http, uc); + + if (!uh->us) + return; + + uh->eof = true; + uh->disconnect = true; + uloop_timeout_set(&uh->disconnect_t, 1); +} + static void uclient_notify_eof(struct uclient_http *uh) { struct ustream *us = uh->us; @@ -177,7 +189,7 @@ static void uclient_notify_eof(struct uclient_http *uh) uclient_backend_set_eof(&uh->uc); if (uh->connection_close) - uclient_http_disconnect(uh); + uclient_http_request_disconnect(&uh->uc); } static void uclient_http_reset_state(struct uclient_http *uh) @@ -1047,18 +1059,6 @@ int uclient_http_set_ssl_ctx(struct uclient *cl, const struct ustream_ssl_ops *o return 0; } -static void uclient_http_request_disconnect(struct uclient *cl) -{ - struct uclient_http *uh = container_of(cl, struct uclient_http, uc); - - if (!uh->us) - return; - - uh->eof = true; - uh->disconnect = true; - uloop_timeout_set(&uh->disconnect_t, 1); -} - const struct uclient_backend uclient_backend_http = { .prefix = uclient_http_prefix, -- 2.30.2