* wbuf
* ====
*/
-static int wbuf_flush(struct json_write_buf *wbuf);
+static int wbuf_flush(struct json_write_buf *wbuf, int full);
static int wbuf_init(struct json_write_buf *wbuf, BIO *bio, size_t alloc)
{
static ossl_inline int wbuf_write_char(struct json_write_buf *wbuf, char c)
{
if (wbuf_avail(wbuf) == 0) {
- if (!wbuf_flush(wbuf))
+ if (!wbuf_flush(wbuf, /*full=*/0))
return 0;
}
}
/* Flush write buffer, returning 0 on I/O failure. */
-static int wbuf_flush(struct json_write_buf *wbuf)
+static int wbuf_flush(struct json_write_buf *wbuf, int full)
{
size_t written = 0, total_written = 0;
}
wbuf->cur = 0;
+
+ if (full)
+ (void)BIO_flush(wbuf->bio); /* best effort */
+
return 1;
}
int ossl_json_flush(OSSL_JSON_ENC *json)
{
- return wbuf_flush(&json->wbuf);
+ return wbuf_flush(&json->wbuf, /*full=*/1);
}
int ossl_json_set0_sink(OSSL_JSON_ENC *json, BIO *bio)