Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Exception in ChannelSession ReleaseSemaphore #400

Copy link
Copy link
@fabricedupre

Description

@fabricedupre
Issue body actions

Hello,

I am using latest stable release 2016.1.0 on Windows 10 with Visual Studio 2017 within a desktop application.

ReleaseSemaphore sometimes throws a SystemNullReference exception. To circumvent that issue I had to modify the function to:

    private void ReleaseSemaphore()
    {
        if (Interlocked.CompareExchange(ref _sessionSemaphoreObtained, 0, 1) == 1)
        {
                SemaphoreLight sem = SessionSemaphore;

                if (sem != null)
                    sem.Release();
                else
                    System.Diagnostics.Trace.WriteLine("*** SessionSemaphore NULL");
        }
    }

Digging a little bit, I found that in fact the issue came from Channel SessionSemaphore property. I also had to change it a little bit as below:

    protected SemaphoreLight SessionSemaphore
    {
        get
        {
                ISession s = _session;

                if (s != null)
                    return s.SessionSemaphore;
            
                System.Diagnostics.Trace.WriteLine("*** session NULL");
                return null;
        }
    }

Running my app with those changes, I sometimes get the below trace output, but no more exception:
*** session NULL
*** SessionSemaphore NULL

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.