Swapped Identity Assignment in APICreateSocketPair#404
Swapped Identity Assignment in APICreateSocketPair#404thouravi wants to merge 1 commit intoValveSoftware:masterfrom
Conversation
|
I am hesitant to change the behaviour of this function since there might be people using this function that depends on the current behaviour. I am tempted to just update the documentation to match the current behaviour. The current behaviour is confusing, but honestly this is already inherently confusing because when you get info about a connection, you get the REMOTE identity, not the local one. I believe that is why it is swapped, because that is actually less surprising than the non-swapped case. So I think the correct thing to do is just to avoid changing behaviour and risking breaking stuff, and to just update the documentation to clarify the exact behaviour. Also, the same bug exists in the pipe version, so we would need them to be consistent. |
|
That’s a fair point, I hadn’t considered that existing callers might be relying on the current behavior to get the remote identity. One thing worth considering: could we add a note in the docs flagging this as counterintuitive, so future callers don’t have to discover it the hard way? Maybe even a comment in the source near the assignment. And Agreed on keeping the pipe version consistent, whatever approach we take here should apply there too. |
pConn[0]is initialized withpIdentity[1]andscopeLock[1]pConn[1]is initialized withpIdentity[0]andscopeLock[0]The indices are inverted. Each connection slot gets the wrong identity and the wrong scope lock.
Fix: