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

[BUG] PRE restriction is not applied on a listener socket #1873

Closed
maxsharabayko opened this issue Mar 18, 2021 · 3 comments · Fixed by #1939
Closed

[BUG] PRE restriction is not applied on a listener socket #1873

maxsharabayko opened this issue Mar 18, 2021 · 3 comments · Fixed by #1939
Labels
[API] Area: Changes in SRT library API [core] Area: Changes in SRT library core Priority: High Type: Bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@maxsharabayko
Copy link
Collaborator

After PR #1776 socket options with PRE restriction can be applied on a listener socket even after srt_listen was called.
E.g. SRTO_LATENCY, SRTO_TSBPDMODE etc. can be changed while listening for incoming connections. As well as other socket options with PRE binding (see APISocketOptions.md).

Example test case fails with the current master and succeeds with SRT v1.4.2.

// Check that setting SRTO_LATENCY after a socket is in the listening state is not allowed.
TEST_F(TestSocketOptions, LatencyPRERestriction)
{
    const int latency_ms = 200;
    int optlen = (int)(sizeof latency_ms);

    StartListener(); // calls srt_bind and srt_listen
    EXPECT_EQ(srt_setsockopt(m_listen_sock, 0, SRTO_LATENCY, &latency_ms, sizeof latency_ms), SRT_ERROR);
}

SRT v1.4.2 does not allow to set an option with PRE restriction if a socket has m_bOpened set to true. E.g. SRTO_LATENCY, SRTO_TSBPDMODE, SRTO_RCVBUF, etc.

The latest master checks only if m_bConnected or m_bConnecting is set to true. Neither m_bOpened, nor m_bListening is checked.

Affected SRT versions

  • SRT Version: v1.4.3-rc0
@maxsharabayko maxsharabayko added Priority: High Type: Bug Indicates an unexpected problem or unintended behavior [core] Area: Changes in SRT library core [API] Area: Changes in SRT library API labels Mar 18, 2021
@maxsharabayko maxsharabayko added this to the v1.4.3 milestone Mar 18, 2021
@ethouris
Copy link
Collaborator

ethouris commented Mar 18, 2021

The #1776 PR changed completely nothing in the general restriction rules since UDT codebase.

The change you observe is because many options have been found with "wrong" restrictions and this has been fixed - among others, SRTO_LATENCY changed the restriction from PREBIND to PRE. This change was completely intended and it was accepted, including changes in the documentation.

@maxsharabayko
Copy link
Collaborator Author

SRTO_LATENCY changed the restriction from PREBIND to PRE. This change was completely intended and it was accepted, including changes in the documentation.

Hm, so you are saying that it is ok to change a value of SRTO_LATENCY, SRTO_TSBPDMODE on a listener socket while listening for incoming connections? And that this change was intended.

@ethouris
Copy link
Collaborator

It was intended and accepted. There was no reason to restrict it on the data socket before binding because it didn't influence the binding process.

For a listener socket it changes only one thing: if you can change it on the listener, then you can allow all connections that happen before that change to use the old value, and after - the new value, and you cannot exactly control that process on the connections. For an application this might be seen as a bad practice (it should rather close the socket first, to prevent the new connection during the change time, maybe do something about existing connections spawned off this listener, and then start the listener again, this time with a new value), but there's nothing dangerous that can happen here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[API] Area: Changes in SRT library API [core] Area: Changes in SRT library core Priority: High Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants