Fix race condition when registering services 25/825/1
authorGiovanni Meo <gmeo@cisco.com>
Wed, 7 Aug 2013 09:35:29 +0000 (11:35 +0200)
committerGiovanni Meo <gmeo@cisco.com>
Wed, 7 Aug 2013 09:35:29 +0000 (11:35 +0200)
commit0d1d688ac55acc55c3909c52c2cdb940cfb3764f
treee3e6e4f66b1d20255eb94e674d45fa3bb94f06dd
parent6841bbe558146312e1568fc897a054e007a3ba45
Fix race condition when registering services

Dependency Manager is able to notify every component when a new
service tracked is added/removed, this kind of operation is usually
done by allocating a synchronized set or an concurrent map to store
the new service reference or remove it.
This works fine, just it's necessary to be aware that the services may
be learnt by the Component before the "init" method of the component
it's called. In fact the init method of a Dependency Manager component
is called after all the required dependency have been met so that
means that the services may have already been registered. Now if a
component allocate the data structure needed to hold the service
reference during the init time, it can run in the condition where the
services already registered would be wiped out.

The fix is to make sure all the Dependency Manager component init
method don't allocate the data structure needed to hold the services,
but they should be created or during constructor time or during field
initialization. The second approach is prefered here.

Change-Id: I9057351830c09736c5ad7b6777330ef14b39fe9c
Signed-off-by: Giovanni Meo <gmeo@cisco.com>
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/OFStatisticsManager.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadServiceFilter.java
opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.java