91 ASSERT(selectionInfo); // should always be there |
91 ASSERT(selectionInfo); // should always be there |
92 |
92 |
93 return (iContext.iMessage.IsMessage<TCFDataClient::TStart>() && |
93 return (iContext.iMessage.IsMessage<TCFDataClient::TStart>() && |
94 TCprConfigModifier::Is(selectionInfo->CprConfig(), TCprConfigModifier::ESCPRHangOnStart)); |
94 TCprConfigModifier::Is(selectionInfo->CprConfig(), TCprConfigModifier::ESCPRHangOnStart)); |
95 } |
95 } |
96 } |
96 |
|
97 DEFINE_SMELEMENT(TCancelPreviousSelfRequest, NetStateMachine::MStateTransition, DummySCPRStates::TContext) |
|
98 void TCancelPreviousSelfRequest::DoL() |
|
99 { |
|
100 iContext.iNodeActivity->PostRequestTo(iContext.Node().Id(), Messages::TEBase::TCancel().CRef()); |
|
101 } |
|
102 |
|
103 DEFINE_SMELEMENT(TRebindSelf, NetStateMachine::MStateTransition, DummySCPRStates::TContext) |
|
104 void TRebindSelf::DoL() |
|
105 { |
|
106 iContext.iNodeActivity->PostRequestTo(iContext.Node().Id(), TCFDataClient::TBindTo(Messages::TNodeId::NullId()).CRef()); |
|
107 } |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 CrazyIdle::~CrazyIdle() |
|
113 { |
|
114 ASSERT(PostedToNodeId()==Messages::TNodeId::NullId()); |
|
115 } |
|
116 |
|
117 MeshMachine::CNodeActivityBase* CrazyIdle::NewL(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode) |
|
118 { |
|
119 return new(ELeave)CrazyIdle(aActivitySig, aNode); |
|
120 } |
|
121 |
|
122 DEFINE_SMELEMENT(CrazyIdle::TAwaitingCancelled, NetStateMachine::MState, DummySCPRStates::TContext) |
|
123 TBool CrazyIdle::TAwaitingCancelled::Accept() |
|
124 { |
|
125 if (iContext.iMessage.IsMessage<Messages::TEBase::TError>()) |
|
126 { |
|
127 ASSERT(iContext.iNodeActivity); |
|
128 iContext.iNodeActivity->SetPostedTo(iContext.iNodeActivity->SoleOriginator().Peer().RecipientId()); |
|
129 } |
|
130 return EFalse; |
|
131 } |
|
132 } |
|
133 |
|
134 |
97 |
135 |
98 namespace DummySCprParamsRequest |
136 namespace DummySCprParamsRequest |
99 { |
137 { |
100 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
138 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
101 DECLARE_DEFINE_NODEACTIVITY(ECFActivityParamRequest, dummySCprParamRequest, TCFScpr::TSetParamsRequest) |
139 DECLARE_DEFINE_NODEACTIVITY(ECFActivityParamRequest, dummySCprParamRequest, TCFScpr::TSetParamsRequest) |
132 THROUGH_NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendStarted, MeshMachine::TNoTag) |
170 THROUGH_NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendStarted, MeshMachine::TNoTag) |
133 LAST_NODEACTIVITY_ENTRY(KNoTag, DummySCPRStates::TRaiseGranted) |
171 LAST_NODEACTIVITY_ENTRY(KNoTag, DummySCPRStates::TRaiseGranted) |
134 NODEACTIVITY_END() |
172 NODEACTIVITY_END() |
135 } |
173 } |
136 |
174 |
|
175 namespace CrazyIdleActivity |
|
176 { |
|
177 //CrazyIdleActivity is used to test yet another angle of the meshmachine cancelling behaviour. |
|
178 //What it does is: |
|
179 //(1) responds to TIdle with an attempt to bind the sender, then, without waiting for the bind to complete |
|
180 //(2) responds to TIdle normally (by deleting the sender) |
|
181 //(3) cancells the bind request |
|
182 //What it tests is: |
|
183 //For two related nodes and upon the teardown of their relation there is an obligation to synchronise the activities |
|
184 //running on the nodes and awaiting responses from each other. This obligation is put on the requestee, i.e.: a node that perfomes |
|
185 //an activity on behalf of a leaving node should gracefully terminate that activity (by having the activity respond to the requestor. |
|
186 //That obligation therefore doesn't rest on the requestor (someone, but not everyone, needs to do something). |
|
187 //There's trivial race condition arising from this distribution of responsibility, i.e.: the requestor activity may decide to |
|
188 //cancel when the relation is being terminated and TCancel may hit void. Activities must be resilient to this and not send |
|
189 //TCancels to disappearing nodes. CrazyIdleActivity tests precislely this: it initaites an activity (TBindTo), then tears down the |
|
190 //relation and cancels the previously initiated activity (TBindTo). CrazyIdleActivity must wrap up gracefully. |
|
191 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityDataClientIdle, crazyIdle, TCFControlProvider::TIdle, DummySCPRStates::CrazyIdle::NewL) |
|
192 FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingDataClientIdle, MeshMachine::TNoTag) |
|
193 //Issue TBindTo to self (this will then bind the data client reporting TIdle). Wait for BindTo activity to start before |
|
194 //telling the dataclient to go away (TDestroy) as otherwise TBindTo won't make it in sending TBindTo to the dataclient. |
|
195 THROUGH_NODEACTIVITY_ENTRY(KNoTag, DummySCPRStates::TRebindSelf, DummySCPRStates::TNoTagWaitForBindTo) |
|
196 THROUGH_NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::THandleDataClientIdle, MeshMachine::TNoTag) |
|
197 //There's an additional test peformed by DummySCPRStates::CrazyIdle::TAwaitingCancelled. The state sets the postedto of CrazyIdle |
|
198 //to point at the dataclient and CrazyIdle::~CrazyIdle asserts that that postedto is cleared. Currently PostedTo isn't cleared automatically - some people |
|
199 //argued that it shouldn't and that activities should clear postedto whenever it's good for them. Unfortunatelly some activities are |
|
200 //a bit lousy doing this and in result they can store a postedto pointing a node that has responded to the request a long time ago |
|
201 //and above all a node that may have a long time ago left. A facility has been added to meshmachine to clear postedto when the node pointed |
|
202 //at it actually leaves. This facility is tested collectivelly by DummySCPRStates::CrazyIdle::TAwaitingCancelled and CrazyIdle::~CrazyIdle |
|
203 NODEACTIVITY_ENTRY(KNoTag, DummySCPRStates::TCancelPreviousSelfRequest, DummySCPRStates::CrazyIdle::TAwaitingCancelled, DummySCPRStates::TNoTagWaitNoDataClients) |
|
204 LAST_NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing) |
|
205 NODEACTIVITY_END() |
|
206 } |
|
207 |
|
208 |
|
209 |
137 // Activity Map For test-code ridden scpr |
210 // Activity Map For test-code ridden scpr |
138 namespace DummySCPRStates |
211 namespace DummySCPRStates |
139 { |
212 { |
140 DEFINE_ACTIVITY_MAP(stateMap) |
213 DEFINE_ACTIVITY_MAP(stateMap) |
141 ACTIVITY_MAP_ENTRY(DummySCprParamsRequest, dummySCprParamRequest) |
214 ACTIVITY_MAP_ENTRY(DummySCprParamsRequest, dummySCprParamRequest) |
142 ACTIVITY_MAP_ENTRY(DummyBindToActivity, dummyBindTo) |
215 ACTIVITY_MAP_ENTRY(DummyBindToActivity, dummyBindTo) |
143 ACTIVITY_MAP_ENTRY(DummyBreakStartActivity, dummyBreakSCPrStart) |
216 ACTIVITY_MAP_ENTRY(DummyBreakStartActivity, dummyBreakSCPrStart) |
144 ACTIVITY_MAP_ENTRY(DummyStartActivity, dummySCPrStart) |
217 ACTIVITY_MAP_ENTRY(DummyStartActivity, dummySCPrStart) |
|
218 ACTIVITY_MAP_ENTRY(CrazyIdleActivity, crazyIdle) |
145 ACTIVITY_MAP_END_BASE(SCprActivities, coreSCprActivities) |
219 ACTIVITY_MAP_END_BASE(SCprActivities, coreSCprActivities) |
146 } |
220 } |
147 |
221 |
148 // Activity Map For vanilla cpr |
222 // Activity Map For vanilla cpr |
149 namespace VanillaDummySCPRStates |
223 namespace VanillaDummySCPRStates |