From 8f76e5d8823b684d91e19f8efebe5579e00c8c48 Mon Sep 17 00:00:00 2001 From: Determinant Date: Sun, 13 Oct 2019 15:32:16 -0400 Subject: add len() --- include/salticidae/buffer.h | 1 + include/salticidae/network.h | 2 +- src/conn.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/salticidae/buffer.h b/include/salticidae/buffer.h index c7b11dd..35d10b8 100644 --- a/include/salticidae/buffer.h +++ b/include/salticidae/buffer.h @@ -108,6 +108,7 @@ class SegBuffer { } size_t size() const { return _size; } + size_t len() const { return buffer.size(); } bool empty() const { return buffer.empty(); } void clear() { diff --git a/include/salticidae/network.h b/include/salticidae/network.h index 5b4cd7d..c3b9e79 100644 --- a/include/salticidae/network.h +++ b/include/salticidae/network.h @@ -584,7 +584,7 @@ void MsgNetwork::on_read(const ConnPool::conn_t &_conn) { } } } - if (conn->ready_recv && recv_buffer.size() < conn->max_recv_buff_size) + if (conn->ready_recv && recv_buffer.len() < conn->max_recv_buff_size) { /* resume reading from socket */ conn->ev_socket.del(); diff --git a/src/conn.cpp b/src/conn.cpp index 6a44a36..5b01745 100644 --- a/src/conn.cpp +++ b/src/conn.cpp @@ -106,7 +106,7 @@ void ConnPool::Conn::_recv_data(const conn_t &conn, int fd, int events) { ssize_t ret = seg_buff_size; while (ret == (ssize_t)seg_buff_size) { - if (conn->recv_buffer.size() >= conn->max_recv_buff_size) + if (conn->recv_buffer.len() >= conn->max_recv_buff_size) { /* receive buffer is full, disable READ event */ conn->ev_socket.del(); @@ -195,7 +195,7 @@ void ConnPool::Conn::_recv_data_tls(const conn_t &conn, int fd, int events) { auto &tls = conn->tls; while (ret == (ssize_t)seg_buff_size) { - if (conn->recv_buffer.size() >= conn->max_recv_buff_size) + if (conn->recv_buffer.len() >= conn->max_recv_buff_size) { /* receive buffer is full, disable READ event */ conn->ev_socket.del(); -- cgit v1.2.3-70-g09d2