[QFJ-563] SocketAcceptor initialization is not properly synchronized Created: 20/Oct/10  Updated: 01/Dec/11  Resolved: 01/Dec/11

Status: Closed
Project: QuickFIX/J
Component/s: Engine
Affects Version/s: 1.5.1
Fix Version/s: 1.5.2

Type: Bug Priority: Default
Reporter: Jaroslav Sedlacek Assignee: Christoph John
Resolution: Fixed Votes: 0
Labels: None


 Description   

SocketAcceptor initialization is using Boolean object as both lock and flag. This approach has 2 major problems:
1) Public object such as Boolean.FALSE should not be used for synchronization. If it is used as lock in multiple places it can lead to performance degradation or deadlock.
2) Synchronization is done on Boolean.FALSE before initialization and on Boolean.TRUE after initialization but synchronization on 2 different locks do not constitute "happens-before" relationship. It means thread coming shortly after initialization can see changed flag and use Boolean.TRUE for locking and so it uses different lock than the lock used during initialization. As a result this thread can see objects created and updated during initialization in inconsistent state.

The problem can be fixed by using private not-share object as a lock and boolean value as flag.



 Comments   
Comment by Christoph John [ 01/Dec/11 ]

I also came across this issue when working on QFJ-643. Will take care of it.

Generated at Sat Nov 23 07:31:00 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.