HBPVIS / ZeroEQ

Cross-platform C++ library for fast binary and REST messaging
https://hbpvis.github.io/
Other
41 stars 25 forks source link

Receiver: return after timeout even if more data is pending #218

Closed eile closed 7 years ago

rdumusc commented 7 years ago

@eile @tribal-tec this commit breaks the http server in Tide, which is based on QSocketNotifier. I don't understand what you were trying to achieve here. Doing a non-blocking receive() using timeout=0 is not allowed anymore? Please advise.

eile commented 7 years ago

Seems there is no test for this. :P

This PR fixed that if the publisher is faster than the subscriber, a subscriber.receive(timeout) would never return, even after the timeout expired.

This changes the behaviour of receive(0) which now will do one receive, not all (which is in line with the doc/spec).

Not sure why/how this breaks the QSocketNotifier.

rdumusc commented 7 years ago

OK, part of the problem is that the timeout is now used for two purposes:

I think the reason it breaks in Tide is because the zmq socket notifies only once data first arrives (edge triggered), not as long as there is data to read (level triggered). So now it only processes one message, exceeds the limit of 0 millisecond and stops instead of reading all messages.

tribal-tec commented 7 years ago

Wouldn't while(receive(0)); solve it then in Tide to process all pending?

rdumusc commented 7 years ago

seeing that receive() returns false when no messages were processed probably yes, I will test that next week