hotspotfw/hsclient/src/hssiaphandler.cpp
changeset 32 5bbf13e885a0
parent 25 001d4d78e350
child 36 682dd021f9be
--- a/hotspotfw/hsclient/src/hssiaphandler.cpp	Mon May 24 21:11:39 2010 +0300
+++ b/hotspotfw/hsclient/src/hssiaphandler.cpp	Thu May 27 10:28:52 2010 +0300
@@ -30,6 +30,10 @@
 #include <cmmanagerdef.h>
 #include <cmdestinationext.h>
 
+// CONSTANTS
+const TInt  KRetryCount   = 20;
+const TInt  KRetryTimeout = 100000;
+
 using namespace CMManager;
 
 // ============================ MEMBER FUNCTIONS ===============================
@@ -199,9 +203,27 @@
             *((CMDBField<TUint32>*)iWLANRecord->GetFieldByIdL(KCDTIdWlanEnableWpaPsk)) = aSettings.iEnableWpaPsk;
             }
         }
-    // now update the access point
-    iWLANRecord->ModifyL( *dbSession );
+    // Update access point, be prepared that Commsdat might be locked
+    TInt errCode( KErrLocked );
+    TInt retryCount( 0 );
     
+    while( errCode == KErrLocked && retryCount < KRetryCount )
+        {
+        TRAP( errCode, iWLANRecord->ModifyL( *dbSession ) );
+
+        if ( errCode == KErrLocked )
+            {	
+            User::After( KRetryTimeout );
+            }	
+        retryCount++;	        
+        }
+    
+    if ( errCode )
+        {
+        // override previous ret value only when error happened        	    	
+        ret = errCode;
+        }
+
     CleanupStack::PopAndDestroy( dbSession );
     DEBUG("CHssIapHandler::ChangeSettingsL DONE");
 	return ret;