tls/m_tls.c
/*! Flush the write buffer to the underlying IO object.
 *
 *  We are buffering all writes to try to aggregate multiple writes into larger
 *  chunks and also to work around possible issues with WANT_WRITE style
 *  retries.
 *
 *  This function must be called after any of these functions:
 *   - SSL_connect()
 *   - SSL_accept()
 *   - SSL_shutdown()
 *   - SSL_read()
 *   - SSL_write()
 */
Flush the write buffer to the underlying IO object.
We are buffering all writes to try to aggregate multiple writes into larger
chunks and also to work around possible issues with WANT_WRITE style
retries.


Flush the write buffer to the underlying IO object . We are buffering all writes to try to aggregate multiple writes into larger chunks and also to work around possible issues with WANT_WRITE style retries .
static void M_io_tls_flush_write_buf(M_io_layer_t *layer)
{
#ifdef TLS_BUFFER_WRITES
	M_io_handle_t *handle = M_io_layer_get_handle(layer);
	M_io_error_t   err;
	size_t         write_len;
	if (M_buf_len(handle->write_buf) == 0)
		return;
	write_len           = M_buf_len(handle->write_buf);
	err                 = M_io_layer_write(M_io_layer_get_io(layer), M_io_layer_get_index(layer)-1, (const unsigned char *)M_buf_peek(handle->write_buf), &write_len, NULL);
	handle->last_io_err = err;
	if (err != M_IO_ERROR_SUCCESS) {
		return;
	}
	if (write_len == M_buf_len(handle->write_buf)) {
	} else {
	}
	M_buf_drop(handle->write_buf, write_len);
	if (M_buf_len(handle->write_buf) == 0) {
		M_io_layer_softevent_add(layer, M_FALSE, M_EVENT_TYPE_WRITE, M_IO_ERROR_SUCCESS);
	}
#else
	(void)layer;
#endif
}
static void M_io_tls_flush_write_buf ( M_io_layer_t * layer ) { #ifdef TLS_BUFFER_WRITES M_io_handle_t * handle = M_io_layer_get_handle ( layer ) ; M_io_error_t err ; size_t write_len ; if ( M_buf_len ( handle -> write_buf ) == 0 ) return ; write_len = M_buf_len ( handle -> write_buf ) ; err = M_io_layer_write ( M_io_layer_get_io ( layer ) , M_io_layer_get_index ( layer ) - 1 , ( const unsigned char * ) M_buf_peek ( handle -> write_buf ) , & write_len , NULL ) ; handle -> last_io_err = err ; if ( err != M_IO_ERROR_SUCCESS ) { return ; } if ( write_len == M_buf_len ( handle -> write_buf ) ) { } else { } M_buf_drop ( handle -> write_buf , write_len ) ; if ( M_buf_len ( handle -> write_buf ) == 0 ) { M_io_layer_softevent_add ( layer , M_FALSE , M_EVENT_TYPE_WRITE , M_IO_ERROR_SUCCESS ) ; } #else ( void ) layer ; #endif }
Flush the write buffer to the underlying IO object.
Flush the write buffer to the underlying IO object .
//M_printf("%s(): %p write flush failed\n", __FUNCTION__, layer); //		M_printf("%s(): %p flushed %zu bytes of %zu\n", __FUNCTION__, layer, write_len, M_buf_len(handle->write_buf)); /* If the entire buffer flushed, notify we can write more */