Skip to content

std::net: clamp linger timeout value to prevent silent truncation.#153207

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
devnexen:net_set_linger_fix
Apr 1, 2026
Merged

std::net: clamp linger timeout value to prevent silent truncation.#153207
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
devnexen:net_set_linger_fix

Conversation

@devnexen
Copy link
Copy Markdown
Contributor

Duration::as_secs() returns u64 but l_linger field type is narrower, c_int on most unix platforms, c_ushort on cygwin and windows. clamping before the cast, consistent with how set_timeout handles this.

Duration::as_secs() returns u64 but l_linger field type is narrower,
c_int on most unix platforms, c_ushort on cygwin and windows.
clamping before the cast, consistent with how set_timeout handles this.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 28, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Feb 28, 2026

r? @joboet

rustbot has assigned @joboet.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, joboet

@joboet
Copy link
Copy Markdown
Member

joboet commented Feb 28, 2026

The implementation looks good to me, but I'll reassign this to libs-api to decide whether rounding down here is correct (as opposed to rounding the duration up and returning an error if the time is nor representable).

r? libs-api

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Feb 28, 2026
@rustbot rustbot assigned Amanieu and unassigned joboet Feb 28, 2026
@Amanieu
Copy link
Copy Markdown
Member

Amanieu commented Mar 31, 2026

This is fine, the underlying syscall clamps the value down to the maximum supported value anyways.

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 31, 2026

📌 Commit baf8595 has been approved by Amanieu

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 31, 2026
rust-bors bot pushed a commit that referenced this pull request Apr 1, 2026
Rollup of 5 pull requests

Successful merges:

 - #152935 (c-variadic: error when we can't guarantee that the backend does the right thing)
 - #153207 (std::net: clamp linger timeout value to prevent silent truncation.)
 - #154592 (Fix `mismatched_lifetime_syntaxes` suggestions for hidden path lifetimes)
 - #154643 (fix pin docs)
 - #154648 (Clarify `ty::List`)
@rust-bors rust-bors bot merged commit 8296e03 into rust-lang:main Apr 1, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 1, 2026
rust-timer added a commit that referenced this pull request Apr 1, 2026
Rollup merge of #153207 - devnexen:net_set_linger_fix, r=Amanieu

std::net: clamp linger timeout value to prevent silent truncation.

Duration::as_secs() returns u64 but l_linger field type is narrower, c_int on most unix platforms, c_ushort on cygwin and windows. clamping before the cast, consistent with how set_timeout handles this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants