Export to GitHub

apns-sharp - issue #12

Orphaning of streams


Posted on Oct 7, 2009 by Swift Rhino

In NotificationConnection, the ensureConnection method, you have a condition where connected will never be true before you hit the while loop.

        bool connected = false;

        if (apnsStream == null || !apnsStream.CanWrite)
            connected = false;

        if (apnsClient == null || !apnsClient.Connected)
            connected = false;
  • The optimal solution for this would be to get rid of that block of code and simply do

connected = ((apnsClient != null && apnsClient.Connected) && (apnsStream != null && apnsStream.CanWrite));

But, if apsnClient or apnsStream are open and have not been disposed, you will lose control of memory. You will need to dispose of those instances before you can allocate new ones.

Comment #1

Posted on Oct 7, 2009 by Swift Rhino

Technically, this should really be two different bugs but they are one in the same

Comment #2

Posted on Dec 22, 2009 by Happy Lion

This is changed in the latest commit, no more EnsureConnected method at all, as I found that the apnsClient.Connected method really doesn't give a true indication of the connection state. It basically reports the state of the connection from the time of the last operation made on the stream.

Now, the connected state is handled a bit differently.

Status: Fixed

Labels:
Type-Defect Priority-Medium