Enable to write more data then defined in SSL_MAX_CONTENT_LEN.
Signed-off-by: Luka Perkov <luka@openwrt.org>
__hidden int __ustream_ssl_write(struct ustream_ssl *us, const char *buf, int len)
{
void *ssl = us->ssl;
- int ret = ssl_write(ssl, (const unsigned char *) buf, len);
+ int done = 0, ret = 0;
- if (ret < 0) {
- if (ssl_do_wait(ret))
- return 0;
+ while (done != len) {
+ ret = ssl_write(ssl, (const unsigned char *) buf + done, len - done);
- ustream_ssl_error(us, ret);
- return -1;
+ if (ret < 0) {
+ if (ssl_do_wait(ret))
+ return done;
+
+ ustream_ssl_error(us, ret);
+ return -1;
+ }
+
+ done += ret;
}
- return ret;
+ return done;
}
__hidden int __ustream_ssl_read(struct ustream_ssl *us, char *buf, int len)