Skip to content

freebsd support - #2492

Closed
romanov wants to merge 1 commit into
DeusData:mainfrom
romanov:freebsd-support
Closed

romanov wants to merge 1 commit into
DeusData:mainfrom
romanov:freebsd-support

Conversation

@romanov

@romanov romanov commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Added FreeBSD support

Checklist

  • Every commit is signed off (git commit -s) — required, CI rejects
    unsigned commits (DCO, see CONTRIBUTING.md)
  • Tests pass locally (make -f Makefile.cbm test)
  • Lint passes (make -f Makefile.cbm lint-ci)
  • New behavior is covered by a test (reproduce-first for bug fixes)

@romanov
romanov requested a review from DeusData as a code owner October 2, 2026 21:00
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

Thanks for opening this — it has been seen, and it is queued.

This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence.

Current review status: working through a backlog. 0.9.1-rc.1 is out, so the release freeze that held reviews is over — but it left a large queue of open pull requests behind it, and we are reading through them oldest-first. The background is in discussion #1144.

What that means for this PR, concretely:

  • It will not be closed for inactivity. No stale bot touches pull requests here.
  • It may still sit a while before a human reads it. That is on us, not on you.
  • Older PRs are read first, so a recent one is not being skipped — it is behind a queue.

Things that will genuinely speed it up whenever review does happen:

  • Keep it rebased on main — the tree is moving quickly right now, and a conflicting branch cannot be reviewed as the diff you intended.
  • Get CI green, or say which failures you believe are pre-existing.
  • Keep the change to one claim. Bundled features and refactors get split before they get merged, which costs you a round trip.
  • Every commit needs a sign-off (git commit -s) — CI enforces DCO.

If this fixes a bug, a reproduction we can run is worth more than a description of the symptom.

Thanks for contributing, and sorry in advance for the wait.

@DeusData DeusData added the enhancement New feature or request label Oct 19, 2026
@DeusData

Copy link
Copy Markdown
Owner

Thanks for working on FreeBSD support. A quick look shows the peer-credential addition plus broader startup/connect timeout increases. Could you expand the description with the FreeBSD version/toolchain and test results, and explain why each timeout change is needed? That will make the intended support scope reviewable.

@DeusData

Copy link
Copy Markdown
Owner

Thanks again for taking on FreeBSD support. The LOCAL_PEERCRED / struct xucred branch in src/daemon/ipc.c looks like exactly the missing piece: on current main that peer lookup has no FreeBSD case, so the daemon cannot read the connecting process id and closes the connection. That part is a real, focused fix, and it follows the same shape as the existing Linux, macOS and NetBSD branches.

To make this mergeable, here are a few concrete steps on top of the questions above:

  1. Sign-off: the commit has no Signed-off-by line, so the dco check is red. git commit --amend -s followed by a force-push of the branch fixes it.
  2. Conflict: the branch no longer merges cleanly into current main. The conflict is in src/main.c, where the timeout constants live.
  3. Startup budget: since this PR was opened, main gained a CBM_STARTUP_TIMEOUT_MS environment variable (clamped to 1 s .. 10 min) for slow or loaded hosts. If the 30 s -> 120 s change to MAIN_MCP_STARTUP_TIMEOUT_MS was for a slow machine, that variable covers it without changing the default for everyone, so we would suggest dropping that hunk.
  4. The other two timeout changes (MAIN_CONNECT_TIMEOUT_MS 1 s -> 30 s and HOST_INITIAL_CLIENT_TIMEOUT_MS 10 s -> 120 s) apply on every platform. With the peer-credential fix in place, do you still need them on FreeBSD? If you do, please share what you observed (FreeBSD version, compiler, and which step timed out). If you do not, the simplest path is a PR with just the ipc.c change, which we can review quickly.

Thanks for your patience with the review backlog, and for helping widen the platforms this runs on.

@DeusData

Copy link
Copy Markdown
Owner

Thank you again for the FreeBSD peer-credential fix. The October 20 questions remain: sign off the commit and clarify whether the cross-platform timeout increases are still needed with peer lookup fixed. A focused ipc.c revision, or the FreeBSD version/toolchain and observed timeout evidence, would let the next review proceed.

@DeusData

Copy link
Copy Markdown
Owner

Hi @romanov, thank you again for tracking down the missing FreeBSD case in the daemon's peer-credential lookup. That was the real problem: without it the daemon cannot read the connecting process id on FreeBSD and closes every connection.

We have not heard back since early October, and the commit on this branch has no Signed-off-by line. Only you can add that, because the DCO check compares each commit's sign-off with its own author, so nothing we push on top could make the branch mergeable. So that your fix does not keep waiting, we have carried it forward in #2967, with you credited as co-author (Co-authored-by trailer).

What we kept from you, unchanged: the LOCAL_PEERCRED / struct xucred branch in cbm_daemon_ipc_connection_peer_pid(), including the cr_version, effective-uid and positive-pid checks, and the sys/ucred.h include guarded by __FreeBSD__.

What we left out, and why: the three timeout increases in src/main.c and src/daemon/host.c. They change the defaults on every platform, slow or loaded hosts can already raise the startup budget with CBM_STARTUP_TIMEOUT_MS, and with the peer lookup fixed they should not be needed on FreeBSD. If you still see a timeout there after #2967, an issue with the FreeBSD version, the compiler and the step that timed out would be very welcome.

We will close this PR once #2967 has merged. Thanks again for helping widen the platforms this runs on.

@DeusData

Copy link
Copy Markdown
Owner

Closing in favour of #2967, which merged as a3e9c91 and carries your Co-authored-by credit. Thank you, @romanov: your LOCAL_PEERCRED / xucred branch is now how the daemon reads the peer process id on FreeBSD, carried over unchanged, version, uid and pid checks included. If a timeout still shows up on FreeBSD, an issue with the FreeBSD version, the compiler and the step that timed out is the quickest way to get it looked at.

@DeusData DeusData closed this Nov 13, 2026
neil1123-vip pushed a commit to neil1123-vip/codebase-memory-mcp that referenced this pull request Nov 13, 2026
cbm_daemon_ipc_connection_peer_pid() had branches for Linux
(SO_PEERCRED), macOS (LOCAL_PEERPID) and NetBSD (LOCAL_PEEREID), but
FreeBSD defines none of them, so it fell through to `return 0`, and
runtime_accept_connection() closes every connection whose peer pid is
0: on FreeBSD the daemon rejected every client.

Read the peer credentials with getsockopt(SOL_LOCAL, LOCAL_PEERCRED)
into a struct xucred and accept only the expected layout version, the
caller's effective uid and a positive pid, mirroring the Linux branch.
The branch and its <sys/ucred.h> include compile only on FreeBSD.

Carried forward from DeusData#2492, which also raised three timeouts on every
platform; those are left out (CBM_STARTUP_TIMEOUT_MS covers slow hosts).

Co-authored-by: Yury Romanov <[email protected]>
Signed-off-by: Martin Vogel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants