Skip to content

fix(cpp): make the ZMQ transport build and recover from a missed reply - #633

Open
Sahil-u07 wants to merge 5 commits into
ControlCore-Project:devfrom
Sahil-u07:fix/cpp-zmq-transport
Open

Sahil-u07 wants to merge 5 commits into
ControlCore-Project:devfrom
Sahil-u07:fix/cpp-zmq-transport

Conversation

@Sahil-u07

Copy link
Copy Markdown
Contributor

Fixes #632

The C++ ZMQ transport didn't compile because concore_base.hpp included <zmq.hpp> inside namespace concore_base. I moved the include above the namespace, still behind CONCORE_USE_ZMQ.

Once it built, the new test showed the REQ socket had the same problem Java (#577) and Python (#599) had, so C++ REQ ports now set ZMQ_REQ_RELAXED and ZMQ_REQ_CORRELATE too.

Commits:

  • include fix, plus TestConcoreZmq.cpp with a request/reply round trip between two Concore objects
  • REQ recovery, with the C++ version of the Python test from fix: let Python REQ ports recover after a receive timeout #599
  • the two write_zmq cases from the conformance fixtures. The C++ notes in the matrix now point to this test, they said it was only checked by reading the code
  • CI builds and runs the test on Linux, Windows and macOS. Linux also runs it against concoredocker.hpp

I also switched the existing setsockopt() calls to set(zmq::sockopt::...) because setsockopt() is deprecated in cppzmq. That needs cppzmq 4.7 or newer.

The C++ jobs on dev currently fail on the two tryparam comma tests in TestConcoreHpp.cpp, #629 fixes that. With that one line applied, all three C++ jobs pass in my fork.

Before (dev)

before

After

after

concore_base.hpp included <zmq.hpp> inside namespace concore_base, so
every standard header it pulls in got wrapped in that namespace too.
Building any C++ node with -DCONCORE_USE_ZMQ failed with ~700 errors,
for both concore.hpp and concoredocker.hpp.

Moved the include above the namespace, still behind CONCORE_USE_ZMQ.
Added TestConcoreZmq.cpp, which sends a request and a reply between two
Concore objects over a local socket and checks values and simtime. Build
it with -DTEST_DOCKER_HEADER to run it against concoredocker.hpp.
Same problem Java (ControlCore-Project#577) and Python (ControlCore-Project#599) had: once a REQ socket misses
a reply, every later send fails with "Operation cannot be accomplished
in current state", so the node can never write on that port again.

Set ZMQ_REQ_RELAXED and ZMQ_REQ_CORRELATE on REQ sockets, like the other
two runtimes. Also moved the existing options to set(zmq::sockopt::...)
since setsockopt() is deprecated in cppzmq and warns with -Wall.

The new test is the C++ version of the Python one: the first reply never
comes, the second request still goes out and the late reply is dropped.
The matrix marked both C++ write_zmq rows as passing from reading the
code, since there was no ZMQ test. Added both fixture cases to
TestConcoreZmq.cpp: a list write sends [simtime+delta, ...] and leaves
simtime alone, and a string write is sent as is. Updated the two notes
to point to the test.
Nothing built C++ with -DCONCORE_USE_ZMQ before, which is how the
namespace include went unnoticed. Installs cppzmq on each runner and
runs TestConcoreZmq.cpp. The Linux job also runs it against
concoredocker.hpp.
zmq::sockopt, used for the socket options now, came in cppzmq 4.7.
@Sahil-u07

Copy link
Copy Markdown
Contributor Author

Hi @pradeeban! The C++ checks are red only because of the tryparam tests that are failing on dev too, #629 fixes those. I'll rebase once that's merged so the new ZMQ tests run here as well. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant