Skip to content

Commit

Permalink
Connection: Check socket is closed before read/write
Browse files Browse the repository at this point in the history
  • Loading branch information
htfy96 committed Jan 27, 2017
1 parent 7f2ca79 commit 458d177
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/c10k/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace c10k
void Connection::handle_read()
{
logger->trace("Handling read, there are {} items in r_buffer", r_buffer.size());
if (is_closed())
throw std::runtime_error("Read when socket is closed");
while (!r_buffer.empty()) // can read
{
detail::ConnRReq &req = r_buffer.front();
Expand Down Expand Up @@ -92,6 +94,8 @@ namespace c10k
void Connection::handle_write()
{
logger->trace("Handling write, there are {} items in w_buffer", w_buffer.size());
if (is_closed())
throw std::runtime_error("Write when socket is closed");
while (!w_buffer.empty()) // can write
{
detail::ConnWReq &req = w_buffer.front();
Expand Down

0 comments on commit 458d177

Please sign in to comment.