Skip to content

Commit

Permalink
Another test fix for #85
Browse files Browse the repository at this point in the history
  • Loading branch information
Redth committed Jan 29, 2013
1 parent d6979f8 commit 35b531d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions PushSharp.Apple/ApplePushChannel.cs
Expand Up @@ -72,6 +72,7 @@ public override PlatformType PlatformType
}

object sentLock = new object();
object connectLock = new object();
object streamWriteLock = new object();
int reconnectDelay = 3000;
float reconnectBackoffMultiplier = 1.5f;
Expand Down Expand Up @@ -127,7 +128,8 @@ protected override void SendNotification(Common.Notification notification)

if (isOkToSend)
{
Connect();
lock(connectLock)
Connect();

try
{
Expand Down Expand Up @@ -264,6 +266,9 @@ void Cleanup()
{
while (true)
{
lock(connectLock)
Connect();

bool wasRemoved = false;

lock (sentLock)
Expand All @@ -272,7 +277,7 @@ void Cleanup()
if (sentNotifications.Count > 0)
{
//Don't expire any notifications while we are in a connecting state
if ((connected || CancelToken.IsCancellationRequested) || (!connected && QueuedNotificationCount <= 0))
if (connected || CancelToken.IsCancellationRequested)
{
//Get the oldest sent message
var n = sentNotifications[0];
Expand Down Expand Up @@ -307,7 +312,7 @@ void Cleanup()
Thread.Sleep(250);
}
}

void Connect()
{
//Keep trying to connect
Expand Down

0 comments on commit 35b531d

Please sign in to comment.