Skip to content

potential unreleased locks #97

Description

@joprice

I noticed that the use of locks in the QueueManager, especially the one that throws, could end up holding onto the lock too long:

fileprivate func synchronizeThrows<T>(action: () throws -> T) throws -> T {
recursiveLock.lock()
let result = try action()
recursiveLock.unlock()
return result
}
fileprivate func synchronize <T>(action: () -> T) -> T {
recursiveLock.lock()
let result = action()
recursiveLock.unlock()
return result
}
. I'm not a swift expert, but moving unlock into a defer block should guarantee that the lock is released on exiting. I haven't repro'd this, but I would think any failable function being passed to synchronizeThrows would cause later operations to hang.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions