On Thu, 1 Dec 2022 14:02:51 GMT, Per Minborg <[email protected]> wrote:

> > > receiverThread and senderThread are declared volatile but are always 
> > > accessed (r/w) whilst synchronising on the stateLock.
> 
> @stsypanov Yes I am aware that this was a separate observation which is not 
> related to the assignment of the variables. I can surely keep them volatile 
> but I wonder why they are volatile in the first place.

The SCTP implementation dates from JDK 7 and has not changed much since then.  
In the case of the thread IDs used for signalling then I suspect this was 
copied from the original SocketChannelImpl code that has been 
replaced/re-written by way of splitting the blocking and non-blocking code 
paths (the thread IDs are only needed for channels configured blocking). If all 
access to the thread IDs is guarded by stateLock then you should be okay to 
making it non-volatile. Testing is a challenge when touching this area as SCTP 
requires special kernel configuration. Keeping the changes simple and easy to 
review would be helpful.

-------------

PR: https://git.openjdk.org/jdk/pull/11418

Reply via email to