diff options
author | Determinant <[email protected]> | 2018-09-12 10:32:51 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2018-09-12 10:32:51 -0400 |
commit | 0eea9ddc7cfb2820295dd87aed3dc911a100ecde (patch) | |
tree | ae641aa20713d15577776af64d686c1d4ee949ae | |
parent | f40ee925f06587399e3a1b755ede2ea87a7cc67f (diff) |
no need to cut the segs for the send_buffer
-rw-r--r-- | include/salticidae/conn.h | 6 | ||||
-rw-r--r-- | src/conn.cpp | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/include/salticidae/conn.h b/include/salticidae/conn.h index 53d51a3..f290e3d 100644 --- a/include/salticidae/conn.h +++ b/include/salticidae/conn.h @@ -114,6 +114,12 @@ class SegBuffer { _size += data.size(); buffer.push_back(buffer_entry_t(std::move(data))); } + + bytearray_t move_pop() { + auto res = std::move(buffer.front().data); + buffer.pop_front(); + return std::move(res); + } bytearray_t pop(size_t len) { bytearray_t res; diff --git a/src/conn.cpp b/src/conn.cpp index d650b76..0607ed3 100644 --- a/src/conn.cpp +++ b/src/conn.cpp @@ -48,9 +48,9 @@ void ConnPool::Conn::send_data(evutil_socket_t fd, short events) { if (!(events & EV_WRITE)) return; auto conn = self(); /* pin the connection */ ssize_t ret = seg_buff_size; - while (!send_buffer.empty() && ret == (ssize_t)seg_buff_size) + while (!send_buffer.empty()) { - bytearray_t buff_seg = send_buffer.pop(seg_buff_size); + bytearray_t buff_seg = send_buffer.move_pop(); ssize_t size = buff_seg.size(); ret = send(fd, buff_seg.data(), size, MSG_NOSIGNAL); SALTICIDAE_LOG_DEBUG("socket sent %zd bytes", ret); |