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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SSHMaster::Connection::trySetBufferSize #10765

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ericson2314
Copy link
Member

Motivation

It is unused in Nix currently, but will be used in Hydra. This reflects what Hydra does in NixOS/hydra#1387.

Context

We may probably to use it more widely for better SSH store performance, but this needs to be subject to more testing before we do that.

Priorities and Process

Add 馃憤 to pull requests you find important.

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

@Ericson2314
Copy link
Member Author

Oh wat, segfault in CI in ambient Nix (i.e. nothing to do with this PR)

/Users/runner/work/_temp/8e2e66c1-0beb-427b-912b-9e63f8be4be1.sh: line 1:  4963 Segmentation fault: 11  nix --experimental-features 'nix-command flakes' flake check -L

@roberth
Copy link
Member

roberth commented May 24, 2024

segfault in CI in ambient Nix (i.e. nothing to do with this PR)

/Users/runner/work/_temp/8e2e66c1-0beb-427b-912b-9e63f8be4be1.sh: line 1:  4963 Segmentation fault: 11  nix --experimental-features 'nix-command flakes' flake check -L

Is that on Darwin? Can you get a stack trace for it?

@vcunat
Copy link
Member

vcunat commented May 24, 2024

We didn't post here, but the fcntl calls are wrong. Setter takes an int, not a pointer. And getter takes nothing, returns value. EDIT: that's how man fcntl.2 reads to me, at least.

It is unused in Nix currently, but will be used in Hydra. This reflects
what Hydra does in NixOS/hydra#1387.

We may probalby to use it more widely for better SSH store performance,
but this needs to be subject to more testing before we do that.
@vcunat
Copy link
Member

vcunat commented May 26, 2024

Nit: why design the interface with size_t when we're only able to implement int?

EDIT: especially note that the (current) implementation silently overflows to non-sensical values.

@Ericson2314
Copy link
Member Author

Ericson2314 commented May 27, 2024

@vcunat ah I could assert, or that + change type to unsigned int. I just didn't want to accept negative numbers.

@roberth
Copy link
Member

roberth commented May 27, 2024

Could you add a test? We can't just rely on types here, unfortunately.
You could detect the buffer size by filling a pipe in non blocking mode, without reading it.

@vcunat
Copy link
Member

vcunat commented May 27, 2024

Accepting negative numbers? Well, if you do an unsigned int or size_t and pass a too large value, you can end up passing a negative number to the syscall. So if you don't have code somehow guarding that, I'd say it's better to make the real type visible in the API already.

But perhaps more generally: the function returns the resulting buffer size (or negative error code), so perhaps it would make sense to check the return value? Overriding buffer size surely won't be a very important error, but perhaps some debug-level logs in case the value differs from what was passed as desired size? (that could even cover these negative cases by itself)

EDIT: I don't know the customs of Nix codebase, and I only really use pure C, so... take my comments with a grain of salt.

@Ericson2314 Ericson2314 marked this pull request as draft May 27, 2024 14:19
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.

None yet

3 participants