http: call ustream_poll if not enough read data is available
authorFelix Fietkau <nbd@nbd.name>
Wed, 27 Mar 2024 21:29:38 +0000 (22:29 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 29 Mar 2024 14:09:36 +0000 (15:09 +0100)
Avoids having to go through another uloop notification for the next read.

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

index 83c268f239137423741eeac8704eba64a3d2c36c..33f651301d4e373751808c2c517ebbfee4df53cd 100644 (file)
@@ -1077,8 +1077,12 @@ uclient_http_read(struct uclient *cl, char *buf, unsigned int len)
                return 0;
 
        data = ustream_get_read_buf(uh->us, &read_len);
-       if (!data || !read_len)
-               return 0;
+       if (!data || !read_len) {
+               ustream_poll(uh->us);
+               data = ustream_get_read_buf(uh->us, &read_len);
+               if (!data || !read_len)
+                       return 0;
+       }
 
        data_end = data + read_len;
        read_len = 0;