snnagar / apns-sharp

Automatically exported from code.google.com/p/apns-sharp
0 stars 0 forks source link

Orphaning of streams #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by h3sm...@gmail.com on 7 Oct 2009 at 4:54

GoogleCodeExporter commented 9 years ago
Technically, this should really be two different bugs but they are one in the 
same 

Original comment by h3sm...@gmail.com on 7 Oct 2009 at 5:01

GoogleCodeExporter commented 9 years ago
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.

Original comment by jond...@gmail.com on 22 Dec 2009 at 5:52