Skip to content

Add stream socket so_linger context option#20808

Open
bukka wants to merge 3 commits intophp:masterfrom
bukka:stream_so_linger
Open

Add stream socket so_linger context option#20808
bukka wants to merge 3 commits intophp:masterfrom
bukka:stream_so_linger

Conversation

@bukka
Copy link
Member

@bukka bukka commented Dec 30, 2025

This adds so_linger stream socket context options that is used to set the lingering time in seconds. If the value is lower or equal to 0, then the lingering is disabled.

bukka added 2 commits March 6, 2026 20:29
This adds so_linger stream socket context options that is used to set
the lingering time in seconds. If the value is lower or equal to 0,
then the lingering is disabled.
@bukka
Copy link
Member Author

bukka commented Mar 7, 2026

The CI failure unrelated. @devnexen could you check this out if this looks good to you?

Please also check this eefbf0e if you think it's expected on FreeBSD... I suppose that it just say that it has to be greater than 0 so should be fine to leave it like that - not sure what to do else though...

@devnexen
Copy link
Member

devnexen commented Mar 7, 2026

Please also check this eefbf0e if you think it's expected on FreeBSD... I suppose that it just say that it has to be greater than 0 so should be fine to leave it like that - not sure what to do else though...

I just double checked, but FreeBSD set l_onoff field by masking with SO_LINGER (which is 0x0080)

			l.l_onoff = so->so_options & SO_LINGER;

if (sockvals->mask & PHP_SOCKVAL_SO_LINGER) {
struct linger linger_val = {
.l_onoff = (sockvals->linger > 0),
.l_linger = (unsigned short)sockvals->linger
Copy link
Member

Choose a reason for hiding this comment

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

the only subtlety is setting l_onoff with 1 but with l_linger with 0 is a valid use case (closing connection w/o handshake aka RST on close) but you can only carry one value per socket option right ?

Copy link
Member

Choose a reason for hiding this comment

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

saying that, even rust expresses this in a similar way I just recalled having pushing a PR in there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants