25 #include "MmTsy_numberOfSlots.h" |
25 #include "MmTsy_numberOfSlots.h" |
26 |
26 |
27 // ============================ MEMBER FUNCTIONS =============================== |
27 // ============================ MEMBER FUNCTIONS =============================== |
28 |
28 |
29 |
29 |
30 CMmPacketContextTsy::CMmPacketContextTsy() |
30 CMmPacketContextTsy::CMmPacketContextTsy(): |
|
31 iReqHandleType(EMultimodePacketContextReqHandleUnknown) |
31 { |
32 { |
32 } |
33 } |
33 |
34 |
34 CMmPacketContextTsy* CMmPacketContextTsy::NewL( |
35 CMmPacketContextTsy* CMmPacketContextTsy::NewL( |
35 CMmPacketServiceTsy* const aMmPacketService, |
36 CMmPacketServiceTsy* const aMmPacketService, |
161 TFLOGSTRING3( "TSY: CMmPacketContextTsy::ExtFunc. IPC: %d Context name:%S", aIpc, &iContextName ); |
162 TFLOGSTRING3( "TSY: CMmPacketContextTsy::ExtFunc. IPC: %d Context name:%S", aIpc, &iContextName ); |
162 |
163 |
163 TInt ret( KErrNone ); |
164 TInt ret( KErrNone ); |
164 TInt trapError( KErrNone ); |
165 TInt trapError( KErrNone ); |
165 |
166 |
|
167 #ifdef ADD_REMOVE_PACKETFILTER_DEFECT_FIXED // search for this up from bottom of file |
|
168 // Ensure the ReqHandleType is unset. |
|
169 // This will detect cases where this method indirectly calls itself |
|
170 // (e.g. servicing a client call that causes a self-reposting notification to complete and thus repost). |
|
171 // Such cases are not supported because iReqHandleType is in the context of this class instance, |
|
172 // not this request, and we don't want the values set by the inner request and the outer request |
|
173 // interfering with each other. |
|
174 __ASSERT_DEBUG(iReqHandleType==EMultimodePacketContextReqHandleUnknown, User::Invariant()); |
|
175 #else |
166 // Reset last tsy request type |
176 // Reset last tsy request type |
167 iReqHandleType = EMultimodePacketContextReqHandleUnknown; |
177 iReqHandleType = EMultimodePacketContextReqHandleUnknown; |
|
178 #endif |
168 |
179 |
169 // Trap the call of DoExtFuncL |
180 // Trap the call of DoExtFuncL |
170 TRAP( trapError, ret = DoExtFuncL( aTsyReqHandle, aIpc, aPackage ) ); |
181 TRAP( trapError, ret = DoExtFuncL( aTsyReqHandle, aIpc, aPackage ) ); |
171 |
182 |
172 if ( KErrNone != trapError ) |
183 if ( KErrNone != trapError ) |
184 #ifdef REQHANDLE_TIMER |
195 #ifdef REQHANDLE_TIMER |
185 SetTypeOfResponse( iReqHandleType, aTsyReqHandle ); |
196 SetTypeOfResponse( iReqHandleType, aTsyReqHandle ); |
186 #else |
197 #else |
187 iTsyReqHandleStore->SetTsyReqHandle( iReqHandleType, aTsyReqHandle ); |
198 iTsyReqHandleStore->SetTsyReqHandle( iReqHandleType, aTsyReqHandle ); |
188 #endif // REQHANDLE_TIMER |
199 #endif // REQHANDLE_TIMER |
|
200 #ifdef ADD_REMOVE_PACKETFILTER_DEFECT_FIXED // search for this up from bottom of file |
|
201 // We've finished with this value now. Clear it so it doesn't leak |
|
202 // up to any other instances of this method down the call stack |
|
203 iReqHandleType = EMultimodePacketContextReqHandleUnknown; |
|
204 #endif |
189 } |
205 } |
190 |
206 |
191 return KErrNone; |
207 return KErrNone; |
192 } |
208 } |
193 |
209 |
537 TFLOGSTRING3( "TSY: CMmPacketContextTsy::CancelService. IPC: %d Handle:%d", |
553 TFLOGSTRING3( "TSY: CMmPacketContextTsy::CancelService. IPC: %d Handle:%d", |
538 aIpc, aTsyReqHandle ); |
554 aIpc, aTsyReqHandle ); |
539 |
555 |
540 TInt ret( KErrNone ); |
556 TInt ret( KErrNone ); |
541 TTsyReqHandle reqHandle( NULL ); |
557 TTsyReqHandle reqHandle( NULL ); |
|
558 |
|
559 #ifdef ADD_REMOVE_PACKETFILTER_DEFECT_FIXED // search for this up from bottom of file |
|
560 // Ensure the ReqHandleType is unset. |
|
561 // This will detect cases where this method indirectly calls itself |
|
562 // (e.g. servicing a client call that causes a self-reposting notification to complete and thus repost). |
|
563 // Such cases are not supported because iReqHandleType is in the context of this class instance, |
|
564 // not this request, and we don't want the values set by the inner request and the outer request |
|
565 // interfering with each other. |
|
566 __ASSERT_DEBUG(iReqHandleType==EMultimodePacketContextReqHandleUnknown, User::Invariant()); |
|
567 #else |
542 // Reset last tsy request type |
568 // Reset last tsy request type |
543 iReqHandleType = EMultimodePacketContextReqHandleUnknown; |
569 iReqHandleType = EMultimodePacketContextReqHandleUnknown; |
|
570 #endif |
544 |
571 |
545 switch ( aIpc ) |
572 switch ( aIpc ) |
546 { |
573 { |
547 // TSY has started a request and it is not possible to then cancel |
574 // TSY has started a request and it is not possible to then cancel |
548 // this request. The best thing for the TSY to do in this case is to |
575 // this request. The best thing for the TSY to do in this case is to |
622 // Reset tsy request handle |
649 // Reset tsy request handle |
623 iTsyReqHandleStore->ResetTsyReqHandle( iReqHandleType ); |
650 iTsyReqHandleStore->ResetTsyReqHandle( iReqHandleType ); |
624 |
651 |
625 // Complete request |
652 // Complete request |
626 CMmPacketContextTsy::ReqCompleted( aTsyReqHandle, KErrCancel ); |
653 CMmPacketContextTsy::ReqCompleted( aTsyReqHandle, KErrCancel ); |
|
654 #ifdef ADD_REMOVE_PACKETFILTER_DEFECT_FIXED // search for this up from bottom of file |
|
655 // We've finished with this value now. Clear it so it doesn't leak |
|
656 // up to any other instances of this method down the call stack |
|
657 iReqHandleType = EMultimodePacketContextReqHandleUnknown; |
|
658 #endif |
627 } |
659 } |
628 |
660 |
629 return ret; |
661 return ret; |
630 } |
662 } |
631 |
663 |
1379 EMultimodePacketContextAddMediaAuthorization ); |
1411 EMultimodePacketContextAddMediaAuthorization ); |
1380 } |
1412 } |
1381 else |
1413 else |
1382 { |
1414 { |
1383 #ifdef USING_CTSY_DISPATCHER |
1415 #ifdef USING_CTSY_DISPATCHER |
1384 // Distinguish between RemovePacketFilter and AddPacketFilter |
1416 // Distinguish between RemovePacketFilter and AddPacketFilter.. |
|
1417 |
|
1418 // There is a hang defect lurking here. |
|
1419 // |
|
1420 // To show the defect, add and run the following test case (you could |
|
1421 // copy from CCTsyPacketServicesFU::TestUseCase0007L): |
|
1422 // - Add a packet filter. Wait for the request to complete. |
|
1423 // - Remove the packet filter. (don't wait for completion) |
|
1424 // - Add another packet filter. |
|
1425 // - Wait for removal to complete (WILL HANG but obviously shouldn't). |
|
1426 // |
|
1427 // The reason for this hang is that there's a single completion method |
|
1428 // for both Add and Remove packet filter functions down in the CTSY |
|
1429 // (dispatcher mode only). |
|
1430 // |
|
1431 // If a client calls RemovePacketFilter, then immediately |
|
1432 // calls AddPacketFilter (before the RemovePacketFilter has |
|
1433 // completed), the iReqHandleType data member will already have been |
|
1434 // updated to be EMultimodePacketContextAddPacketFilter.. |
|
1435 // So the code under the else below (that searches for the |
|
1436 // RemovePacketFilter reqHandle and completes it) will never get run. |
|
1437 // Thus the RemovePacketFilter call will hang. |
|
1438 // |
|
1439 // Fixing this requires that some other variable (NOT iReqHandleType) |
|
1440 // is used to record that an add or a remove action is outstanding. |
|
1441 // |
|
1442 // When this defect has been addressed, please treat all the sections marked |
|
1443 // ADD_REMOVE_PACKETFILTER_DEFECT_FIXED above as defined, and delete any |
|
1444 // else blocks. This will then assert that the iReqHandleType doesn't |
|
1445 // leak between calls. Which will protect us against any other such hang |
|
1446 // bugs in the future. |
|
1447 // This is the change that I was trying to apply when I ran into this defect. |
|
1448 // See Perforce CL#1755436 |
|
1449 // Rob Lundie Hill |
|
1450 |
1385 if (iReqHandleType == EMultimodePacketContextRemovePacketFilter) |
1451 if (iReqHandleType == EMultimodePacketContextRemovePacketFilter) |
1386 { |
1452 { |
1387 reqHandle = iTsyReqHandleStore->ResetTsyReqHandle( EMultimodePacketContextRemovePacketFilter ); |
1453 reqHandle = iTsyReqHandleStore->ResetTsyReqHandle( EMultimodePacketContextRemovePacketFilter ); |
1388 } |
1454 } |
1389 else |
1455 else |