http: do not call uclient_http_disconnect from uclient_notify_eof directly
authorFelix Fietkau <nbd@openwrt.org>
Thu, 4 Sep 2014 11:10:59 +0000 (13:10 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 4 Sep 2014 11:11:01 +0000 (13:11 +0200)
Depending on the context, it can lead to crashes

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
uclient-http.c

index 1569cda34aa6c3e4167fac4f38137c8da6d4ee90..ff1bcc464a75f2d686a70256f24acc7f93238ba7 100644 (file)
@@ -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,