Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor out commonality between WorkerProto::Basic{Client,Server}Connection #11125

Merged
merged 4 commits into from
Jul 19, 2024

Conversation

edolstra
Copy link
Member

@edolstra edolstra commented Jul 17, 2024

Motivation

This gets rid of some duplicate code. It also renames clientVersion and daemonVersion to the more correct protoVersion (since it's the version agreed to by both sides).

This is in preparation of another PR that adds more fine-grained protocol negotiation.

This also fixes a bug in FdSource::operator = where it wouldn't move the underlying BufferedSource, so it could lose data if the buffer wasn't empty.

Context

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions bot added new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store labels Jul 17, 2024
Comment on lines +1040 to +1043
WorkerProto::BasicServerConnection conn;
conn.to = std::move(to);
conn.from = std::move(from);
conn.protoVersion = clientVersion;
Copy link
Member

@Ericson2314 Ericson2314 Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this use designated initializer syntax? I think so

Suggested change
WorkerProto::BasicServerConnection conn;
conn.to = std::move(to);
conn.from = std::move(from);
conn.protoVersion = clientVersion;
WorkerProto::BasicServerConnection conn {{
.to = to,
.from = from,
.protoVersion = clientVersion,
}};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that doesn't work with inheritance.

src/libstore/daemon.cc Outdated Show resolved Hide resolved
Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two little nits, very nice on the whole!

Refactors, I like them :D

…ction

This also renames clientVersion and daemonVersion to the more correct
protoVersion (since it's the version agreed to by both sides).
This wasn't moving the underlying buffer, so if the buffer was
non-empty, it could lose data.
@edolstra edolstra enabled auto-merge July 19, 2024 11:36
@edolstra edolstra merged commit c4213f0 into NixOS:master Jul 19, 2024
11 checks passed
@edolstra edolstra deleted the basic-connection branch July 19, 2024 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants