Skip to content
This repository has been archived by the owner on Apr 6, 2019. It is now read-only.

Commit

Permalink
reset response builder on disconnection #150
Browse files Browse the repository at this point in the history
  • Loading branch information
Cylix committed Feb 1, 2018
1 parent f390eef commit 5ec22db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions includes/cpp_redis/builders/reply_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class reply_builder {
//!
bool reply_available(void) const;

//!
//! reset the reply builder to its initial state (clear internal buffer and stages)
//!
void reset(void);

private:
//!
//! build reply using m_buffer content
Expand Down
6 changes: 6 additions & 0 deletions sources/builders/reply_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ reply_builder::operator<<(const std::string& data) {
return *this;
}

void
reply_builder::reset(void) {
m_builder = nullptr;
m_buffer.clear();
}

bool
reply_builder::build_reply(void) {
if (!m_buffer.size())
Expand Down
4 changes: 4 additions & 0 deletions sources/network/redis_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ redis_connection::disconnect(bool wait_for_removal) {

//! clear buffer
m_buffer.clear();
//! clear builder
m_builder.reset();

__CPP_REDIS_LOG(debug, "cpp_redis::network::redis_connection disconnected");
}
Expand Down Expand Up @@ -186,6 +188,8 @@ redis_connection::tcp_client_disconnection_handler(void) {
__CPP_REDIS_LOG(debug, "cpp_redis::network::redis_connection has been disconnected");
//! clear buffer
m_buffer.clear();
//! clear builder
m_builder.reset();
//! call disconnection handler
call_disconnection_handler();
}
Expand Down
2 changes: 1 addition & 1 deletion tacopie

0 comments on commit 5ec22db

Please sign in to comment.