Commit Graph

1231 Commits

Author SHA1 Message Date
Claude
268fcafcc6 feat(cmake): add the FairMQ::FairMQ alias target to the build tree
- Projects that add FairMQ with add_subdirectory() use the same target
  name as projects that use the installed package

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 10:21:32 +01:00
Claude
0dfbb73d86 refactor(cmake): use PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR
- CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR point to the top-level project
  and break add_subdirectory() and FetchContent
- Find the helper modules relative to the CMakeLists.txt that includes them
- Replace @CMAKE_BINARY_DIR@ in the example test scripts

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 10:21:32 +01:00
Claude
2061b8636d fix(cmake): drop misspelled BOOST_ASIO_HAS_HAS_STD_CHRONO definition
- The macro name is a typo and has no effect
- It was exported to every consumer as a PUBLIC definition

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 10:21:31 +01:00
Claude
25f44828d7 docs(shmem): document that sender and receiver must use the same kind of type
- shmem uses one metadata format for a single message and another for
  a multipart message; Receive(Parts) of a single send, or
  Receive(MessagePtr) of a multipart send, gives wrong metadata or a
  crash
- Add a sender/receiver table to the messages page of the
  documentation and a note to Channel::Receive()
- Update the source line links into Channel.h
- Keep PartsTransfer.SingleSendMultipartReceive disabled: a fix
  changes the shmem wire format

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:42:53 +01:00
Claude
102cdaf40e fix(shmem): refuse to send an empty Parts
- zeromq refuses an empty Parts with TransferCode::error; shmem sent a
  message with zero parts and returned 0, and the receiver got a
  Receive() with zero parts
- Refuse it in shmem too, with the same warning
- Enable PartsTransfer.EmptyPartsIsRefused
- Update the documentation pages that described the defect, and
  the source line links into the changed files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:42:53 +01:00
Claude
50387fe5cc fix(shmem): fill the result of Monitor::GetDebugInfo()
- The function reserved each result vector and then wrote to
  result[segment][handle], past the end of the vector: it returned
  empty vectors and corrupted the heap
- Append one entry per buffer, in the order of the buffer offset
- Check the debug map for null before its first use
- Name the map entries (segment id, offset, buffer) instead of
  .first and .second
- Enable Monitor.GetDebugInfo (needs FAIRMQ_DEBUG_MODE)
- Update the documentation page that described the defect

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:42:53 +01:00
Claude
47784207d6 fix(control): handle all keys of one input in interactive mode
- The REPL polled the stdin fd, then read one key with std::cin; the
  other keys of the same read stayed in the std::cin buffer, and
  poll() did not report them again
- Read one key with read(2), so poll() reports each key that is not
  handled yet; skip whitespace, as operator>> did
- Stop reading at end of input: before, a closed stdin (e.g.
  < /dev/null) made the loop print the help without a pause
- Enable ControlPlugin.SeveralKeysInOneInput
- Update the documentation pages that described the defect, and
  the source line links into the changed files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:42:53 +01:00
Claude
9b6662f6a9 fix(device): print --print-channels and --version output to stdout
- DeviceRunner sets the console log severity to "nolog" for both
  options, but printed their output with LOGV(info), so both options
  printed nothing
- Add Device::PrintRegisteredChannels(std::ostream&) for the
  machine-readable channel list; the version goes to std::cout, like
  --help and --print-options
- Enable DeviceRunner.PrintChannels and DeviceRunner.Version
- Update the documentation pages that described the defect, and
  the source line links into the changed files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:42:53 +01:00
Claude
b70595cebe fix(config): reject channel properties of the wrong type
- ptree::get(key, default) returns the default also for a value that
  does not convert, so a typo (e.g. sndBufSize=big) silently gave the
  default value
- Use the default only for a missing key; throw ParserError with the
  key and the value for a value of the wrong type
- Rethrow parser errors in the config plugin: before, the device
  logged the error and continued without its channel configuration
- Enable JSONParser and SuboptParser RejectsValuesOfTheWrongType
- Update the documentation pages that described the defect, and
  the source line links into the changed files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:42:53 +01:00
Claude
442b203d0d fix(fsm): refuse all transitions in the Error state
- The Error state is a terminate state: the state machine ignores all
  events in it and calls no action, so ChangeState() returned the
  result of the previous transition (ErrorFound: true)
