Skip to content

Commit

Permalink
Make readMessage bail if it can't read a message instead of blocking …
Browse files Browse the repository at this point in the history
…forever (#168)

* Make readMessage bail if it can't read a message instead of blocking forever

* Only change TerminalClient's call to readMessage
  • Loading branch information
MisterTea authored Jan 16, 2019
1 parent c0c0fe7 commit 15a14d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/base/Connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class Connection {

virtual ~Connection();

virtual bool read(string* buf);
virtual bool write(const string& buf);

virtual bool readMessage(string* buf);
virtual void writeMessage(const string& message);

Expand Down Expand Up @@ -63,8 +66,6 @@ class Connection {
inline bool isShuttingDown() { return shuttingDown; }

protected:
virtual bool read(string* buf);
virtual bool write(const string& buf);
bool recover(int newSocketFd);

shared_ptr<SocketHandler> socketHandler;
Expand Down
2 changes: 1 addition & 1 deletion src/terminal/TerminalClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ int main(int argc, char** argv) {
while (globalClient->hasData()) {
VLOG(4) << "GlobalClient has data";
string packetTypeString;
if (!globalClient->readMessage(&packetTypeString)) {
if (!globalClient->read(&packetTypeString)) {
break;
}
if (packetTypeString.length() != 1) {
Expand Down

0 comments on commit 15a14d2

Please sign in to comment.