mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-16 18:47:33 -05:00
* Fix for issue #441. Method doc reads that the method is thread-safe, but there exist no locking to ensure thread safety on call into recycle method. Modifying the decrementUserCount method to block other callers to ensure thread-safe access. This appears to be a hot area of code and there may be a performance hit by doing this, please double check my work here. * Moving synchronized to recycle method as it's accessed by two different methods that could potentially cause an unsafe access race condition. * Revert - synchronizing recycle does not protect against multiple recycle calls on the same object.
This commit is contained in:
@@ -93,7 +93,7 @@ public abstract class AbstractReusableBuffer
|
|||||||
*
|
*
|
||||||
* This method is thread-safe.
|
* This method is thread-safe.
|
||||||
*/
|
*/
|
||||||
public void decrementUserCount()
|
public synchronized void decrementUserCount()
|
||||||
{
|
{
|
||||||
if(mUserCount.decrementAndGet() <= 0)
|
if(mUserCount.decrementAndGet() <= 0)
|
||||||
{
|
{
|
||||||
@@ -104,7 +104,7 @@ public abstract class AbstractReusableBuffer
|
|||||||
/**
|
/**
|
||||||
* Sends this buffer back to the owning buffer queue for reuse
|
* Sends this buffer back to the owning buffer queue for reuse
|
||||||
*/
|
*/
|
||||||
private void recycle()
|
private synchronized void recycle()
|
||||||
{
|
{
|
||||||
prepareForRecycle();
|
prepareForRecycle();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user