- Return false for each transition in the Error state, except for
  ErrorFound: the device is already in the Error state, so callers
  such as ChangeStateOrThrow(ErrorFound) in Device::RunWrapper() or
  in user code do not throw
- Enable StateMachine.RefusesTransitionsInError
- Update the documentation pages that described the defect, and
  the source line links into the changed files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:42:53 +01:00
Claude
93dfef1a74 docs: replace the Markdown docs with links to the site
- Remove docs/*.md and docs/images/
- Rewrite README.md: description, install, first steps and links to
  the site
- Replace the READMEs of the examples, fairmq/shmem, fairmq/devices and
  fairmq/tools with links to the site pages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 01:21:28 +01:00
Claude
f50b1f0e39 feat(tools): add an execute() overload with a deadline
- a child process that hangs blocked execute() until the caller was
  killed (e.g. by the ctest timeout); the child then ran on as an
  orphan, with its shm segments and ipc files
- the new overload kills the child with SIGKILL after the timeout and
  logs the timeout in the captured output
- keep the old overload (no limit) for compatibility

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 17:00:01 +01:00
Claude
f1312aefe3 fix(shmem): release region blocks of reused messages to their own region
- Remove the `fRegionPtr` member of `shmem::Message`. It cached the
  region of the last `GetData()`, `GetRefCount()` or `Copy()` call.
  `Rebuild()` and `Socket::Receive()` did not reset it.
- When a message received a block of region A, was read, rebuilt, and
  then received a block of region B, its release went to region A.
  Region A got a wrong callback and region B never got its block back.
- Look up the region with `Manager::GetRegionFromCache()` where it is
  needed. The lookup is a thread-local fast path.
- `sizeof(shmem::Message)` goes from 80 to 72 bytes on LP64.

Refs: #477

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 15:11:03 +01:00
Claude
f4e265a562 fix(shmem): lock the region mutexes in one order
- GetRegion() locks the local region mutex first and then the
  session-wide shmem mutex; CreateRegion() locked them in the opposite
  order
- a thread that creates a region and a thread that opens a region of
  another process in the same session can deadlock (ABBA)
- lock the local region mutex first also in CreateRegion()
- add a regression test

Refs: #334
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:37:01 +01:00
Claude
139111a0c5 fix(shmem): do not hold region locks while region acks stop
- RemoveRegion() held the session-wide shmem mutex and the local region
  mutex while it joined the ack threads of the region
- the ack receiver calls the user callback for each outstanding ack
  during the linger period; a callback that calls into the transport
  (e.g. GetRegionInfo(), or a message destruction that opens a region)
  waits for one of these mutexes, and the destruction never ends
- the shmem mutex is shared by all processes of the session, so the
  other processes hang also, and new processes hang at startup
- stop the acks without a lock, then lock each mutex separately and
  only for the access to the shared data
- add a regression test

Refs: #334
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:37:01 +01:00
Claude
8900606bae fix(shmem): wake the region ack sender when acks stop
- the ack sender waited up to 500 ms for a full ack batch, also after
  StopAcks(), so each region destruction took at least 500 ms
- wait with a predicate that includes the stop flag
- set the stop flag under the ack mutex, so that the sender cannot miss
  the notification

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:37:01 +01:00
Claude
f92780e9a9 fix(zeromq,shmem): stop socket monitor before closing sockets
- Stop the zmq monitor and drain pending events before closing the
  monitored socket and the reading monitor socket
- Events emitted while the monitored socket closes were dropped by
  libzmq, leaking their endpoint frames (zmq_msg_init_size)
- Apply to both the zeromq and shmem transport sockets
- LeakSanitizer no longer reports leaks in the test suite

Fixes: #463

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 13:28:53 +01:00
Dennis Klein
fc69b5e7ae refactor: compile channel name validation regex only once
- the pattern is constant; compiling it on every Validate() call is
  wasted work and, when channels are validated from multiple threads,
  needlessly exercises libstdc++'s lazily-populated ctype caches
2026-06-10 19:31:19 +02:00
Dennis Klein
f08d42fcb8 fix: serialize console output in fair::mq::tools::execute
- concurrent execute() calls print captured subprocess lines to
  std::cout from multiple threads; the standard allows that, but
  libstdc++ maintains the formatted-output state (ios_base::width)
  with plain reads and writes -- a data race ThreadSanitizer reports
  once libstdc++ itself is instrumented
- a mutex around the insertion also keeps whole lines from
  interleaving
2026-06-10 19:31:19 +02:00
Alexey Rybalchenko
1597999aed fix(shmem): don't cache nullptr in GetRegionFromCache
A failed region lookup was inserted into the thread-local cache as
nullptr, making the failure permanent for the lifetime of the cache
generation - retrying never healed because the fast path would return
nullptr without calling GetRegion again. Skip the cache insert on
failure so subsequent calls retry the slow path.
2026-06-10 18:51:04 +02:00
Alexey Rybalchenko
215c31428b feat(shmem): expose side-channel metadata API for unsent messages
Add two public entry points needed by the ALICE use case where shmem
messages are allocated via a transport but never sent — their metadata
is instead serialised into Arrow tables and delivered over a separate
channel, allowing consumer devices to resolve the payload pointer
without taking ownership.

shmem::Message::GetMeta() returns the MetaHeader of the message,
mirroring the existing positional-init pattern already used in Socket.h.

shmem::GetDataAddressFromHandle(TransportFactory&, const MetaHeader&)
is a free function declared in Common.h and defined in Manager.cxx.
Keeping it out of the TransportFactory class body means callers only
need to include Common.h (available transitively via Message.h) and do
not drag in Socket.h or zmq.h. The implementation handles both managed
segments and unmanaged regions, and throws SharedMemoryError with a
typed message on a bad segment or region id. TransportFactory also
gains a same-named member for callers that already have the concrete
type. Lifetime of the returned pointer is the caller's responsibility;
the cache device is expected to hold the messages alive.

A SideChannel test covers the GetMeta/GetDataAddressFromHandle
round-trip for both standard and expanded-metadata configurations.
2026-06-10 18:51:04 +02:00
Dennis Klein
4b2c6cafac build: avoid -Wignored-attributes on the popen deleter
- glibc declares pclose with function attributes (nothrow/leaf), so
  decltype(pclose)* carries attributes that gcc ignores on the unique_ptr
  template argument, emitting -Wignored-attributes
- spell the deleter as a plain int(*)(FILE*) instead; pclose converts to
  it silently and the deleter behaves identically (both popen branches)
2026-06-09 23:00:58 +02:00
Dennis Klein
ab4bc49088 style: drop redundant member initializers in shmem UnmanagedRegion
- fShmemObject() and fFileMapping() default-construct anyway
- clang-tidy readability-redundant-member-init
  https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html
2026-06-09 23:00:58 +02:00
Dennis Klein
35d713ebaa refactor: use default member initializers
- move constant constructor initializers into in-class default member
  initializers
- clang-tidy modernize-use-default-member-init
  https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-default-member-init.html
2026-06-09 23:00:58 +02:00
Dennis Klein
4dfe24d411 style: drop redundant member initializers
- remove constructor member initializers that duplicate the default
  member initialization
- clang-tidy readability-redundant-member-init
  https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html
2026-06-09 23:00:58 +02:00
Dennis Klein
d2aa2f10de style: drop redundant empty-string initializers
- remove `= ""` initialization from strings that default-construct empty
- clang-tidy readability-redundant-string-init
  https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-string-init.html
2026-06-09 23:00:58 +02:00
Dennis Klein
d5e0c29ced perf: emplace elements instead of inserting temporaries
- construct container elements in place instead of inserting a temporary
- clang-tidy modernize-use-emplace
  https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-emplace.html
2026-06-09 23:00:58 +02:00
Dennis Klein
0feda158b4 perf: avoid copies in range-based for loops
- take loop variables by const reference where the body does not modify
  them
- clang-tidy performance-for-range-copy
  https://clang.llvm.org/extra/clang-tidy/checks/performance/for-range-copy.html
2026-06-09 23:00:58 +02:00
Dennis Klein
7a44c5e19e style: add braces around single-statement bodies
- wrap single-statement control-flow bodies in braces
- clang-tidy readability-braces-around-statements
  https://clang.llvm.org/extra/clang-tidy/checks/readability/braces-around-statements.html
2026-06-09 23:00:58 +02:00
Dennis Klein
e23c4d8ff1 style: use raw string literals for escaped strings
- replace string literals containing many escaped characters with raw
  string literals
- clang-tidy modernize-raw-string-literal
  https://clang.llvm.org/extra/clang-tidy/checks/modernize/raw-string-literal.html
2026-06-09 23:00:58 +02:00
Dennis Klein
8ab00ecddc refactor: use nullptr for null pointer literals
- replace `0` null pointer literals (e.g. `void* hint = 0`) with `nullptr`
- clang-tidy modernize-use-nullptr
  https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-nullptr.html
2026-06-09 23:00:58 +02:00
Dennis Klein
fa64faf3f7 fix(boost): add compatibility for Boost.Process v1 API in Boost 1.89+
Boost 1.88 replaced Boost.Process with v2, breaking the v1 API.
Boost 1.89 restores v1 compatibility via <boost/process/v1.hpp>.

- Fail configuration if Boost 1.88 is detected
- Define FAIRMQ_BOOST_PROCESS_V1_HEADER for Boost >= 1.89
- Use conditional includes to select v1.hpp or process.hpp
- Add namespace aliases (bp, bp_this) for portable API access
2026-01-05 14:11:19 +01:00
Giulio Eulisse
67dcf77a7f De-boostify: use std::pmr from C++17 2025-06-13 08:02:06 +02:00
Alexey Rybalchenko
24e7a5b8d0 Make shmem headers public 2025-03-17 15:16:46 +01:00
Giulio Eulisse
c11506e958 feat(EventManager): Out of line some methods 2025-01-23 15:35:26 +01:00
Dennis Klein
e4f258c9ea fix: Update copyright 2025-01-09 17:09:57 +01:00
Dennis Klein
324a27a2e1 fix(tools): No longer use removed alias io_service
Deprecated via d3bbf3756d
and removed via 49fcd03434
in Boost 1.87 or Asio 1.33.
2025-01-09 17:09:57 +01:00
Dennis Klein
c80f97b338 fix(tools): No longer use removed query API
Deprecated via 74fe2b8e14
and removed via e916bdfb1a
in Boost 1.87 or Asio 1.33.
2025-01-09 17:09:57 +01:00
Giulio Eulisse
fe2127e12f Reduce bloat due to statics
Avoid disseminating every compile unit including Message.h with TransportNames and
TransportTypes and the associated unordered_map helper methods (e.g.
murmur_hash).
2025-01-07 17:41:30 +01:00
Giulio Eulisse
41165cf16b Out of line ProgOption::SetProperty for int and std::string
The specializations are common enough to show up in O2 compilation profiles
and they are not time critical (once per run at max).
2025-01-07 17:34:22 +01:00
Giulio Eulisse
91b31f0799 Hide actual container from the API 2024-05-23 15:54:24 +02:00
Alexey Rybalchenko
39cb021827 Add 'no control' controller 2024-02-19 22:09:54 +01:00
Alexey Rybalchenko
0e221b28b8 shm: use node_allocator for ref counts 2024-01-25 10:45:34 +01:00
Alexey Rybalchenko
1ee0977df4 shm: use (de)allocate_one() for ref counts 2024-01-25 10:45:34 +01:00
Alexey Rybalchenko
24d578a4ba shm: extend monitor output for refCount region 2024-01-25 10:45:34 +01:00
Alexey Rybalchenko
2df3d909fa shm: when refCount segment size is zero, fallback to old behaviour
, which is to store reference counts inside the main data segment
2023-11-29 19:21:42 +01:00
Alexey Rybalchenko
58ffdfd1f4 Remove unused ctor and constant 2023-11-29 19:21:42 +01:00
Alexey Rybalchenko
faf577086a shm: fix initialization of rc segment when region is created externally 2023-11-24 14:19:21 +01:00
Alexey Rybalchenko
ff1f9b94ef shm: include rcCountSegment free memory in the monitor output 2023-11-24 14:19:21 +01:00
Alexey Rybalchenko
7567a10513 shm: Bump the ref segment size 10x 2023-11-15 12:52:14 +01:00