Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server expectText stuck #1563

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably get current timeout and reset the previous value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I didn't think about that, but now I checked and there is no easy way to get that: no getReadTimeout() or haveReadTimeout() method in the InputStream. Do you think is this the case to add one?

if (lsuccess) {
messageLen -= result.length()+1;
}
Expand Down