12 #define BUFFERS_PRIVATE
34 tor_assert(CHUNK_REMAINING_CAPACITY(chunk) >= at_most);
35 read_result =
tor_tls_read(tls, CHUNK_WRITE_PTR(chunk), at_most);
38 buf->datalen += read_result;
39 chunk->datalen += read_result;
70 size_t total_read = 0;
72 check_no_tls_errors();
75 return TOR_TLS_ERROR_MISC;
77 return TOR_TLS_ERROR_MISC;
79 while (at_most > total_read) {
80 size_t readlen = at_most - total_read;
82 if (!buf->tail || CHUNK_REMAINING_CAPACITY(buf->tail) < MIN_READ_LEN) {
84 if (readlen > chunk->memlen)
85 readlen = chunk->memlen;
87 size_t cap = CHUNK_REMAINING_CAPACITY(buf->tail);
99 return (
int)total_read;
129 log_debug(
LD_NET,
"flushed %d bytes, %d remain.",
130 r,(
int)buf->datalen);
144 flushlen = buf->datalen;
146 sz = (ssize_t) flushlen;
150 check_no_tls_errors();
155 if ((ssize_t)buf->head->datalen >= sz)
158 flushlen0 = buf->head->datalen;
chunk_t * buf_add_chunk_with_capacity(buf_t *buf, size_t capacity, int capped)
void buf_drain(buf_t *buf, size_t n)
Header file for buffers.c.
static int read_to_chunk_tls(buf_t *buf, chunk_t *chunk, tor_tls_t *tls, size_t at_most)
static int flush_chunk_tls(tor_tls_t *tls, buf_t *buf, chunk_t *chunk, size_t sz)
int buf_read_from_tls(buf_t *buf, tor_tls_t *tls, size_t at_most)
int buf_flush_to_tls(buf_t *buf, tor_tls_t *tls, size_t flushlen)
Header for buffers_tls.c.
Integer definitions used throughout Tor.
int tor_tls_read(tor_tls_t *tls, char *cp, size_t len)
int tor_tls_write(tor_tls_t *tls, const char *cp, size_t n)
size_t tor_tls_get_forced_write_size(tor_tls_t *tls)
Macros to manage assertions, fatal and non-fatal.
#define IF_BUG_ONCE(cond)