telephonyserverplugins/common_tsy/commontsy/src/mmpacket/Cmmpacketservicetsy.cpp
branchRCL_3
changeset 7 fe8b59ab9fa0
parent 0 3553901f7fa8
child 9 2492a6e4aed7
--- a/telephonyserverplugins/common_tsy/commontsy/src/mmpacket/Cmmpacketservicetsy.cpp	Mon Mar 15 12:45:06 2010 +0200
+++ b/telephonyserverplugins/common_tsy/commontsy/src/mmpacket/Cmmpacketservicetsy.cpp	Wed Mar 31 23:24:02 2010 +0300
@@ -36,7 +36,8 @@
 
 // ======== MEMBER FUNCTIONS ========
 
-CMmPacketServiceTsy::CMmPacketServiceTsy()
+CMmPacketServiceTsy::CMmPacketServiceTsy():
+    iReqHandleType(EMultimodePacketServiceReqHandleUnknown)
     {
     }
 
@@ -775,6 +776,7 @@
     if ( RPacketService::EAttachWhenPossible == iAttachMode )
         {
         SetAttachModeL( &iAttachMode );
+        iReqHandleType = EMultimodePacketServiceReqHandleUnknown;
         }
     }
     
@@ -1966,9 +1968,14 @@
     TInt ret( KErrNone );
     TInt trapError( KErrNone );
 
-    // Reset request handle type
-    iReqHandleType = EMultimodePacketServiceReqHandleUnknown;
-
+    // Ensure the ReqHandleType is unset.
+    // This will detect cases where this method indirectly calls itself
+    // (e.g. servicing a client call that causes a self-reposting notification to complete and thus repost).
+    // Such cases are not supported because iReqHandleType is in the context of this class instance,
+    // not this request, and we don't want the values set by the inner request and the outer request
+    // interfering with each other.
+    __ASSERT_DEBUG(iReqHandleType==EMultimodePacketServiceReqHandleUnknown, User::Invariant());
+    
     // Set tsy request handle
     iTsyReqHandle = aTsyReqHandle;
 
@@ -1993,7 +2000,9 @@
 #else
         iTsyReqHandleStore->SetTsyReqHandle( iReqHandleType, iTsyReqHandle );
 #endif // REQHANDLE_TIMER
-
+        // We've finished with this value now. Clear it so it doesn't leak
+        //  up to any other instances of this method down the call stack
+        iReqHandleType = EMultimodePacketServiceReqHandleUnknown;
         }
 
     return KErrNone;
@@ -2355,8 +2364,13 @@
 
     TInt ret( KErrNone );
     
-    // Reset last tsy request type
-    iReqHandleType = EMultimodePacketServiceReqHandleUnknown;
+    // Ensure the ReqHandleType is unset.
+    // This will detect cases where this method indirectly calls itself
+    // (e.g. servicing a client call that causes a self-reposting notification to complete and thus repost).
+    // Such cases are not supported because iReqHandleType is in the context of this class instance,
+    // not this request, and we don't want the values set by the inner request and the outer request
+    // interfering with each other.
+    __ASSERT_DEBUG(iReqHandleType==EMultimodePacketServiceReqHandleUnknown, User::Invariant());
 
     // When the clients close their sub-sessions (eg. by calling
     // RPacketService::Close), they may not have cancelled all their
@@ -2368,7 +2382,6 @@
 
     switch ( aIpc )
         {
-
         case EPacketNotifyContextAdded:
             iNotifyDataPointers.iContextAdded = NULL;
             iReqHandleType = EMultimodePacketServiceNotifyContextAdded;
@@ -2471,6 +2484,10 @@
 
         // Complete request with KErrCancel
         CMmPacketServiceTsy::ReqCompleted( aTsyReqHandle, KErrCancel );
+        
+        // We've finished with this value now. Clear it so it doesn't leak
+        //  up to any other instances of this method down the call stack
+        iReqHandleType = EMultimodePacketServiceReqHandleUnknown;
         }
 
     return ret;
@@ -2875,7 +2892,7 @@
     }
 
 //----------------------------------------------------------------------------
-// CMmPacketServiceTsy::CompleteUpdateMbmsMonitorServiceListL
+// CMmPacketServiceTsy::CompleteUpdateMbmsMonitorServiceList
 // Completes update monitored service list request
 //----------------------------------------------------------------------------
 //
@@ -2886,14 +2903,16 @@
 	TFLOGSTRING( "TSY: CMmPacketServiceTsy::CompleteUpdateMbmsMonitorServiceListL." );
 
 	TInt result= aResult;
+	TInt err(KErrNone);
 	// Reset request handle. Returns the deleted request handle
 	const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
 	        EMultimodePacketServiceUpdateMBMSMonitorServiceList ) );
 	        
 	if( aResult == KErrNone )
 		{
-		result = iMBMSMonitoredList->ProcessEntriesL(NULL, iActionType);
-        CompleteNotifyMbmsServiceAvailabilityChangeL( NULL, aResult );		
+		TRAP( err, result = iMBMSMonitoredList->ProcessEntriesL( NULL, iActionType ) );
+		if ( !err )
+		    TRAP( err, CompleteNotifyMbmsServiceAvailabilityChangeL( NULL, aResult ) );		
 		}
 	//there were problem managing entries
 	else if( (aResult == KErrMbmsImpreciseServiceEntries) && (aDataPackage != NULL) )
@@ -2904,15 +2923,20 @@
 		// Check failed entries exists and add succesful entries to main list
 		if( failedMonitorEntries != NULL )
 			{
-			iMBMSMonitoredList->ProcessEntriesL( failedMonitorEntries, iActionType );
+			TRAP( err, iMBMSMonitoredList->ProcessEntriesL( failedMonitorEntries, iActionType ) );
 			}
 		else // There was a general error, don't add anything to main list
 			{
-			iMBMSMonitoredList->ResetTempListL();
+			TRAP( err, iMBMSMonitoredList->ResetTempListL() );
 			}
 		}
 	 if( EMultimodePacketServiceReqHandleUnknown != reqHandle )
 		 {
+         // If there was an error due to a function leaving, complete to the client with that error.
+         if (err)
+             {
+             result = err;
+             }
 		 //complete with error to client
 		 CMmPacketServiceTsy::ReqCompleted( reqHandle, result );
 		 }