commsfwsupport/commselements/meshmachine/src/mm_node.cpp
branchRCL_3
changeset 17 9ddb1d67ebaf
parent 12 8b5d60ce1e94
child 18 9644881fedd0
equal deleted inserted replaced
15:51722b10598b 17:9ddb1d67ebaf
   456       	        {
   456       	        {
   457       	        //Abort for one originator only (Cancel the activity if last originator & error just this one originator)
   457       	        //Abort for one originator only (Cancel the activity if last originator & error just this one originator)
   458       	        TInt idx = aContext.iNodeActivity->FindOriginator(aCommsId);
   458       	        TInt idx = aContext.iNodeActivity->FindOriginator(aCommsId);
   459       	        if (KErrNotFound!=idx)
   459       	        if (KErrNotFound!=idx)
   460       	        	{
   460       	        	{
       
   461                     TBool canSend = ETrue;
   461 					if(aContext.iNodeActivity->iOriginators.Count() == 1) // only if this is the final originator
   462 					if(aContext.iNodeActivity->iOriginators.Count() == 1) // only if this is the final originator
   462 						{
   463 						{
   463 						aContext.iNodeActivity->SetError(KErrAbort);
   464 						aContext.iNodeActivity->SetError(KErrAbort);
   464            	        	aContext.iNodeActivity->Cancel(aContext);
   465            	        	aContext.iNodeActivity->Cancel(aContext);
       
   466            	        	//This is a workaround for CCommsBinderRequest. The proper fix is to abolish the concept of aborting activities.
       
   467                         //Aborting activities is a bad idea as an aborted activity isn't given a chance to perform graceful cleanup.
       
   468            	        	//Today activities get aborted because their orinators urgently leave. I.e.: they are trully leaving now! Last orders!
       
   469            	        	//It is then incorrect to leave the activity d'tor to finish the wrap up - because the node will be gone by then.
       
   470            	        	//So whether and when to send an error must be decided here, by this generic code that has no clue on the subtleties
       
   471            	        	//of individual activities. If there is no abort - there is urgent leavers. They send TLeaveRequest and they politely
       
   472            	        	//wait for the completion and all this code is unnecessary.
       
   473            	        	canSend = (aContext.iNodeActivity->Error() != KErrNone);
   465 						}
   474 						}
   466 					
   475                     
   467     					
       
   468                     //In the "quiet mode", when the hosting node is being destroyed, we can not afford sending
   476                     //In the "quiet mode", when the hosting node is being destroyed, we can not afford sending
   469                     //an error to the node as it would hit void.
   477                     //an error to the node as it would hit void.
   470                     TNodePeerId& originator = aContext.iNodeActivity->iOriginators[idx];
   478                     TNodePeerId& originator = aContext.iNodeActivity->iOriginators[idx];
   471                     TBool canSend = !((aIsNodeBeingDestroyed && originator == aContext.NodeId())
   479                     canSend &= !((aIsNodeBeingDestroyed && originator == aContext.NodeId())
   472                         || aContext.iMessage.IsMessage<TEChild::TLeft>());
   480                         || aContext.iMessage.IsMessage<TEChild::TLeft>()); 
   473                     if (canSend)
   481                     if (canSend)
   474                         {
   482                         {
   475                         aContext.iNodeActivity->PostToOriginator(originator, TEBase::TError(aContext.iMessage.MessageId(), KErrAbort).CRef());
   483                         aContext.iNodeActivity->PostToOriginator(originator, TEBase::TError(aContext.iMessage.MessageId(), KErrAbort).CRef());
   476                         }
   484                         }
   477     					
   485                     aContext.iNodeActivity->RemoveOriginator(idx);
   478 
       
   479 	 	        	aContext.iNodeActivity->RemoveOriginator(idx);
       
   480       	        	}
   486       	        	}
   481       	        }
   487       	        }
   482             }
   488             }
   483         }
   489         }
   484     aContext.iReturn = KErrNone;
   490     aContext.iReturn = KErrNone;