Committed by
Gerrit Code Review
[emu][onos-3159] fix concurrency flaws in OpenFlowDeviceProvider.java and OpenFlowGroupProvider.java
Change-Id: I76b21b221d3ef71e1701c13810c4df374afe1776
Showing
2 changed files
with
20 additions
and
1 deletions
| ... | @@ -319,6 +319,9 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -319,6 +319,9 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
| 319 | } | 319 | } |
| 320 | DeviceId did = deviceId(uri(dpid)); | 320 | DeviceId did = deviceId(uri(dpid)); |
| 321 | OpenFlowSwitch sw = controller.getSwitch(dpid); | 321 | OpenFlowSwitch sw = controller.getSwitch(dpid); |
| 322 | + if (sw == null) { | ||
| 323 | + return; | ||
| 324 | + } | ||
| 322 | 325 | ||
| 323 | ChassisId cId = new ChassisId(dpid.value()); | 326 | ChassisId cId = new ChassisId(dpid.value()); |
| 324 | 327 | ||
| ... | @@ -339,9 +342,14 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -339,9 +342,14 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
| 339 | providerService.updatePorts(did, buildPortDescriptions(sw)); | 342 | providerService.updatePorts(did, buildPortDescriptions(sw)); |
| 340 | 343 | ||
| 341 | PortStatsCollector psc = | 344 | PortStatsCollector psc = |
| 342 | - new PortStatsCollector(controller.getSwitch(dpid), portStatsPollFrequency); | 345 | + new PortStatsCollector(sw, portStatsPollFrequency); |
| 343 | psc.start(); | 346 | psc.start(); |
| 344 | collectors.put(dpid, psc); | 347 | collectors.put(dpid, psc); |
| 348 | + | ||
| 349 | + //figure out race condition for collectors.remove() and collectors.put() | ||
| 350 | + if (controller.getSwitch(dpid) == null) { | ||
| 351 | + switchRemoved(dpid); | ||
| 352 | + } | ||
| 345 | } | 353 | } |
| 346 | 354 | ||
| 347 | @Override | 355 | @Override |
| ... | @@ -364,6 +372,9 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -364,6 +372,9 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
| 364 | } | 372 | } |
| 365 | DeviceId did = deviceId(uri(dpid)); | 373 | DeviceId did = deviceId(uri(dpid)); |
| 366 | OpenFlowSwitch sw = controller.getSwitch(dpid); | 374 | OpenFlowSwitch sw = controller.getSwitch(dpid); |
| 375 | + if (sw == null) { | ||
| 376 | + return; | ||
| 377 | + } | ||
| 367 | providerService.updatePorts(did, buildPortDescriptions(sw)); | 378 | providerService.updatePorts(did, buildPortDescriptions(sw)); |
| 368 | } | 379 | } |
| 369 | 380 | ... | ... |
| ... | @@ -334,12 +334,20 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv | ... | @@ -334,12 +334,20 @@ public class OpenFlowGroupProvider extends AbstractProvider implements GroupProv |
| 334 | @Override | 334 | @Override |
| 335 | public void switchAdded(Dpid dpid) { | 335 | public void switchAdded(Dpid dpid) { |
| 336 | OpenFlowSwitch sw = controller.getSwitch(dpid); | 336 | OpenFlowSwitch sw = controller.getSwitch(dpid); |
| 337 | + if (sw == null) { | ||
| 338 | + return; | ||
| 339 | + } | ||
| 337 | if (isGroupSupported(sw)) { | 340 | if (isGroupSupported(sw)) { |
| 338 | GroupStatsCollector gsc = new GroupStatsCollector( | 341 | GroupStatsCollector gsc = new GroupStatsCollector( |
| 339 | controller.getSwitch(dpid), POLL_INTERVAL); | 342 | controller.getSwitch(dpid), POLL_INTERVAL); |
| 340 | gsc.start(); | 343 | gsc.start(); |
| 341 | collectors.put(dpid, gsc); | 344 | collectors.put(dpid, gsc); |
| 342 | } | 345 | } |
| 346 | + | ||
| 347 | + //figure out race condition | ||
| 348 | + if (controller.getSwitch(dpid) == null) { | ||
| 349 | + switchRemoved(dpid); | ||
| 350 | + } | ||
| 343 | } | 351 | } |
| 344 | 352 | ||
| 345 | @Override | 353 | @Override | ... | ... |
-
Please register or login to post a comment