Skip to content

SubscribeEvents may not be Thread-Safe #14

@DanieleGhianda

Description

@DanieleGhianda

I was using InboundSocket to originate some calls and play Audio files, and sometimes i got an ThrowInvalidOperationException_ConcurrentOperationsNotSupported where I called Play(...).

Here is the call stack:

    System.ThrowHelper.ThrowInvalidOperationException_ConcurrentOperationsNotSupported()
    System.Collections.Generic.HashSet<T>.FindItemIndex(T)
    System.Collections.Generic.HashSet<T>.Contains(T)
    NEventSocket.Sockets.EventSocket.SubscribeEvents.AnonymousMethod__28_0(NEventSocket.FreeSwitch.EventName)
    System.Linq.Enumerable.All<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource, bool>)
    NEventSocket.Sockets.EventSocket.SubscribeEvents(NEventSocket.FreeSwitch.EventName[])
    NEventSocket.Sockets.EventSocket.ExecuteApplication(string, string, string, bool, bool, int)
    NEventSocket.ApplicationExtensions.Play(NEventSocket.Sockets.EventSocket, string, string, NEventSocket.FreeSwitch.PlayOptions)

I checked the library and I noticed the use of HashSet:
private readonly HashSet<EventName> subscribedEvents = new HashSet<EventName>();

Am I missing something or is it really not Thread-Safe ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions