uclient-http: allow .header_done() callback to reset the connection
authorFelix Fietkau <nbd@openwrt.org>
Tue, 14 Apr 2015 21:01:53 +0000 (23:01 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 14 Apr 2015 21:01:53 +0000 (23:01 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
uclient-http.c

index eb69702fb287470d9abbe2b6d4a6679da48dea73..7e930d7e5ed019a66b8dbf901aab685b0f720d7d 100644 (file)
@@ -73,6 +73,7 @@ struct uclient_http {
        struct ustream_ssl ussl;
 
        struct uloop_timeout disconnect_t;
+       unsigned int seq;
 
        bool ssl_require_validation;
        bool ssl;
@@ -196,6 +197,7 @@ static void uclient_notify_eof(struct uclient_http *uh)
 
 static void uclient_http_reset_state(struct uclient_http *uh)
 {
+       uh->seq++;
        uclient_backend_reset_state(&uh->uc);
        uh->read_chunked = -1;
        uh->content_length = -1;
@@ -641,6 +643,7 @@ error:
 static void __uclient_notify_read(struct uclient_http *uh)
 {
        struct uclient *uc = &uh->uc;
+       unsigned int seq = uh->seq;
        char *data;
        int len;
 
@@ -675,6 +678,9 @@ static void __uclient_notify_read(struct uclient_http *uh)
                        *sep = 0;
                        cur_len = sep + 2 - data;
                        uclient_parse_http_line(uh, data);
+                       if (seq != uh->seq)
+                               return;
+
                        ustream_consume(uh->us, cur_len);
                        len -= cur_len;