Skip to content

Commit 50c16fa

Browse files
committed
Split POSIX UDS transport implementation
1 parent 36c0655 commit 50c16fa

9 files changed

Lines changed: 1269 additions & 1106 deletions

File tree

‎.agents/sow/current/SOW-0015-20260605-codacy-scope-and-maintainability.md‎

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,72 @@ Open decisions:
236236
- cppcheck: success, 45 files, 0 issues.
237237
- ShellCheck: success, 3 files, 0 issues.
238238
- Spectral: success, 11 files, 0 issues.
239-
- Revive: partial, 90 files, 0 issues, 1 `findings is not iterable` invocation error.
239+
- Revive: partial, 90 files, 0 issues, 1 `findings is not iterable` invocation error.
240240
- The previous pushed commit `5a55246b9b4698317bdf8440c898369034a1f408` has green CI for CodeQL, Static Analysis, Supply Chain Security, Codacy Local Analysis, Codacy Coverage, and the Codacy GitHub check.
241+
- Committed and pushed `36c06554e1a617e314574ab1cfeae17547285f14`.
242+
- Imported `.codacy/codacy.config.json` again after adding Revive locally:
243+
- 7 tools reconfigured: Checkov, Opengrep, Trivy, Cppcheck, ShellCheck, Spectral, Revive.
244+
- 2727 patterns enabled.
245+
- No tool was disabled.
246+
- Triggered Codacy Cloud reanalysis after the push.
247+
- Checked GitHub CI for `36c06554e1a617e314574ab1cfeae17547285f14`:
248+
- Supply Chain Security: success.
249+
- Codacy Local Analysis: success.
250+
- Static Analysis: success.
251+
- CodeQL: success.
252+
- Codacy Coverage: success.
253+
- Code Quality push check: success.
254+
- Checked Codacy Cloud after `.codacy.yml` reached `main`:
255+
- `listIgnoredFiles` reports `hasCodacyConfigurationFile: true`.
256+
- 133 files are now listed as ignored, including `bench/**`, `tests/**`, Go `*_test.go`, Rust `*_tests.rs`, and Rust `tests.rs` files.
257+
- Repository headline metrics still report the previous full-analysis commit `5a55246b9b4698317bdf8440c898369034a1f408` and still show 42% complex files and 41% duplicated files. This appears to be Codacy metric lag or commit-selection lag after a config-only commit.
258+
- Built a production-source-only file list by filtering the current Codacy file API data through the new ignored-path rules.
259+
- Top production complexity files after filtering ignored test/bench paths:
260+
- `src/libnetdata/netipc/src/transport/posix/netipc_uds.c`: complexity 227, duplication 422.
261+
- `src/go/pkg/netipc/transport/windows/pipe.go`: complexity 214, duplication 773.
262+
- `src/go/pkg/netipc/transport/posix/uds.go`: complexity 182, duplication 745.
263+
- `src/libnetdata/netipc/src/transport/posix/netipc_shm.c`: complexity 179, duplication 166.
264+
- `src/go/pkg/netipc/protocol/apps_lookup.go`: complexity 148, duplication 175.
265+
- Selected `src/libnetdata/netipc/src/transport/posix/netipc_uds.c` as the next production maintainability target because it is the highest-complexity production file after excluding test/bench paths.
266+
- Read `src/libnetdata/netipc/src/transport/posix/netipc_uds.c` in full.
267+
- `netipc_uds.c` currently mixes several separate responsibilities in one compilation unit:
268+
- path validation and stale endpoint recovery.
269+
- low-level SEQPACKET send/receive.
270+
- client handshake.
271+
- server handshake.
272+
- listener/connect/accept/close lifecycle.
273+
- client-side in-flight message ID tracking.
274+
- send chunking.
275+
- receive chunk reassembly and batch validation.
276+
- Selected low-risk implementation shape:
277+
- keep the public `netipc_uds.h` API unchanged.
278+
- keep `netipc_uds.c` as shared low-level/common helpers.
279+
- add a private `netipc_uds_internal.h`.
280+
- move lifecycle/stale recovery, handshake, in-flight tracking, send, and receive into separate POSIX UDS implementation files.
281+
- split send/receive helper logic only where it removes obvious nested branches without changing protocol behavior.
282+
- Implemented the POSIX UDS split:
283+
- `netipc_uds.c`: shared low-level send/receive and packet-size helpers.
284+
- `netipc_uds_internal.h`: private POSIX UDS declarations and constants.
285+
- `netipc_uds_handshake.c`: client/server handshake and negotiation.
286+
- `netipc_uds_lifecycle.c`: listen/connect/accept/close and stale socket recovery.
287+
- `netipc_uds_inflight.c`: client-side message ID tracking.
288+
- `netipc_uds_send.c`: outbound limit checks, single-packet send, and chunked send.
289+
- `netipc_uds_receive.c`: inbound validation, chunk reassembly, and batch validation.
290+
- Updated `CMakeLists.txt` so the `netipc_uds` static library builds all POSIX UDS implementation files.
291+
- Validation after the split:
292+
- `cmake --build build`: passed.
293+
- `/usr/bin/ctest --test-dir build --output-on-failure`: 46/46 tests passed in 449.75 seconds.
294+
- `git diff --check`: passed.
295+
- `bash .agents/sow/audit.sh`: passed.
296+
- `codacy-analysis analyze . --output-format json`: exit status 0, 0 issues, 1 known Revive adapter error.
297+
- Checkov: success, 11 files, 0 issues.
298+
- Opengrep/Semgrep: success, 271 files, 0 issues.
299+
- Trivy: success, 272 files, 0 issues.
300+
- cppcheck: success, 51 files, 0 issues.
301+
- ShellCheck: success, 3 files, 0 issues.
302+
- Spectral: success, 11 files, 0 issues.
303+
- Revive: partial, 90 files, 0 issues, 1 `findings is not iterable` invocation error.
304+
- Note: plain `ctest` resolves to a broken user-local Python wrapper at `~/.local/bin/ctest`; system `/usr/bin/ctest` was used for validation.
241305

242306
## Validation
243307

‎CMakeLists.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ target_include_directories(netipc_protocol PUBLIC
5353
if(NOT NETIPC_WINDOWS_RUNTIME)
5454
add_library(netipc_uds STATIC
5555
src/libnetdata/netipc/src/transport/posix/netipc_uds.c
56+
src/libnetdata/netipc/src/transport/posix/netipc_uds_handshake.c
57+
src/libnetdata/netipc/src/transport/posix/netipc_uds_inflight.c
58+
src/libnetdata/netipc/src/transport/posix/netipc_uds_lifecycle.c
59+
src/libnetdata/netipc/src/transport/posix/netipc_uds_receive.c
60+
src/libnetdata/netipc/src/transport/posix/netipc_uds_send.c
5661
)
5762
target_include_directories(netipc_uds PUBLIC
5863
src/libnetdata/netipc/include

0 commit comments

Comments
 (0)