mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-28 12:30:58 +00:00
flush TLS buffer
This commit is contained in:
1 parent
5726e680ec
commit
1f48b1ca65
9 files changed
+62
-10
No files matched your search
+8
-1
@@ -204,11 +204,18 @@ long mg_tls_send(struct mg_connection *c, const void *buf, size_t len) {
|
||||
tls->throttled_buf = (unsigned char *)buf; // MbedTLS code actually ignores
|
||||
tls->throttled_len = len; // these, but let's play API rules
|
||||
return (long) len; // already encripted that when throttled
|
||||
}
|
||||
} // if last chunk fails to be sent, it needs to be flushed
|
||||
if (n <= 0) return MG_IO_ERR;
|
||||
return n;
|
||||
}
|
||||
|
||||
void mg_tls_flush(struct mg_connection *c) {
|
||||
if (c->is_tls_throttled) {
|
||||
long n = mbedtls_ssl_write(&tls->ssl, tls->throttled_buf, tls->throttled_len);
|
||||
c->is_tls_throttled = (n == MBEDTLS_ERR_SSL_WANT_READ || n == MBEDTLS_ERR_SSL_WANT_WRITE);
|
||||
}
|
||||
}
|
||||
|
||||
void mg_tls_ctx_init(struct mg_mgr *mgr) {
|
||||
struct mg_tls_ctx *ctx = (struct mg_tls_ctx *) calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
|
||||
Reference in new issue
Block a user