Skip to content

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

Open
devnexen wants to merge 1 commit intorust-lang:mainfrom
devnexen:net_set_linger_fix
Open

std::net: clamp linger timeout value to prevent silent truncation.#153207
devnexen wants to merge 1 commit intorust-lang:mainfrom
devnexen:net_set_linger_fix

Conversation

@devnexen
Copy link
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
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. 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