Skip to content

Commit

Permalink
fix server stuck on uncomplete text read
Browse files Browse the repository at this point in the history
  • Loading branch information
damn1 authored and drdanz committed May 4, 2018
1 parent 3dac873 commit 7b3e7c6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libYARP_OS/include/yarp/os/impl/NameserCarrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class yarp::os::impl::NameserTwoWayStream : public TwoWayStream, InputStream
virtual void beginPacket() override;
virtual void endPacket() override;

virtual bool setReadTimeout(double timeout) override;

using yarp::os::InputStream::read;
virtual YARP_SSIZE_T read(const yarp::os::Bytes& b) override;
};
Expand Down
5 changes: 5 additions & 0 deletions src/libYARP_OS/src/NameserCarrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ void yarp::os::impl::NameserTwoWayStream::endPacket() {
delegate->endPacket();
}

bool yarp::os::impl::NameserTwoWayStream::setReadTimeout(double timeout)
{
return delegate->getInputStream().setReadTimeout(timeout);
}

YARP_SSIZE_T yarp::os::impl::NameserTwoWayStream::read(const Bytes& b) {
// assume it is ok for name_ser to go byte-by-byte
// since this protocol will be phased out
Expand Down
2 changes: 2 additions & 0 deletions src/libYARP_OS/src/StreamConnectionReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ yarp::os::ConstString StreamConnectionReader::expectText(int terminatingChar)
}
yAssert(in!=nullptr);
bool lsuccess = false;
in->setReadTimeout(2.0);
ConstString result = in->readLine(terminatingChar, &lsuccess);
in->setReadTimeout(0.0);
if (lsuccess) {
messageLen -= result.length()+1;
}
Expand Down

0 comments on commit 7b3e7c6

Please sign in to comment.