aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2018-09-03 20:53:10 -0400
committerDeterminant <[email protected]>2018-09-03 20:53:10 -0400
commitf40ee925f06587399e3a1b755ede2ea87a7cc67f (patch)
treedeb85ed2cb05b54448438e4f1181273ff8418056 /src
parent3145cb1ae49ef94aecf8688329545e912e67a25f (diff)
fix bug: rewinding send buffer should push to the front
Diffstat (limited to 'src')
-rw-r--r--src/conn.cpp10
1 files changed, 3 insertions, 7 deletions
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();