229 |
229 |
230 CNodeActivityBase* a = NULL; |
230 CNodeActivityBase* a = NULL; |
231 for (TInt i = iActivities.Count() - 1; i>=0 && a==NULL; i--) |
231 for (TInt i = iActivities.Count() - 1; i>=0 && a==NULL; i--) |
232 { |
232 { |
233 CNodeActivityBase* act = iActivities[i]; |
233 CNodeActivityBase* act = iActivities[i]; |
234 const TNodeId& postedTo = act->iPostedToId; |
234 const TNodeId& postedTo = act->PostedToNodeId(); |
235 if (!act->IsIdle() |
235 if (!act->IsIdle() |
236 && (postedTo.IsNull() || aContext.iSender == postedTo) |
236 && (postedTo.IsNull() || aContext.iSender == postedTo) |
237 && (recipient->NodeCtx() == act->ActivityId())) |
237 && (recipient->NodeCtx() == act->ActivityId())) |
238 { |
238 { |
239 a = act; |
239 a = act; |
427 context.iNodeActivity = NULL; |
427 context.iNodeActivity = NULL; |
428 } |
428 } |
429 } |
429 } |
430 } |
430 } |
431 |
431 |
|
432 |
432 EXPORT_C void AMMNodeBase::AbortActivitiesOriginatedBy(TNodeContextBase& aContext, const TNodeId& aCommsId, TBool aIsNodeBeingDestroyed) |
433 EXPORT_C void AMMNodeBase::AbortActivitiesOriginatedBy(TNodeContextBase& aContext, const TNodeId& aCommsId, TBool aIsNodeBeingDestroyed) |
433 { |
434 { |
434 CNodeActivityBase* caller = aContext.iNodeActivity; |
435 CNodeActivityBase* caller = aContext.iNodeActivity; |
435 TBool abortAll = aCommsId.IsNull(); |
436 TBool abortAll = aCommsId.IsNull(); |
436 |
437 |
437 for (TInt i = iActivities.Count() - 1; i>=0; i--) |
438 for (TInt i = iActivities.Count() - 1; i>=0; i--) |
438 { |
439 { |
439 aContext.iNodeActivity = iActivities[i]; |
440 aContext.iNodeActivity = iActivities[i]; |
|
441 |
|
442 if (!abortAll && aContext.iNodeActivity->PostedToNodeId() == aCommsId) |
|
443 {//clear postedto if a leaver has been set as a postedto at any of the running activities. |
|
444 //No other messages will ever come from the leaver and it is not gonna be safe to forward TCancels |
|
445 //to the leaver, so at least postedto must be cleared to avoid the crash. It could be speculated that |
|
446 //if the postedto is still set, then either the postedto node failed to respond or the local activity failed to |
|
447 //clear postedto when it had responded. Worth putting a speculative ASSERT here to catch misdeeds. |
|
448 |
|
449 //clearing postedto shouldn't be done in here (AbortActivitiesOriginatedBy), but I (RZ) have expressed my disrespect to the |
|
450 //this method before and the suggestion that it should go (replaced by a CancelActivitiesOriginatedBy). |
|
451 //So instead of introducing another method that loops through activities i decided to piggyback the function in an |
|
452 //existing method. Note that the final logic should be based on RNodeInterfaces and not TNodeIds. |
|
453 aContext.iNodeActivity->ClearPostedTo(); |
|
454 } |
440 |
455 |
441 // We dont want to abort already idle activities or they may error. |
456 // We dont want to abort already idle activities or they may error. |
442 if(aContext.iNodeActivity->IsIdle()) |
457 if(aContext.iNodeActivity->IsIdle()) |
443 { |
458 { |
444 continue; |
459 continue; |