If you call schedule, it is possible to miss a cancellation if you call cancel before it is added to the map.
executorService.schedule() is called.
Before we put it in the map via scheduledFutures.put(..) we call cancel. It is not found in the cancellation map so therefore not cancelled.
Since we're cancelling all timers on disconnect (a separate bug fix), this becomes an issue if a user disconnects while a timer is being scheduled. Slim possible chance, but non-zero.
We fixed by using coarse grained synchronization across the whole class. The reason we thought this was ok (rather than finely grained synchronization) is because the map.put/remove is a constant time (or log(n) time) operation.
If you call schedule, it is possible to miss a cancellation if you call cancel before it is added to the map.
executorService.schedule() is called.
Before we put it in the map via scheduledFutures.put(..) we call cancel. It is not found in the cancellation map so therefore not cancelled.
Since we're cancelling all timers on disconnect (a separate bug fix), this becomes an issue if a user disconnects while a timer is being scheduled. Slim possible chance, but non-zero.
We fixed by using coarse grained synchronization across the whole class. The reason we thought this was ok (rather than finely grained synchronization) is because the map.put/remove is a constant time (or log(n) time) operation.
https://github.com/Zipwhip/netty-socketio/commit/12aa05292370fcf6377679b880fbffda6748fc3d