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
Fixed restrictions on pre-bind only options #1332
Conversation
46a0699
to
d4eda49
Compare
Why e.g. the latency is not allowed to be changed after a socket is bound to some IP? |
Theoretically, but I'm simply not changing the internals here, but adjusting the API entries to the internals. This is a separation between the state and the options for those options that then undergo "negotiation" during the handshake. Example: the state of TLPKTDROP is notified as per agent and peer separately, although if it's not supported by the peer, then the state is not set to true even if the option dictates otherwise. For options that are not mapped to the state negotiated during the handshake it doesn't matter. Important here is that the INIT/OPEN state distinction is the only way to make a border point between the option and the state. This is important for options that WISH to alter the state, but the real state change is in force only if the handshake process also confirms it. |
Didn't get your point. if (m_bConnecting || m_bConnected) |
Again. A socket to be connected passes the following transition: INIT -> OPEN -> CONNECTING -> CONNECTED If you don't bind it yourself, it will undergo self-binding, so it enters the Both self-binding and explicit binding functions will call The fix is simple: all such options, which are being read-and-forgotten in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This procedure contains rewriting the values from the variables keeping the values of the options into the variables that keep the state - which means, after transiting to OPEN state the change in pre-bind options is meaningless - it will no longer influence the state.
Ok, it makes sense.
What about other pre-binding options then? E.g. SRTO_RENDEZVOUS
still checks for m_bConnecting
or m_bConnected
.
SRTO_KMPREANNOUNCE
and SRTO_ENFORCEDENCRYPTION
check only for m_bConnected
.
Shouldn't they also check for m_bOpened
then?
Just take a look in the code as to how variables that are assigned to these options are used. None of the options you mentioned causes setting up the state that is not read after that. It's about the options that are recorded in fields that are referred to only during opening and not read any time later. |
I'm thinking if it should be reflected in the documentation then? E.g. I am looking at How does a user know the difference? |
There's not much we can do about it, unless we fix the internals. For now to be simple we should state that the users should set all PRE options, then possibly do bind, then connect. I don't think it matters for users if they could set some options before binding and some after binding. |
This fix changes restrictions on options that are being taken into account only at the function that is called during binding - both self-binding done on an unbound socket used for
srt_connect
and the manual binding bysrt_bind
. When these options were altered betweensrt_bind
andsrt_connect
the option setting would be ignored without making the user aware.