zeromq / libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
https://www.zeromq.org
Mozilla Public License 2.0
9.62k stars 2.35k forks source link

`ZMQ_POLLIN` interacts somewhat badly with `ZMQ_REQ_CORRELATE` #4527

Open mitchellwrosen opened 1 year ago

mitchellwrosen commented 1 year ago

Issue description

When using ZMQ_REQ_CORRELATE, it is possible to observe the following sequence of events:

  1. Send request 1
  2. Send request 2
  3. Poll on ZMQ_POLLIN
  4. Receive a reply to request 1
  5. Poll returns, indicating there's something to read
  6. Read blocks after throwing away the reply, because it wasn't a reply to the latest request

I think if for technical reasons it's not possible to refrain from returning from zmq_poll here, we could at least document this as a possibility.

Thank you!