syncmlfw/common/sosserver_clientapi/src/NSmlClientAPI.cpp
changeset 73 ae69c2e8bc34
parent 0 b497e44ab2fc
--- a/syncmlfw/common/sosserver_clientapi/src/NSmlClientAPI.cpp	Tue Sep 28 17:53:08 2010 +0530
+++ b/syncmlfw/common/sosserver_clientapi/src/NSmlClientAPI.cpp	Fri Oct 15 11:46:45 2010 +0530
@@ -111,9 +111,26 @@
 	if ( res != KErrNone )
 		{
 		res = LaunchServerL();
-		User::LeaveIfError( res );
-		res = CreateSession( KSOSServerName, KServerVersion, KDefaultMessageSlots );
+		if ( res == KErrNone )
+		{
+			res = CreateSession( KSOSServerName, KServerVersion, KDefaultMessageSlots );
 		}
+		else if ( res == KErrAlreadyExists )
+		{
+			TInt retryCount = 3;
+				
+			while ( res != KErrNone && retryCount )
+			{
+				res = CreateSession( KSOSServerName, KServerVersion, KDefaultMessageSlots );
+				if( res != KErrNone )
+				{
+				 // wait 1.5 seconds to give the server a chance to reach its serviceable state
+				 User::After( 1500000 );
+				 --retryCount;
+				}
+			}
+		}
+		}	
 
 	User::LeaveIfError( res );
 	
@@ -139,10 +156,10 @@
 	if ( !iEventCallback )
 		{
 		// callback not yet created, create
-		iEventCallback = new (ELeave) CSmlActiveCallback( *this );
+		iEventCallback = new (ELeave) CSmlActiveCallback( *this );		
 		}
 	
-	iEventCallback->SetEventObserverL( aEventObserver );
+	iEventCallback->SetEventObserverL( aEventObserver );	
 	
 	_DBG_FILE("RSyncMLSession::RequestEventL(): end");
 	}
@@ -178,9 +195,10 @@
 		// callback not yet created, create
 		iEventCallback = new (ELeave) CSmlActiveCallback( *this );
 		}
-
+	
 	iEventCallback->SetProgressObserverL( aProgressObserver );
-	
+	  
+		
 	_DBG_FILE("RSyncMLSession::RequestProgressL(): end");
 	}