Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
PHZ76 committed Sep 2, 2019
1 parent b8eb38f commit 67575ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/net/BufferReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ class BufferReader
return crlf == beginWrite() ? nullptr : crlf;
}

const char* findLastCrlfCrlf() const
{
char crlfCrlf[] = "\r\n\r\n";
const char* crlf = std::find_end(peek(), beginWrite(), crlfCrlf, crlfCrlf + 4);
return crlf == beginWrite() ? nullptr : crlf;
}

void retrieveAll()
{
_writerIndex = 0;
Expand Down
8 changes: 1 addition & 7 deletions src/net/TcpConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ void TcpConnection::handleWrite()
if (_isClosed)
return;

if (!_mutex.try_lock())
{
return;
}
std::lock_guard<std::mutex> lock(_mutex);

int ret = 0;
bool empty = false;
Expand All @@ -112,7 +109,6 @@ void TcpConnection::handleWrite()
if (ret < 0)
{
this->close();
_mutex.unlock();
return;
}
empty = _writeBufferPtr->isEmpty();
Expand All @@ -131,8 +127,6 @@ void TcpConnection::handleWrite()
_channelPtr->enableWriting();
_taskScheduler->updateChannel(_channelPtr);
}

_mutex.unlock();
}

void TcpConnection::close()
Expand Down

0 comments on commit 67575ac

Please sign in to comment.