zeromq / clrzmq4

ZeroMQ C# namespace (.NET and mono, Windows, Linux and MacOSX, x86 and amd64)
GNU Lesser General Public License v3.0
241 stars 112 forks source link

Correct handling of timeout during polling #212

Open TillAlex opened 2 years ago

TillAlex commented 2 years ago

During debugging of the case when timeout elapses while polling I found a strange behaviour:

In https://github.com/zeromq/clrzmq4/blob/e5471f96b8db833ccc5df5e4e99b25291718f191/ZPollItems.Win32.cs#L79

the result of zmq_poll is compared to -1. If it's not -1 the method return true. In the case when the timeout elapsed the return value of zmq_poll is 0 and true is returned.

In ZPollItems.Poll

https://github.com/zeromq/clrzmq4/blob/e5471f96b8db833ccc5df5e4e99b25291718f191/ZPollItems.cs#L171

the return value is used to decided if PollManyResults has to be called. But why should we try to read the results if no events have been signaled?

Can anyone have a look into this if the code is working as intended?