From f40ee925f06587399e3a1b755ede2ea87a7cc67f Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 3 Sep 2018 20:53:10 -0400 Subject: fix bug: rewinding send buffer should push to the front --- src/conn.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/conn.cpp b/src/conn.cpp index 2a7735b..d650b76 100644 --- a/src/conn.cpp +++ b/src/conn.cpp @@ -60,7 +60,7 @@ void ConnPool::Conn::send_data(evutil_socket_t fd, short events) { if (ret < 1) /* nothing is sent */ { /* rewind the whole buff_seg */ - send_buffer.push(std::move(buff_seg)); + send_buffer.rewind(std::move(buff_seg)); if (ret < 0 && errno != EWOULDBLOCK) { SALTICIDAE_LOG_INFO("reason: %s", strerror(errno)); @@ -69,13 +69,9 @@ void ConnPool::Conn::send_data(evutil_socket_t fd, short events) { } } else - { /* rewind the leftover */ - bytearray_t left_over; - left_over.resize(size); - memmove(left_over.data(), buff_seg.data() + ret, size); - send_buffer.push(std::move(left_over)); - } + send_buffer.rewind( + bytearray_t(buff_seg.begin() + ret, buff_seg.end())); /* wait for the next write callback */ ready_send = false; ev_write.add(); -- cgit v1.2.3-70-g09d2