author | hgs |
Mon, 01 Nov 2010 20:11:36 +0000 | |
changeset 299 | b5a01337d018 |
parent 286 | 48e57fb1237e |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32\sfile\sf_request.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include "sf_std.h" |
|
19 |
#include "sf_file_cache.h" |
|
20 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
21 |
#include "sf_notifier.h" |
|
22 |
#endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
23 |
||
24 |
||
25 |
TParse dummyP; |
|
26 |
RMessage2 dummyM; |
|
27 |
||
28 |
CFsClientMessageRequest* RequestAllocator::iFreeHead; |
|
29 |
CFsClientMessageRequest* RequestAllocator::iCloseHead; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
30 |
TInt RequestAllocator::iRequestCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
31 |
TInt RequestAllocator::iFreeCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
32 |
TInt RequestAllocator::iRequestCountPeak; |
0 | 33 |
RFastLock RequestAllocator::iCacheLock; |
34 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
35 |
TMsgOperation* OperationAllocator::iFreeHead; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
36 |
TInt OperationAllocator::iRequestCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
37 |
TInt OperationAllocator::iFreeCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
38 |
TInt OperationAllocator::iRequestCountPeak; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
39 |
RFastLock OperationAllocator::iCacheLock; |
0 | 40 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
41 |
TInt RequestAllocator::Initialise() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
42 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
43 |
iFreeHead = NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
44 |
iCloseHead = NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
45 |
iRequestCount = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
46 |
iFreeCount = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
47 |
iRequestCountPeak = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
48 |
return iCacheLock.CreateLocal(); |
0 | 49 |
} |
50 |
||
51 |
void RequestAllocator::FreeRequest(CFsClientMessageRequest* aRequest) |
|
52 |
// |
|
53 |
//free request |
|
54 |
// |
|
55 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
56 |
__CACHE_PRINT1(_L("RequestAllocator::FreeRequest for %x"), aRequest); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
57 |
ASSERT(aRequest != NULL); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
58 |
iCacheLock.Wait(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
59 |
if (iFreeCount >= KFreeCountMax) |
0 | 60 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
61 |
delete aRequest; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
62 |
ASSERT(iRequestCount > 0); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
63 |
iRequestCount--; |
0 | 64 |
} |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
65 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
66 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
67 |
aRequest->SetSubstedDrive(NULL); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
68 |
aRequest->iNext = iFreeHead; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
69 |
iFreeHead=aRequest; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
70 |
iFreeCount++; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
71 |
} |
0 | 72 |
iCacheLock.Signal(); |
73 |
} |
|
74 |
||
75 |
void RequestAllocator::OpenSubFailed(CSessionFs* aSession) |
|
76 |
// |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
77 |
// Move request from closed list to free list |
0 | 78 |
// |
79 |
{ |
|
80 |
__ASSERT_DEBUG(iCloseHead!=NULL,Fault(ERequestAllocatorOpenSubFailed)); // On arriving here Close Queue is supposed to be empty |
|
81 |
__ASSERT_ALWAYS(aSession!=NULL,Fault(ERequestAllocatorOpenSubFailed)); |
|
82 |
if (iCloseHead==NULL) |
|
83 |
{ |
|
84 |
return; |
|
85 |
} |
|
86 |
iCacheLock.Wait(); |
|
87 |
CFsClientMessageRequest* rp = iCloseHead; |
|
88 |
iCloseHead = rp->iNext; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
89 |
iCacheLock.Signal(); |
0 | 90 |
|
91 |
// dec the number of closed requests owned by this session |
|
92 |
aSession->CloseRequestCountDec(); |
|
93 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
94 |
__CACHE_PRINT1(_L("RequestAllocator::OpenSubFailed() IsAllocated %d"), rp->IsAllocated()); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
95 |
FreeRequest(rp); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
96 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
97 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
98 |
CFsClientMessageRequest* RequestAllocator::GetRequest() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
99 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
100 |
// Get request from the free queue |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
101 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
102 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
103 |
CFsClientMessageRequest* request; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
104 |
if (iFreeHead == NULL) |
0 | 105 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
106 |
request = new CFsClientMessageRequest; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
107 |
if (request) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
108 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
109 |
iRequestCount++; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
110 |
iRequestCountPeak = Max(iRequestCountPeak, iRequestCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
111 |
} |
0 | 112 |
} |
113 |
else |
|
114 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
115 |
request = iFreeHead; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
116 |
iFreeHead = iFreeHead->iNext; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
117 |
request->iNext = NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
118 |
iFreeCount--; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
119 |
ASSERT(iFreeCount >= 0); |
0 | 120 |
} |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
121 |
return request; |
0 | 122 |
} |
123 |
||
124 |
TInt RequestAllocator::GetMessageRequest(const TOperation& aOperation,const RMessage2& aMessage,CFsClientMessageRequest* &aRequest) |
|
125 |
// |
|
126 |
// tries to get a pre allocated message from the cache. Failing that allocates one indivisualy |
|
127 |
// |
|
128 |
{ |
|
129 |
if(aOperation.IsOpenSubSess()) |
|
130 |
{ |
|
131 |
__CACHE_PRINT(_L("++RequestAllocator::GetMessageRequest() Open sub-sess")); |
|
132 |
iCacheLock.Wait(); |
|
133 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
134 |
aRequest = GetRequest(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
135 |
CFsClientMessageRequest* closeRequest = GetRequest(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
136 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
137 |
if (aRequest == NULL || closeRequest == NULL) |
0 | 138 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
139 |
delete aRequest; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
140 |
delete closeRequest; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
141 |
iCacheLock.Signal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
142 |
return KErrNoMemory; |
0 | 143 |
} |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
144 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
145 |
closeRequest->iNext = iCloseHead; //set second one as a reserved (tail) close request |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
146 |
iCloseHead = closeRequest; |
0 | 147 |
|
148 |
((CSessionFs*) aMessage.Session())->CloseRequestCountInc(); |
|
149 |
} |
|
150 |
else if(aOperation.IsCloseSubSess()) |
|
151 |
{ |
|
152 |
__CACHE_PRINT(_L("++RequestAllocator::GetMessageRequest() Close sub-sess")); |
|
153 |
||
154 |
CFsObject* pO = SessionObjectFromHandle(aMessage.Int3(),0,reinterpret_cast<CSessionFs*>(aMessage.Session())); |
|
155 |
if(!pO) |
|
156 |
return KErrBadHandle; |
|
157 |
||
158 |
CObjPromotion* pm = (CObjPromotion*)pO; |
|
159 |
TInt function = aMessage.Function(); |
|
160 |
switch(function & KIpcFunctionMask) |
|
161 |
{ |
|
162 |
case EFsFormatSubClose: |
|
163 |
{ |
|
164 |
if(pm->UniqueID() != Formats->UniqueID()) |
|
165 |
{ |
|
166 |
return KErrBadHandle; |
|
167 |
} |
|
168 |
break; |
|
169 |
} |
|
170 |
case EFsDirSubClose: |
|
171 |
{ |
|
172 |
if(pm->UniqueID() != Dirs->UniqueID()) |
|
173 |
{ |
|
174 |
return KErrBadHandle; |
|
175 |
} |
|
176 |
break; |
|
177 |
} |
|
178 |
case EFsFileSubClose: |
|
179 |
{ |
|
180 |
if(pm->UniqueID() != FileShares->UniqueID()) |
|
181 |
{ |
|
182 |
return KErrBadHandle; |
|
183 |
} |
|
184 |
break; |
|
185 |
} |
|
186 |
case EFsRawSubClose: |
|
187 |
{ |
|
188 |
if(pm->UniqueID() != RawDisks->UniqueID()) |
|
189 |
{ |
|
190 |
return KErrBadHandle; |
|
191 |
} |
|
192 |
break; |
|
193 |
} |
|
194 |
case EFsPluginSubClose: |
|
195 |
{ |
|
196 |
if(pm->UniqueID() != FsPluginManager::iPluginConns->UniqueID()) |
|
197 |
{ |
|
198 |
return KErrBadHandle; |
|
199 |
} |
|
200 |
break; |
|
201 |
} |
|
202 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
203 |
case EFsNotificationSubClose: |
|
204 |
{ |
|
205 |
if(pm->UniqueID() != FsNotificationManager::iNotifyRequests->UniqueID()) |
|
206 |
{ |
|
207 |
return KErrBadHandle; |
|
208 |
} |
|
209 |
break; |
|
210 |
} |
|
211 |
#endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
212 |
default: |
|
213 |
Fault(ECloseSubBadMessage); |
|
214 |
} |
|
215 |
||
216 |
iCacheLock.Wait(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
217 |
ASSERT(iCloseHead); |
0 | 218 |
aRequest = iCloseHead; |
219 |
iCloseHead = aRequest->iNext; |
|
220 |
((CSessionFs*) aMessage.Session())->CloseRequestCountDec(); |
|
221 |
aRequest->iNext = NULL; |
|
222 |
||
223 |
if((function & KIpcFunctionMask)!= EFsPluginSubClose && |
|
224 |
(function & KIpcFunctionMask)!= EFsNotificationSubClose) |
|
225 |
{ |
|
226 |
aRequest->SetDrive(&TheDrives[((CFsDispatchObject*)pO)->DriveNumber()]); |
|
227 |
} |
|
228 |
||
229 |
aRequest->SetScratchValue((TUint)pO); |
|
230 |
} |
|
231 |
else |
|
232 |
{ |
|
233 |
__CACHE_PRINT(_L("++RequestAllocator::GetMessageRequest() ")); |
|
234 |
iCacheLock.Wait(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
235 |
aRequest = GetRequest(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
236 |
if (aRequest == NULL) |
0 | 237 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
238 |
iCacheLock.Signal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
239 |
return KErrNoMemory; |
0 | 240 |
} |
241 |
} |
|
242 |
||
243 |
aRequest->Init(); |
|
244 |
||
245 |
iCacheLock.Signal(); |
|
246 |
||
247 |
// pre-allocate any TParse objects needed by this request |
|
248 |
if (aRequest->AllocParseObjects(aOperation) != KErrNone) |
|
249 |
{ |
|
250 |
aRequest->Free(); |
|
251 |
return KErrNoMemory; |
|
252 |
} |
|
253 |
||
254 |
__CACHE_PRINT1(_L("--RequestAllocator::GetMessageRequest() allocated %08x"), aRequest); |
|
255 |
||
256 |
return KErrNone; |
|
257 |
} |
|
258 |
||
259 |
||
260 |
#if defined(_USE_CONTROLIO) || defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
261 |
TInt RequestAllocator::CloseCount() |
|
262 |
{TInt count=0; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
263 |
iCacheLock.Wait(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
264 |
|
0 | 265 |
CFsClientMessageRequest* list=iCloseHead; |
266 |
while(list!=NULL) |
|
267 |
{ |
|
268 |
count++; |
|
269 |
list=list->iNext; |
|
270 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
271 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
272 |
iCacheLock.Signal(); |
0 | 273 |
return(count); |
274 |
} |
|
275 |
TInt RequestAllocator::FreeCount() |
|
276 |
{ |
|
277 |
TInt count=0; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
278 |
iCacheLock.Wait(); |
0 | 279 |
CFsClientMessageRequest* list=iFreeHead; |
280 |
while(list!=NULL) |
|
281 |
{ |
|
282 |
count++; |
|
283 |
list=list->iNext; |
|
284 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
285 |
ASSERT(count == iFreeCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
286 |
iCacheLock.Signal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
287 |
return(count); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
288 |
} |
0 | 289 |
#endif |
290 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
291 |
TInt OperationAllocator::Initialise() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
292 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
293 |
iFreeHead = NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
294 |
iRequestCount = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
295 |
iFreeCount = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
296 |
return iCacheLock.CreateLocal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
297 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
298 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
299 |
void OperationAllocator::FreeOperation(TMsgOperation* aOperation) |
0 | 300 |
// |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
301 |
// free Operation |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
302 |
// |
0 | 303 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
304 |
__CACHE_PRINT1(_L("RequestAllocator::FreeOperation() returning %x to free list"), aOperation); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
305 |
ASSERT(aOperation != NULL); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
306 |
iCacheLock.Wait(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
307 |
if (iFreeCount >= KFreeCountMax) |
0 | 308 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
309 |
delete aOperation; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
310 |
ASSERT(iRequestCount > 0); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
311 |
iRequestCount--; |
0 | 312 |
} |
313 |
else |
|
314 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
315 |
aOperation->iNext = iFreeHead; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
316 |
iFreeHead = aOperation; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
317 |
iFreeCount++; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
318 |
} |
0 | 319 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
320 |
iCacheLock.Signal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
321 |
} |
0 | 322 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
323 |
TInt OperationAllocator::GetOperation(TMsgOperation* &aOperation) |
0 | 324 |
// |
325 |
// tries to get a pre allocated subop from the cache. Failing that allocates one individualy |
|
326 |
// |
|
327 |
{ |
|
328 |
||
329 |
__CACHE_PRINT(_L("RequestAllocator::GetOperation() ")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
330 |
|
0 | 331 |
iCacheLock.Wait(); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
332 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
333 |
TInt r = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
334 |
if (iFreeHead == NULL) |
0 | 335 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
336 |
aOperation = new TMsgOperation; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
337 |
if (aOperation == NULL) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
338 |
r = KErrNoMemory; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
339 |
else |
0 | 340 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
341 |
iRequestCount++; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
342 |
iRequestCountPeak = Max(iRequestCountPeak, iRequestCount); |
0 | 343 |
} |
344 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
345 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
346 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
347 |
aOperation = iFreeHead; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
348 |
iFreeHead = iFreeHead->iNext; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
349 |
iFreeCount--; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
350 |
ASSERT(iFreeCount >= 0); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
351 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
352 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
353 |
if (aOperation) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
354 |
aOperation->iNext = aOperation->iPrev = NULL; |
0 | 355 |
|
356 |
iCacheLock.Signal(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
357 |
return r; |
0 | 358 |
} |
359 |
||
360 |
||
361 |
CFsRequest::CFsRequest() |
|
362 |
// |
|
363 |
// |
|
364 |
// |
|
365 |
: iOperation(NULL),iDriveNumber(KDriveInvalid) |
|
366 |
{} |
|
367 |
||
368 |
CFsRequest::~CFsRequest() |
|
369 |
// |
|
370 |
// |
|
371 |
// |
|
273 | 372 |
{ |
373 |
Close(); |
|
374 |
} |
|
0 | 375 |
|
376 |
void CFsRequest::Set(const TOperation& aOperation,CSessionFs* aSession) |
|
377 |
// |
|
378 |
// |
|
379 |
// |
|
380 |
{ |
|
381 |
||
382 |
SetState(EReqStateInitialise); |
|
383 |
||
384 |
iOperation = const_cast<TOperation*>(&aOperation); |
|
273 | 385 |
Set(aSession); |
0 | 386 |
} |
387 |
||
388 |
void CFsRequest::Set(CSessionFs* aSession) |
|
389 |
// |
|
390 |
// |
|
391 |
// |
|
392 |
{ |
|
393 |
__ASSERT_DEBUG(iOperation,Fault(EBaseRequestSet1)); |
|
394 |
||
395 |
SetState(EReqStateInitialise); |
|
396 |
||
397 |
iIsCompleted = iOperation->IsCompleted(); |
|
398 |
iError = KErrNone; |
|
399 |
iDriveNumber = KDriveInvalid; |
|
400 |
iCurrentPlugin = NULL; |
|
401 |
iOwnerPlugin = NULL; |
|
402 |
iDirectToDrive = EFalse; |
|
403 |
iClientThreadId= 0; |
|
273 | 404 |
iFlags &= ~(EFreeChanged | EPostInterceptEnabled | EPostOperation | EFsDspObjOpen); |
405 |
||
0 | 406 |
iScratchValue = 0; |
273 | 407 |
|
408 |
OpenSession(aSession); |
|
0 | 409 |
} |
410 |
||
411 |
||
412 |
TParse& CFsRequest::Src() |
|
413 |
// |
|
414 |
// |
|
415 |
// |
|
416 |
{ |
|
417 |
Fault(EBaseRequestSrc); |
|
418 |
return(dummyP); |
|
419 |
} |
|
420 |
||
421 |
TParse& CFsRequest::Dest() |
|
422 |
// |
|
423 |
// |
|
424 |
// |
|
425 |
{ |
|
426 |
Fault(EBaseRequestDest); |
|
427 |
return(dummyP); |
|
428 |
} |
|
429 |
||
430 |
TDrive* CFsRequest::Drive() |
|
431 |
// |
|
432 |
// |
|
433 |
// |
|
434 |
{ |
|
435 |
Fault(EBaseRequestDrive); |
|
436 |
return(NULL); |
|
437 |
} |
|
438 |
||
439 |
TDrive* CFsRequest::SubstedDrive() |
|
440 |
// |
|
441 |
// |
|
442 |
// |
|
443 |
{ |
|
444 |
Fault(EBaseRequestSubstedDrive); |
|
445 |
return(NULL); |
|
446 |
} |
|
447 |
||
448 |
void CFsRequest::SetDrive(TDrive* /*aDrive*/) |
|
449 |
// |
|
450 |
// |
|
451 |
// |
|
452 |
{ |
|
453 |
Fault(EBaseRequestSetDrive); |
|
454 |
} |
|
455 |
||
456 |
void CFsRequest::SetSubstedDrive(TDrive* /*aDrive*/) |
|
457 |
// |
|
458 |
// |
|
459 |
// |
|
460 |
{ |
|
461 |
Fault(EBaseRequestSetSubstedDrive); |
|
462 |
} |
|
463 |
||
464 |
TInt CFsRequest::GetSlot(TFsPluginRequest::TF32ArgType aType) |
|
465 |
{ |
|
466 |
if(iOperation->Arg(0) == aType) return 0; |
|
467 |
if(iOperation->Arg(1) == aType) return 1; |
|
468 |
if(iOperation->Arg(2) == aType) return 2; |
|
469 |
if(iOperation->Arg(3) == aType) return 3; |
|
470 |
||
471 |
return(-1); |
|
472 |
} |
|
473 |
||
299 | 474 |
/* |
475 |
* Gets the UID of the client |
|
476 |
*/ |
|
477 |
TUid CFsRequest::Uid() |
|
478 |
{ |
|
479 |
return TUid::Null(); |
|
480 |
} |
|
481 |
||
482 |
TUid CFsMessageRequest::Uid() |
|
483 |
{ |
|
484 |
return iUID; |
|
485 |
} |
|
486 |
||
0 | 487 |
|
488 |
TBool CFsMessageRequest::IsNotifierSpecific() const |
|
489 |
{ |
|
490 |
#ifndef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
491 |
return EFalse; |
|
492 |
#else |
|
493 |
TInt function = iOperation->iFunction; |
|
494 |
return( function == EFsNotificationAdd || |
|
495 |
function == EFsNotificationBuffer || |
|
496 |
function == EFsNotificationCancel || |
|
497 |
function == EFsNotificationOpen || |
|
498 |
function == EFsNotificationRemove || |
|
499 |
function == EFsNotificationRequest || |
|
500 |
function == EFsNotificationSubClose); |
|
501 |
#endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
502 |
} |
|
503 |
||
504 |
||
505 |
TBool CFsMessageRequest::IsNotifierSupported() const |
|
506 |
{ |
|
507 |
#ifndef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
508 |
return EFalse; |
|
509 |
#else |
|
510 |
TInt function = iOperation->iFunction; |
|
511 |
return( function == EFsDelete || |
|
512 |
function == EFsRmDir || |
|
513 |
function == EFsMkDir || |
|
514 |
function == EFsFormatNext || |
|
515 |
function == EFsFileCreate || |
|
516 |
function == EFsFileReplace || |
|
517 |
function == EFsFileRename || |
|
518 |
function == EFsRename || |
|
519 |
function == EFsReplace || |
|
520 |
function == EFsSetDriveName || |
|
521 |
function == EFsSetVolume || |
|
522 |
function == EFsSetEntry || |
|
523 |
function == EFsFileSetAtt || |
|
524 |
function == EFsFileSet || |
|
525 |
function == EFsMountFileSystem || |
|
526 |
function == EFsDismountFileSystem || |
|
527 |
function == EFsFileSetSize || |
|
528 |
function == EFsFileWrite || |
|
529 |
function == EFsFileWriteDirty || |
|
530 |
function == EFsRawDiskWrite || |
|
531 |
function == EFsMountFileSystemScan); |
|
532 |
#endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
533 |
} |
|
534 |
||
535 |
||
536 |
TInt CFsRequest::Read(TFsPluginRequest::TF32ArgType aType, TInt& aVal) |
|
537 |
{ |
|
538 |
if(iOperation->Arg(0) == aType) { aVal = Message().Int0(); return KErrNone; } |
|
539 |
if(iOperation->Arg(1) == aType) { aVal = Message().Int1(); return KErrNone; } |
|
540 |
if(iOperation->Arg(2) == aType) { aVal = Message().Int2(); return KErrNone; } |
|
541 |
if(iOperation->Arg(3) == aType) { aVal = Message().Int3(); return KErrNone; } |
|
542 |
||
543 |
return KErrNotSupported; |
|
544 |
} |
|
545 |
||
546 |
||
547 |
TInt CFsRequest::Read(TFsPluginRequest::TF32ArgType aType, TUint& aVal) |
|
548 |
{ |
|
549 |
if(iOperation->Arg(0) == aType) { aVal = (TUint)Message().Int0(); return KErrNone; } |
|
550 |
if(iOperation->Arg(1) == aType) { aVal = (TUint)Message().Int1(); return KErrNone; } |
|
551 |
if(iOperation->Arg(2) == aType) { aVal = (TUint)Message().Int2(); return KErrNone; } |
|
552 |
if(iOperation->Arg(3) == aType) { aVal = (TUint)Message().Int3(); return KErrNone; } |
|
553 |
||
554 |
return KErrNotSupported; |
|
555 |
} |
|
556 |
||
557 |
TInt CFsRequest::Read(TFsPluginRequest::TF32ArgType aType, TInt64& aVal) |
|
558 |
{ |
|
559 |
TPckg<TInt64> pkVal(aVal); |
|
560 |
// EFsFileLock, EFsFileUnLock, EFsFileSeek and EFsFileSetSize need special treatment |
|
561 |
if(iOperation->Arg(0) == aType) |
|
562 |
{ |
|
563 |
if((iOperation->Function()==EFsFileLock) || |
|
564 |
(iOperation->Function()==EFsFileUnLock) ) |
|
565 |
{ |
|
566 |
if(IsDescData(KMsgPtr0)) |
|
567 |
Read(KMsgPtr0,pkVal); |
|
568 |
else |
|
569 |
aVal = MAKE_TINT64(0, Message().Int0()); // Position is unsigned value |
|
570 |
return KErrNone; |
|
571 |
} |
|
572 |
||
573 |
if((iOperation->Function()==EFsFileSeek) || // Seek offset (input paramater) |
|
574 |
(iOperation->Function()==EFsFileSize) || // Size (output paramater) |
|
575 |
(iOperation->Function()==EFsFileSetSize) ) // Size to be set (input paramater) |
|
576 |
{ |
|
577 |
if(IsDescData(KMsgPtr0)) |
|
578 |
Read(KMsgPtr0,pkVal); |
|
579 |
else |
|
580 |
aVal = Message().Int0(); // Seek offset / Size is signed value |
|
581 |
return KErrNone; |
|
582 |
} |
|
583 |
||
584 |
aVal = Message().Int0(); |
|
585 |
return KErrNone; |
|
586 |
} |
|
587 |
||
588 |
// EFsFileLock and EFsFileUnLock need special treatment |
|
589 |
if(iOperation->Arg(1) == aType) |
|
590 |
{ |
|
591 |
if((iOperation->Function()==EFsFileLock) || |
|
592 |
(iOperation->Function()==EFsFileUnLock) ) |
|
593 |
{ |
|
594 |
if(IsDescData(KMsgPtr1)) |
|
595 |
Read(KMsgPtr1,pkVal); |
|
596 |
else |
|
597 |
aVal = MAKE_TINT64(0, Message().Int1()); // Length is unsigned value |
|
598 |
return KErrNone; |
|
599 |
} |
|
600 |
||
601 |
aVal = Message().Int1(); |
|
602 |
return KErrNone; |
|
603 |
} |
|
604 |
||
605 |
// EFsFileRead, EFsFileWrite, EFsFileSeek and EFsReadFileSection need special treatment |
|
606 |
if(iOperation->Arg(2) == aType) |
|
607 |
{ |
|
608 |
if((iOperation->Function()==EFsFileRead) || |
|
609 |
(iOperation->Function()==EFsFileWrite) ) |
|
610 |
{ |
|
611 |
if(IsDescData(KMsgPtr2)) |
|
612 |
Read(KMsgPtr2,pkVal); |
|
613 |
else |
|
614 |
{ |
|
615 |
if(Message().Int2() == (TInt)I64LOW(KCurrentPosition64)) |
|
616 |
aVal = KCurrentPosition64; // Position is KCurrentPosition64 (-1) |
|
617 |
else |
|
618 |
aVal = MAKE_TINT64(0,Message().Int2()); // Position is unsigned value |
|
619 |
} |
|
620 |
return KErrNone; |
|
621 |
} |
|
622 |
||
623 |
if(iOperation->Function()==EFsFileSeek) |
|
624 |
{ |
|
625 |
if(IsDescData(KMsgPtr2)) |
|
626 |
Read(KMsgPtr2,pkVal); |
|
627 |
else |
|
628 |
aVal = Message().Int2(); // New position is signed value |
|
629 |
return KErrNone; |
|
630 |
} |
|
631 |
||
632 |
if(iOperation->Function()==EFsReadFileSection) |
|
633 |
{ |
|
634 |
if(IsDescData(KMsgPtr2)) |
|
635 |
Read(KMsgPtr2,pkVal); |
|
636 |
else |
|
637 |
aVal = MAKE_TINT64(0,Message().Int2()); // Position is unsigned value |
|
638 |
return KErrNone; |
|
639 |
} |
|
640 |
||
641 |
aVal = Message().Int2(); |
|
642 |
return KErrNone; |
|
643 |
} |
|
644 |
||
645 |
if(iOperation->Arg(3) == aType) |
|
646 |
{ |
|
647 |
aVal = Message().Int3(); |
|
648 |
return KErrNone; |
|
649 |
} |
|
650 |
||
651 |
return KErrNotSupported; |
|
652 |
} |
|
653 |
||
273 | 654 |
void CFsRequest::OpenDispatchObject(const TInt64& aValue) |
0 | 655 |
{ |
273 | 656 |
CloseDispatchObject(); |
657 |
||
658 |
iScratchValue = aValue; |
|
659 |
||
660 |
if (I64LOW(iScratchValue) && iOperation && (iOperation->iFlags & EFsDspObj)) |
|
661 |
{ |
|
662 |
((CFsDispatchObject*) I64LOW(iScratchValue))->Open(); |
|
663 |
iFlags |= EFsDspObjOpen; |
|
664 |
} |
|
665 |
} |
|
666 |
||
667 |
void CFsRequest::CloseDispatchObject() |
|
668 |
{ |
|
669 |
if (iFlags & EFsDspObjOpen) |
|
0 | 670 |
{ |
671 |
((CFsDispatchObject*) I64LOW(iScratchValue))->Close(); |
|
273 | 672 |
iFlags &= ~EFsDspObjOpen; |
0 | 673 |
} |
273 | 674 |
} |
675 |
||
676 |
void CFsRequest::OpenSession(CSessionFs* aSession) |
|
677 |
{ |
|
678 |
CloseSession(); |
|
679 |
iSession = aSession; |
|
680 |
if (iSession) |
|
681 |
iSession->Open(); |
|
0 | 682 |
} |
683 |
||
273 | 684 |
void CFsRequest::CloseSession() |
685 |
{ |
|
686 |
if (iSession) |
|
687 |
{ |
|
688 |
iSession->Close(); |
|
689 |
iSession = NULL; |
|
690 |
} |
|
691 |
} |
|
692 |
||
693 |
void CFsRequest::Close() |
|
694 |
{ |
|
695 |
SetScratchValue(0); // this should close the CFsObject |
|
696 |
CloseSession(); |
|
697 |
} |
|
0 | 698 |
|
699 |
TInt CFsRequest::Read(TFsPluginRequest::TF32ArgType aType, TDes8& aDes, TInt aOffset) |
|
700 |
{ |
|
701 |
TInt slot = GetSlot(aType); |
|
702 |
if(slot >= 0) |
|
703 |
return Read(slot, aDes, aOffset); |
|
704 |
return KErrNotSupported; |
|
705 |
} |
|
706 |
||
707 |
||
708 |
TInt CFsRequest::Read(TFsPluginRequest::TF32ArgType aType, TDes16& aDes, TInt aOffset) |
|
709 |
{ |
|
710 |
TInt slot = GetSlot(aType); |
|
711 |
if(slot >= 0) |
|
712 |
return Read(slot, aDes, aOffset); |
|
713 |
return KErrNotSupported; |
|
714 |
} |
|
715 |
||
716 |
||
717 |
TInt CFsRequest::Write(TFsPluginRequest::TF32ArgType aType, const TDesC8& aDes, TInt aOffset) |
|
718 |
{ |
|
719 |
TInt slot = GetSlot(aType); |
|
720 |
if(slot >= 0) |
|
721 |
return Write(slot, aDes, aOffset); |
|
722 |
return KErrNotSupported; |
|
723 |
} |
|
724 |
||
725 |
||
726 |
TInt CFsRequest::Write(TFsPluginRequest::TF32ArgType aType, const TDesC16& aDes, TInt aOffset) |
|
727 |
{ |
|
728 |
TInt slot = GetSlot(aType); |
|
729 |
if(slot >= 0) |
|
730 |
return Write(slot, aDes, aOffset); |
|
731 |
return KErrNotSupported; |
|
732 |
} |
|
733 |
||
734 |
||
735 |
TInt CFsRequest::Read(const TInt aMsgPtr,TDes8 &aDes) |
|
736 |
{ |
|
737 |
if (Message().Handle() == KLocalMessageHandle) |
|
738 |
{ |
|
739 |
TDesC8* pDes = (TDesC8*) ((const RLocalMessage*) &Message())->Arg(aMsgPtr); |
|
740 |
if (aDes.MaxLength() < pDes->Length()) |
|
741 |
return KErrTooBig; |
|
742 |
aDes.Copy(*pDes); |
|
743 |
return KErrNone; |
|
744 |
} |
|
745 |
||
746 |
return Message().Read(aMsgPtr,aDes,0); |
|
747 |
} |
|
748 |
||
749 |
||
750 |
TInt CFsRequest::Read(const TInt aMsgPtr,TDes8 &aDes,TInt anOffset) |
|
751 |
{ |
|
752 |
if (Message().Handle() == KLocalMessageHandle) |
|
753 |
{ |
|
754 |
TDesC8* pDes = (TDesC8*) ((const RLocalMessage*) &Message())->Arg(aMsgPtr); |
|
755 |
if (aDes.MaxLength() < pDes->Length() + anOffset) |
|
756 |
return KErrTooBig; |
|
757 |
aDes.SetLength(pDes->Length() + anOffset); |
|
758 |
aDes.MidTPtr(anOffset).Copy(*pDes); |
|
759 |
return KErrNone; |
|
760 |
} |
|
761 |
||
762 |
return Message().Read(aMsgPtr,aDes,anOffset); |
|
763 |
} |
|
764 |
||
765 |
||
766 |
TInt CFsRequest::Read(const TInt aMsgPtr,TDes16 &aDes) |
|
767 |
{ |
|
768 |
if (Message().Handle() == KLocalMessageHandle) |
|
769 |
{ |
|
770 |
TDesC16* pDes = (TDesC16*) ((const RLocalMessage*) &Message())->Arg(aMsgPtr); |
|
771 |
if (aDes.MaxLength() < pDes->Length()) |
|
772 |
return KErrTooBig; |
|
773 |
aDes.Copy(*pDes); |
|
774 |
return KErrNone; |
|
775 |
} |
|
776 |
||
777 |
return Message().Read(aMsgPtr,aDes,0); |
|
778 |
} |
|
779 |
||
780 |
||
781 |
TInt CFsRequest::Read(const TInt aMsgPtr,TDes16 &aDes,TInt anOffset) |
|
782 |
{ |
|
783 |
if (Message().Handle() == KLocalMessageHandle) |
|
784 |
{ |
|
785 |
TDesC16* pDes = (TDesC16*) ((const RLocalMessage*) &Message())->Arg(aMsgPtr); |
|
786 |
if (aDes.MaxLength() < pDes->Length() + anOffset) |
|
787 |
return KErrTooBig; |
|
788 |
aDes.SetLength(pDes->Length() + anOffset); |
|
789 |
aDes.MidTPtr(anOffset).Copy(*pDes); |
|
790 |
return KErrNone; |
|
791 |
} |
|
792 |
||
793 |
return Message().Read(aMsgPtr,aDes,anOffset); |
|
794 |
} |
|
795 |
||
796 |
||
797 |
TInt CFsRequest::Write(const TInt aMsgNum,const TDesC8 &aDes) |
|
798 |
{ |
|
799 |
if (Message().Handle() == KLocalMessageHandle) |
|
800 |
{ |
|
801 |
TDes8* pDes = (TDes8*) ((const RLocalMessage*) &Message())->Arg(aMsgNum); |
|
802 |
if (pDes->MaxLength() < aDes.Length()) |
|
803 |
return KErrTooBig; |
|
804 |
pDes->Copy(aDes); |
|
805 |
return KErrNone; |
|
806 |
} |
|
807 |
||
808 |
return Message().Write(aMsgNum,aDes,0); |
|
809 |
} |
|
810 |
||
811 |
||
812 |
TInt CFsRequest::Write(const TInt aMsgNum,const TDesC8 &aDes,TInt anOffset) |
|
813 |
{ |
|
814 |
if (Message().Handle() == KLocalMessageHandle) |
|
815 |
{ |
|
816 |
TDes8* pDes = (TDes8*) ((const RLocalMessage*) &Message())->Arg(aMsgNum); |
|
817 |
if (pDes->MaxLength() < aDes.Length() + anOffset) |
|
818 |
return KErrTooBig; |
|
819 |
pDes->SetLength(aDes.Length() + anOffset); |
|
820 |
pDes->MidTPtr(anOffset).Copy(aDes); |
|
821 |
return KErrNone; |
|
822 |
} |
|
823 |
||
824 |
return Message().Write(aMsgNum,aDes,anOffset); |
|
825 |
} |
|
826 |
||
827 |
||
828 |
TInt CFsRequest::Write(const TInt aMsgNum,const TDesC16 &aDes) |
|
829 |
{ |
|
830 |
if (Message().Handle() == KLocalMessageHandle) |
|
831 |
{ |
|
832 |
TDes16* pDes = (TDes16*) ((const RLocalMessage*) &Message())->Arg(aMsgNum); |
|
833 |
if (pDes->MaxLength() < aDes.Length()) |
|
834 |
return KErrTooBig; |
|
835 |
pDes->Copy(aDes); |
|
836 |
return KErrNone; |
|
837 |
} |
|
838 |
||
839 |
return Message().Write(aMsgNum,aDes,0); |
|
840 |
} |
|
841 |
||
842 |
||
843 |
TInt CFsRequest::Write(const TInt aMsgNum,const TDesC16 &aDes,TInt anOffset) |
|
844 |
{ |
|
845 |
if (Message().Handle() == KLocalMessageHandle) |
|
846 |
{ |
|
847 |
TDes16* pDes = (TDes16*) ((const RLocalMessage*) &Message())->Arg(aMsgNum); |
|
848 |
if (pDes->MaxLength() < aDes.Length() + anOffset) |
|
849 |
return KErrTooBig; |
|
850 |
pDes->SetLength(aDes.Length() + anOffset); |
|
851 |
pDes->MidTPtr(anOffset).Copy(aDes); |
|
852 |
return KErrNone; |
|
853 |
} |
|
854 |
||
855 |
return Message().Write(aMsgNum,aDes,anOffset); |
|
856 |
} |
|
857 |
||
858 |
||
859 |
void CFsRequest::ReadL(const TInt aMsgPtr,TDes8 &aDes) |
|
860 |
{ User::LeaveIfError(Read(aMsgPtr,aDes)); } |
|
861 |
||
862 |
void CFsRequest::ReadL(const TInt aMsgPtr,TDes8 &aDes,TInt anOffset) |
|
863 |
{ User::LeaveIfError(Read(aMsgPtr,aDes,anOffset)); } |
|
864 |
||
865 |
void CFsRequest::ReadL(const TInt aMsgPtr,TDes16 &aDes) |
|
866 |
{ User::LeaveIfError(Read(aMsgPtr,aDes)); } |
|
867 |
||
868 |
void CFsRequest::ReadL(const TInt aMsgPtr,TDes16 &aDes,TInt anOffset) |
|
869 |
{ User::LeaveIfError(Read(aMsgPtr,aDes,anOffset)); } |
|
870 |
||
871 |
void CFsRequest::WriteL(const TInt aMsgNum,const TDesC8 &aDes) |
|
872 |
{ User::LeaveIfError(Write(aMsgNum,aDes)); } |
|
873 |
||
874 |
void CFsRequest::WriteL(const TInt aMsgNum,const TDesC8 &aDes,TInt anOffset) |
|
875 |
{ User::LeaveIfError(Write(aMsgNum,aDes,anOffset)); } |
|
876 |
||
877 |
void CFsRequest::WriteL(const TInt aMsgNum,const TDesC16 &aDes) |
|
878 |
{ User::LeaveIfError(Write(aMsgNum,aDes)); } |
|
879 |
||
880 |
void CFsRequest::WriteL(const TInt aMsgNum,const TDesC16 &aDes,TInt anOffset) |
|
881 |
{ User::LeaveIfError(Write(aMsgNum,aDes,anOffset)); } |
|
882 |
||
883 |
||
884 |
/** |
|
885 |
@param aMsgNum message argument index |
|
886 |
@return client side descriptor length |
|
887 |
*/ |
|
888 |
TInt CFsRequest::GetDesLength(const TInt aMsgNum) |
|
889 |
{ |
|
890 |
if (Message().Handle() == KLocalMessageHandle) |
|
891 |
{ |
|
892 |
TDes8* pDes = (TDes8*) ((const RLocalMessage*) &Message())->Arg(aMsgNum); |
|
893 |
return pDes->Length(); |
|
894 |
} |
|
895 |
else |
|
896 |
{ |
|
897 |
return Message().GetDesLength(aMsgNum); |
|
898 |
} |
|
899 |
} |
|
900 |
||
901 |
const RMessage2& CFsRequest::Message() |
|
902 |
// |
|
903 |
// |
|
904 |
// |
|
905 |
{ |
|
906 |
Fault(EBaseRequestMessage); |
|
907 |
return(dummyM); |
|
908 |
} |
|
909 |
||
910 |
||
911 |
||
912 |
void CFsMessageRequest::Set(const RMessage2& aMessage,CSessionFs* aSession) |
|
913 |
// |
|
914 |
// For reuseable request |
|
915 |
// |
|
916 |
{ |
|
917 |
iMessage=aMessage; |
|
918 |
iDrive=NULL; |
|
919 |
iSubstedDrive=NULL; |
|
920 |
CFsRequest::Set(aSession); |
|
921 |
SetFreeChanged(EFalse); |
|
922 |
EnablePostIntercept(ETrue); |
|
923 |
} |
|
924 |
||
925 |
||
299 | 926 |
void CFsMessageRequest::Set(const RMessage2& aMessage,const TOperation& aOperation,CSessionFs* aSession, TUid aUid) |
0 | 927 |
// |
928 |
// |
|
929 |
// |
|
930 |
{ |
|
299 | 931 |
iUID = aUid; |
0 | 932 |
iCurrentPlugin=NULL; |
933 |
iMessage=aMessage; |
|
934 |
iDrive=NULL; |
|
935 |
iSubstedDrive=NULL; |
|
936 |
CFsRequest::Set(aOperation,aSession); |
|
937 |
SetFreeChanged(EFalse); |
|
938 |
EnablePostIntercept(ETrue); |
|
939 |
} |
|
940 |
||
941 |
void CFsMessageRequest::Process() |
|
942 |
// |
|
943 |
// Process the request - (passing to a plugin or a drive thread) |
|
944 |
// |
|
945 |
{ |
|
946 |
__THRD_PRINT3(_L("CFsMessageRequest::Process() req %08x state %d plugin 0x%x"), this, iReqState, iCurrentPlugin); |
|
947 |
||
948 |
// initialise request - if not initialised already |
|
949 |
if (iReqState == EReqStateInitialise) |
|
950 |
{ |
|
951 |
TInt r = DoInitialise(); |
|
952 |
if (r == EReqActionComplete) |
|
953 |
{ |
|
954 |
return; |
|
955 |
} |
|
956 |
else if (r == EReqActionBusy) // request postponed ? |
|
957 |
{ |
|
958 |
SetState(EReqStateInitialise); |
|
959 |
Dispatch(EFalse); |
|
960 |
return; |
|
961 |
} |
|
962 |
else if (r == KErrNone && iCurrentPlugin) // dispatch to plugin thread ? |
|
963 |
{ |
|
964 |
Dispatch(EFalse); |
|
965 |
return; |
|
966 |
} |
|
967 |
} |
|
968 |
||
969 |
if(iCurrentPlugin) |
|
970 |
{ |
|
971 |
if (IsPostOperation()) |
|
972 |
{ |
|
973 |
ProcessPostOperation(); |
|
974 |
return; |
|
975 |
} |
|
976 |
||
977 |
if(!IsPluginSpecific()) |
|
978 |
{ |
|
979 |
ProcessPreOperation(); |
|
980 |
return; |
|
981 |
} |
|
982 |
} |
|
983 |
||
984 |
||
985 |
// Is there a PostInitialise function ? |
|
986 |
if (iReqState == EReqStatePostInitialise) |
|
987 |
{ |
|
988 |
TInt r = PostInitialise(); |
|
989 |
if (r == EReqActionComplete) |
|
990 |
{ |
|
991 |
return; |
|
992 |
} |
|
993 |
else if (r == EReqActionBusy) // request postponed ? |
|
994 |
{ |
|
995 |
SetState(EReqStatePostInitialise); |
|
996 |
Dispatch(EFalse); |
|
997 |
return; |
|
998 |
} |
|
999 |
} |
|
1000 |
||
1001 |
ProcessDriveOperation(); |
|
1002 |
} |
|
1003 |
||
1004 |
void CFsMessageRequest::ProcessPostOperation() |
|
1005 |
// |
|
1006 |
// Process the message in post operation mode (handled by the current plugin) |
|
1007 |
// |
|
1008 |
{ |
|
1009 |
TInt err = KErrNone; |
|
243 | 1010 |
if(!iCurrentPlugin->OriginatedFromPlugin(*this)) |
0 | 1011 |
{ |
1012 |
// The request hasn't come from this plugin so it's safe to dispatch |
|
1013 |
TFsPluginRequest request(this); |
|
1014 |
TRAPD(leaveValue, err = iCurrentPlugin->DoRequestL(request)); |
|
1015 |
if(leaveValue != KErrNone) |
|
1016 |
{ |
|
1017 |
Panic(KFsClient,leaveValue); |
|
1018 |
if(iOperation->IsOpenSubSess()) |
|
1019 |
RequestAllocator::OpenSubFailed(Session()); |
|
1020 |
Free(); |
|
1021 |
return; |
|
1022 |
} |
|
1023 |
||
1024 |
if(!IsExpectedResult(err)) |
|
1025 |
{ |
|
1026 |
Complete(err); |
|
1027 |
return; |
|
1028 |
} |
|
1029 |
} |
|
1030 |
||
1031 |
// Find the previous plugin in the chain and dispatch |
|
1032 |
// - If no more plugins are interested in this message, then complete |
|
243 | 1033 |
FsPluginManager::ReadLockChain(); |
1034 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this); |
|
0 | 1035 |
if(iCurrentPlugin == NULL) |
1036 |
{ |
|
243 | 1037 |
FsPluginManager::UnlockChain(); |
0 | 1038 |
Complete(GetError()); |
1039 |
return; |
|
1040 |
} |
|
1041 |
||
1042 |
Dispatch(); |
|
243 | 1043 |
FsPluginManager::UnlockChain(); |
0 | 1044 |
return; |
1045 |
} |
|
1046 |
||
1047 |
||
1048 |
void CFsMessageRequest::ProcessPreOperation() |
|
1049 |
// |
|
1050 |
// Process the message in pre operation mode (handled by the current plugin) |
|
1051 |
// |
|
1052 |
{ |
|
1053 |
TInt err = KErrNone; |
|
243 | 1054 |
if(!iCurrentPlugin->OriginatedFromPlugin(*this)) |
0 | 1055 |
{ |
1056 |
// The request hasn't come from this plugin so it's safe to dispatch |
|
1057 |
TFsPluginRequest request(this); |
|
1058 |
TRAPD(leaveValue, err = iCurrentPlugin->DoRequestL(request)); |
|
1059 |
__PLUGIN_PRINT1(_L("PLUGIN: CFsMessageRequest:: %x processed by plugin"), this); |
|
1060 |
||
1061 |
if((iOperation->Function() == EFsDismountPlugin) && (err != KErrPermissionDenied)) |
|
1062 |
{ |
|
243 | 1063 |
err = KErrNone; |
0 | 1064 |
} |
1065 |
||
1066 |
if(leaveValue != KErrNone) |
|
1067 |
{ |
|
1068 |
Panic(KFsClient,leaveValue); |
|
1069 |
if(iOperation->IsOpenSubSess()) //this should be close subsession |
|
1070 |
RequestAllocator::OpenSubFailed(Session()); //need a close subsession fail |
|
1071 |
Free(); |
|
1072 |
return; |
|
1073 |
} |
|
1074 |
} |
|
1075 |
||
1076 |
if(err == KErrNone) |
|
1077 |
{ |
|
1078 |
// Find the next plugin in the chain and dispatch |
|
1079 |
// - If no more plugins are interested in this message, |
|
1080 |
// then Dispatch() will process the request in drive/main thread context. |
|
243 | 1081 |
FsPluginManager::ReadLockChain(); |
1082 |
FsPluginManager::NextPlugin(iCurrentPlugin, this); |
|
0 | 1083 |
if(iCurrentPlugin && IsPostOperation()) |
1084 |
SetPostOperation(EFalse); |
|
1085 |
Dispatch(); |
|
243 | 1086 |
FsPluginManager::UnlockChain(); |
0 | 1087 |
return; |
1088 |
} |
|
1089 |
// KErrCompletion may be returned by the plugin to |
|
1090 |
// indicate that it has process the message itself (do post-intercept) |
|
1091 |
else if (err == KErrCompletion) |
|
1092 |
{ |
|
1093 |
// Find the previous plugin in the chain and dispatch |
|
1094 |
// - If no more plugins are interested in this message, then complete |
|
243 | 1095 |
FsPluginManager::ReadLockChain(); |
1096 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this); |
|
0 | 1097 |
if(iCurrentPlugin != NULL) |
1098 |
{ |
|
1099 |
SetPostOperation(ETrue); |
|
1100 |
err = KErrNone; |
|
1101 |
Dispatch(); |
|
243 | 1102 |
FsPluginManager::UnlockChain(); |
0 | 1103 |
return; |
1104 |
} |
|
1105 |
else |
|
1106 |
{ |
|
1107 |
err = KErrNone; |
|
1108 |
} |
|
243 | 1109 |
FsPluginManager::UnlockChain(); |
0 | 1110 |
} |
1111 |
||
1112 |
Complete(err); |
|
1113 |
return; |
|
1114 |
} |
|
1115 |
||
1116 |
||
1117 |
void CFsMessageRequest::ProcessDriveOperation() |
|
1118 |
// |
|
1119 |
// Process the message in drive (or main thread) context |
|
1120 |
// |
|
1121 |
{ |
|
1122 |
||
1123 |
// A new request is to be processed - kick off the inactivity/finalisation timer... |
|
1124 |
FsThreadManager::StartFinalisationTimer(iDriveNumber); |
|
1125 |
||
1126 |
TInt err = KErrNone; |
|
1127 |
||
1128 |
TRAPD(leaveValue, err = iOperation->DoRequestL(this)); |
|
1129 |
||
1130 |
// Cancel hung state if a request from the drive thread has finished |
|
1131 |
FsThreadManager::SetDriveHung(DriveNumber(), EFalse); |
|
1132 |
||
1133 |
if(leaveValue != KErrNone) |
|
1134 |
{ |
|
1135 |
Panic(KFsClient,leaveValue); |
|
1136 |
if(iOperation->IsOpenSubSess()) |
|
1137 |
RequestAllocator::OpenSubFailed(Session()); |
|
1138 |
Free(); |
|
1139 |
return; |
|
1140 |
} |
|
1141 |
||
1142 |
// request postponed ? (e.g. if a page used by file cache is busy, |
|
1143 |
// or because of fair scheduling). |
|
1144 |
if (err == EReqActionBusy) |
|
1145 |
{ |
|
1146 |
Dispatch(); |
|
1147 |
return; |
|
1148 |
} |
|
1149 |
||
1150 |
iLastError = err; |
|
1151 |
||
1152 |
if(!IsExpectedResult(err) || IsPluginSpecific()) |
|
1153 |
{ |
|
1154 |
// no need to call DoNotify here since that requires err==KErrNone |
|
1155 |
Complete(err); |
|
1156 |
return; |
|
1157 |
} |
|
1158 |
||
1159 |
SetError(err); |
|
231 | 1160 |
|
1161 |
if (IsExpectedResult(err) && !IsPluginSpecific() && !IsNotifierSpecific()) |
|
1162 |
DoNotifyDiskSpace(KErrNone); |
|
0 | 1163 |
|
1164 |
// Start issuing the post-operation requests starting from the bottom of the chain |
|
1165 |
iCurrentPlugin = NULL; |
|
1166 |
if (PostInterceptEnabled()) |
|
1167 |
{ |
|
243 | 1168 |
FsPluginManager::ReadLockChain(); |
1169 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this); |
|
1170 |
if(iCurrentPlugin && !iCurrentPlugin->OriginatedFromPlugin(*this)) |
|
0 | 1171 |
{ |
1172 |
SetPostOperation(ETrue); |
|
1173 |
if (DispatchToPlugin()) |
|
243 | 1174 |
{ |
1175 |
FsPluginManager::UnlockChain(); |
|
0 | 1176 |
return; |
243 | 1177 |
} |
0 | 1178 |
} |
243 | 1179 |
FsPluginManager::UnlockChain(); |
0 | 1180 |
} |
1181 |
||
1182 |
Complete(GetError()); |
|
1183 |
return; |
|
1184 |
} |
|
1185 |
||
1186 |
void CFsMessageRequest::Complete(TInt aError) |
|
1187 |
// |
|
1188 |
// |
|
1189 |
// |
|
1190 |
{ |
|
1191 |
__THRD_PRINT2(_L("----- CFsMessageRequest::Complete() req %08x with %d"), this, aError); |
|
1192 |
||
1193 |
if(aError!=KErrNone) |
|
1194 |
{ |
|
1195 |
if(iOperation->IsOpenSubSess()) |
|
1196 |
RequestAllocator::OpenSubFailed(Session()); |
|
1197 |
} |
|
1198 |
||
1199 |
iLastError = aError; |
|
1200 |
||
1201 |
// Call the current MessageOp's completion routine - if this returns EReqActionComplete, |
|
1202 |
// then pop the request and call the next MessageOps's completion routine. |
|
1203 |
// Do this until there are no more MessageOp's on the stack. |
|
1204 |
// |
|
1205 |
// Completion return codes: |
|
1206 |
// EReqActionOwnedByPlugin: DON'T dispatch message again, DON'T complete message |
|
1207 |
// EReqActionComplete: DON'T dispatch message again, DO complete message |
|
1208 |
// EReqActionContinue: DO dispatch message again, DON'T complete message |
|
1209 |
// EReqActionBusy DO dispatch message again, DON'T complete message, |
|
1210 |
TInt completeErr; |
|
1211 |
||
1212 |
for (completeErr = EReqActionComplete; CurrentOperationPtr() != NULL && completeErr == EReqActionComplete; ) |
|
1213 |
{ |
|
1214 |
// Get the completion routine from the current TMsgOperation and then pop it |
|
1215 |
TFsRequestFunc doComplete = CurrentOperation().iComplete; |
|
1216 |
PopOperation(); |
|
1217 |
||
1218 |
// Check that a completion routine is supplied if this isn't the last TMsgOperation |
|
1219 |
__ASSERT_ALWAYS(iCurrentOperation == NULL || doComplete != NULL, Fault(EBadOperationIndex)); |
|
1220 |
||
1221 |
// Call the completion routine |
|
1222 |
if (doComplete) |
|
1223 |
completeErr = doComplete(this); |
|
1224 |
||
1225 |
// Check return code is valid |
|
1226 |
__ASSERT_DEBUG(completeErr == EReqActionContinue || completeErr == EReqActionBusy || completeErr == EReqActionComplete || completeErr == EReqActionOwnedByPlugin, Fault(EBadOperationCompletionCode)); |
|
1227 |
} |
|
1228 |
||
1229 |
// a set of flags to determine what actions to take for each return code |
|
1230 |
enum |
|
1231 |
{ |
|
1232 |
EDispatch = 0x01, // dispatch request |
|
1233 |
EComplete = 0x02, // complete request |
|
1234 |
EFree =0x04, // free request |
|
1235 |
EResetPostInitialised = 0x08, // call iPostInitialise again |
|
1236 |
EDispatchToFront = 0x10 // dispatch to back of drive thread queue |
|
1237 |
}; |
|
1238 |
const TUint actions[8] = |
|
1239 |
{ |
|
1240 |
// 0 - EReqActionContinue |
|
1241 |
EDispatch, |
|
1242 |
// 1 - unused |
|
1243 |
0, |
|
1244 |
// 2 - unused |
|
1245 |
0, |
|
1246 |
// 3 - unused |
|
1247 |
0, |
|
1248 |
// 4 - EReqActionCompleteAndDispatch |
|
1249 |
EDispatch | EComplete | EResetPostInitialised | EDispatchToFront, |
|
1250 |
// 5 - EReqActionOwnedByPlugin |
|
1251 |
0, |
|
1252 |
// 6 - EReqActionBusy |
|
1253 |
EDispatch | EResetPostInitialised, |
|
1254 |
// 7 - EReqActionComplete |
|
1255 |
EComplete | EFree, |
|
1256 |
}; |
|
1257 |
||
1258 |
TUint actionFlags = actions[((TUint32) completeErr) & 0x00000007]; |
|
1259 |
||
1260 |
// To dispatch to drive thread and intercept before DoRequestL() |
|
1261 |
// we must re-call iPostInitialise(), so reset iPostInitialised flag |
|
1262 |
if (actionFlags & EResetPostInitialised) |
|
1263 |
{ |
|
1264 |
// can only postpone the request if there's a PostInitialise() function |
|
1265 |
__ASSERT_DEBUG(iOperation->iPostInitialise , Fault(EBadOperationCompletionCode)); |
|
1266 |
SetState(EReqStatePostInitialise); |
|
1267 |
} |
|
1268 |
||
1269 |
||
1270 |
||
1271 |
TInt dispatchError = KErrNone; |
|
1272 |
TBool completeMessage = (iLastError != KErrNone) || (iIsCompleted && (actionFlags & EComplete)); |
|
1273 |
||
1274 |
// Need to lock drive to prevent both file server and drive thread from completing the same message (!) |
|
1275 |
// or the dispatched thread from freeing the message before the first thread has completed it |
|
1276 |
TDrive* drive = iDrive; |
|
1277 |
if (drive) |
|
1278 |
drive->Lock(); |
|
1279 |
||
1280 |
// don't go back up plugin chain once message has been completed |
|
1281 |
if (completeMessage) |
|
1282 |
EnablePostIntercept(EFalse); |
|
1283 |
||
1284 |
if (actionFlags & EDispatch) |
|
1285 |
{ |
|
1286 |
__ASSERT_DEBUG(((actionFlags & EFree) == 0), Fault(EInvalidCompletionFlags)); |
|
1287 |
__ASSERT_DEBUG (iCurrentPlugin == NULL, Fault(EInvalidMsgState)); |
|
1288 |
dispatchError = DispatchToDrive(EFalse, actionFlags & EDispatchToFront); |
|
1289 |
} |
|
1290 |
||
1291 |
||
1292 |
if ((actionFlags & EComplete) && IsExpectedResult(iLastError) && !IsPluginSpecific() && !IsNotifierSpecific()) |
|
1293 |
DoNotify(KErrNone); |
|
1294 |
||
1295 |
||
1296 |
if (completeMessage) |
|
1297 |
{ |
|
1298 |
iIsCompleted = EFalse; |
|
1299 |
TInt msgHandle = Message().Handle(); |
|
1300 |
if ((msgHandle != KLocalMessageHandle) && (msgHandle != 0)) |
|
1301 |
Message().Complete(iLastError); |
|
1302 |
if (IsPluginRequest()) |
|
1303 |
CFsPlugin::Complete(this, iLastError); |
|
1304 |
} |
|
1305 |
||
1306 |
if(iOperation->Function() == EFsFileSubClose) |
|
1307 |
{ |
|
1308 |
HBufC* pFileName = (HBufC*) I64HIGH(ScratchValue64()); |
|
1309 |
if(pFileName) |
|
1310 |
{ |
|
1311 |
delete pFileName; |
|
1312 |
SetScratchValue(NULL); |
|
1313 |
} |
|
1314 |
} |
|
1315 |
||
1316 |
if (drive) |
|
1317 |
drive->UnLock(); |
|
1318 |
||
1319 |
if (actionFlags & EFree) |
|
1320 |
Free(); |
|
1321 |
||
1322 |
// if the dispatch failed, then continue with popping MessageOps from the stack. |
|
1323 |
if (dispatchError != KErrNone) |
|
1324 |
Complete(dispatchError); |
|
1325 |
} |
|
1326 |
||
1327 |
void CFsMessageRequest::DoNotify(TInt aError) |
|
1328 |
// |
|
1329 |
// |
|
1330 |
// |
|
1331 |
{ |
|
1332 |
__PRINT1(_L("----- CFsMessageRequest::DoNotify() with %d"),aError); |
|
1333 |
||
1334 |
TInt driveNumber = DriveNumber(); |
|
1335 |
||
1336 |
if(aError==KErrNone) |
|
1337 |
{ |
|
299 | 1338 |
//Get a notificationInfo block (freed again after notification complete) |
1339 |
CFsNotificationInfo* notificationInfo = NULL; |
|
1340 |
||
0 | 1341 |
if(!(FsNotify::IsChangeQueEmpty(driveNumber))) |
299 | 1342 |
{ |
1343 |
if(CFsNotificationInfo::NotifyType(Operation()->Function())) |
|
1344 |
{ |
|
1345 |
notificationInfo = CFsNotificationInfo::Allocate(*this); |
|
1346 |
if(notificationInfo) |
|
1347 |
FsNotify::HandleChange(*notificationInfo); |
|
1348 |
} |
|
1349 |
} |
|
1350 |
||
1351 |
||
0 | 1352 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
299 | 1353 |
|
1354 |
if(!FsNotificationManager::IsInitialised()) |
|
1355 |
{ |
|
1356 |
if(notificationInfo) |
|
1357 |
{ |
|
1358 |
CFsNotificationInfo::Free(notificationInfo); |
|
1359 |
} |
|
1360 |
return; |
|
1361 |
} |
|
1362 |
||
1363 |
if(!notificationInfo) |
|
1364 |
{ |
|
1365 |
TFsNotification::TFsNotificationType type; |
|
1366 |
CFsNotificationInfo::NotificationType(Operation()->Function(),type); |
|
1367 |
if(type) |
|
1368 |
{ |
|
1369 |
notificationInfo = CFsNotificationInfo::Allocate(*this); |
|
1370 |
if(!notificationInfo) |
|
1371 |
return; |
|
1372 |
} |
|
1373 |
else |
|
1374 |
{ |
|
1375 |
return; |
|
1376 |
} |
|
1377 |
} |
|
0 | 1378 |
if (iOperation->iFunction == EFsFileWrite) |
1379 |
{ |
|
1380 |
CFileShare* share = (CFileShare*) this->ScratchValue(); |
|
1381 |
CFileCB* file = &share->File(); |
|
1382 |
CFileCache* fileCache = file->FileCache(); |
|
1383 |
||
1384 |
// Manage notifications for write with no cache or a write-through |
|
1385 |
if (!fileCache || !fileCache->IsDirty()) |
|
1386 |
{ |
|
299 | 1387 |
FsNotificationManager::HandleChange(*notificationInfo); |
0 | 1388 |
} |
1389 |
} |
|
1390 |
else if(IsNotifierSupported()) |
|
1391 |
{ |
|
299 | 1392 |
FsNotificationManager::HandleChange(*notificationInfo); |
0 | 1393 |
} |
1394 |
#endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
299 | 1395 |
|
1396 |
//Free the notificationInfo block |
|
1397 |
if(notificationInfo) |
|
1398 |
CFsNotificationInfo::Free(notificationInfo); |
|
1399 |
}// Err==KErrNone |
|
0 | 1400 |
} |
1401 |
||
231 | 1402 |
void CFsMessageRequest::DoNotifyDiskSpace(TInt aError) |
1403 |
{ |
|
1404 |
__PRINT1(_L("----- CFsMessageRequest::DoNotifyDiskSpace() with %d"),aError); |
|
1405 |
if(aError != KErrNone) |
|
1406 |
return; |
|
1407 |
||
1408 |
TInt driveNumber = DriveNumber(); |
|
1409 |
if ((driveNumber != KDriveInvalid) && !(FsNotify::IsDiskSpaceQueEmpty(driveNumber))) |
|
1410 |
FsNotify::HandleDiskSpace(this, driveNumber); |
|
1411 |
} |
|
0 | 1412 |
|
1413 |
void CFsMessageRequest::Free() |
|
1414 |
// |
|
1415 |
// |
|
1416 |
// |
|
1417 |
{ |
|
1418 |
__THRD_PRINT1(_L("CFsMessageRequest::Free() isAllocated=%d"), IsAllocated()); |
|
1419 |
||
273 | 1420 |
Close(); |
0 | 1421 |
|
1422 |
if(!IsAllocated()) |
|
1423 |
delete(this); |
|
1424 |
else iOperation = NULL; |
|
1425 |
||
1426 |
} |
|
1427 |
||
1428 |
TInt CFsMessageRequest::DoInitialise() |
|
1429 |
// |
|
1430 |
// returns KErrNone if Initialise succeeded normally |
|
1431 |
// or EReqActionComplete if request completed already |
|
1432 |
// or EReqActionBusy if request needs dispatching & initialising again |
|
1433 |
// |
|
1434 |
{ |
|
1435 |
TInt r = KErrNone; |
|
1436 |
||
1437 |
SetState(iOperation->iPostInitialise ? EReqStatePostInitialise : EReqStateDoRequest); |
|
1438 |
r=Initialise(); |
|
1439 |
if(r==KErrBadHandle) |
|
1440 |
{ |
|
1441 |
// bad subsession handle so panic client |
|
1442 |
_LIT(KPanic,"Panic"); |
|
1443 |
Panic(KPanic,r); |
|
1444 |
if(iOperation->IsOpenSubSess()) //this should be close subsession |
|
1445 |
RequestAllocator::OpenSubFailed(Session()); //need a close subsession fail |
|
1446 |
Free(); |
|
1447 |
r = EReqActionComplete; |
|
1448 |
} |
|
1449 |
else if (r == EReqActionComplete) // completed synchronously in Initialise() function ? |
|
1450 |
{ |
|
1451 |
Complete(KErrNone); |
|
1452 |
} |
|
1453 |
else if (r == EReqActionBusy || r == EReqActionPending) // request postponed or owned by file share ? |
|
1454 |
{ |
|
1455 |
} |
|
1456 |
else if (r != KErrNone) // error |
|
1457 |
{ |
|
1458 |
Complete(r); |
|
1459 |
r = EReqActionComplete; |
|
1460 |
} |
|
1461 |
||
1462 |
return r; |
|
1463 |
} |
|
1464 |
||
1465 |
TInt CFsMessageRequest::PostInitialise() |
|
1466 |
// |
|
1467 |
// returns KErrNone if PostInitialise() succeeded normally |
|
1468 |
// or EReqActionComplete if request completed already |
|
1469 |
// or EReqActionBusy if request needs dispatching & initialising again |
|
1470 |
// |
|
1471 |
{ |
|
1472 |
TInt r = KErrNone; |
|
1473 |
||
1474 |
SetState(EReqStateDoRequest); |
|
1475 |
if (iOperation->iPostInitialise) |
|
1476 |
r = iOperation->iPostInitialise(this); |
|
1477 |
if (r == EReqActionComplete) // completed early ? |
|
1478 |
{ |
|
1479 |
||
1480 |
// Start issuing the post-operation requests starting from the bottom of the chain |
|
1481 |
iCurrentPlugin = NULL; |
|
1482 |
if (PostInterceptEnabled()) |
|
1483 |
{ |
|
243 | 1484 |
FsPluginManager::ReadLockChain(); |
1485 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this); |
|
1486 |
if(iCurrentPlugin && !iCurrentPlugin->OriginatedFromPlugin(*this)) |
|
0 | 1487 |
{ |
1488 |
SetPostOperation(ETrue); |
|
1489 |
Dispatch(); |
|
243 | 1490 |
FsPluginManager::UnlockChain(); |
0 | 1491 |
return r; // EReqActionComplete |
1492 |
} |
|
243 | 1493 |
FsPluginManager::UnlockChain(); |
0 | 1494 |
} |
1495 |
||
1496 |
Complete(KErrNone); |
|
1497 |
} |
|
1498 |
else if (r == EReqActionBusy) // request postponed ? |
|
1499 |
{ |
|
1500 |
} |
|
1501 |
else if (r != KErrNone) // error |
|
1502 |
{ |
|
1503 |
Complete(r); |
|
1504 |
r = EReqActionComplete; |
|
1505 |
} |
|
1506 |
||
1507 |
return r; |
|
1508 |
} |
|
1509 |
||
1510 |
||
1511 |
// CFsMessageRequest::Dispatch() |
|
1512 |
// |
|
1513 |
// If aInitialise is EFalse, just disptach request to appropriate thread - |
|
1514 |
// don't call DoInitialise() or PostInitialise() |
|
1515 |
// |
|
1516 |
void CFsMessageRequest::Dispatch(TBool aInitialise, TBool aLowPriority, TBool aDispatchToFront) |
|
1517 |
{ |
|
1518 |
__THRD_PRINT1(_L("CFsMessageRequest::Dispatch() req %08x"), this); |
|
1519 |
||
1520 |
TInt r = KErrNone; |
|
243 | 1521 |
TBool pluginChainLocked = EFalse; |
0 | 1522 |
|
1523 |
if (iReqState == EReqStateInitialise && aInitialise) |
|
1524 |
{ |
|
1525 |
r = DoInitialise(); |
|
1526 |
if (r == EReqActionComplete) |
|
1527 |
{ |
|
1528 |
return; |
|
1529 |
} |
|
1530 |
else if (r == EReqActionBusy) // request postponed ? |
|
1531 |
{ |
|
1532 |
SetState(EReqStateInitialise); // reinitialize when request is next processed |
|
1533 |
} |
|
1534 |
else if (r == EReqActionPending) // owned by file share ? |
|
1535 |
{ |
|
1536 |
SetState(EReqStateInitialise); // reinitialize when request is next processed |
|
1537 |
return; |
|
1538 |
} |
|
1539 |
if(!IsPluginSpecific() && (iOwnerPlugin == NULL)) |
|
1540 |
{ |
|
243 | 1541 |
FsPluginManager::ReadLockChain(); // Unlocked in DispatchToPlugin |
1542 |
pluginChainLocked = ETrue; |
|
0 | 1543 |
iCurrentPlugin = NULL; |
1544 |
iClientThreadId = 0; |
|
243 | 1545 |
FsPluginManager::NextPlugin(iCurrentPlugin, this); |
0 | 1546 |
|
1547 |
// find out whether there is a plugin registered to post intercept this message |
|
1548 |
CFsPlugin* postInterceptPlugin = NULL; |
|
1549 |
if (iCurrentPlugin == NULL) |
|
243 | 1550 |
FsPluginManager::PrevPlugin(postInterceptPlugin, this); |
0 | 1551 |
|
243 | 1552 |
// Save the client's thread Id for subsequent testing by CFsPlugin::OriginatedFromPlugin() - doing so on the fly |
0 | 1553 |
// is risky because some messages are completed early in which case Message().Client() will result in a panic |
1554 |
if ((iCurrentPlugin || postInterceptPlugin) && Message().Handle() != NULL && Message().Handle() != KLocalMessageHandle) |
|
1555 |
{ |
|
1556 |
RThread thread; |
|
1557 |
Message().Client(thread, EOwnerThread); |
|
1558 |
iClientThreadId = thread.Id(); |
|
1559 |
thread.Close(); |
|
1560 |
} |
|
1561 |
} |
|
1562 |
} // initialise |
|
1563 |
||
1564 |
||
1565 |
// dispatch to plugin thread if initialised (otherwise dispatch to drive thread) |
|
1566 |
if (iReqState > EReqStateInitialise && DispatchToPlugin()) |
|
1567 |
{ |
|
1568 |
__PLUGIN_PRINT1(_L("PLUGIN: CFsMessageRequest %x dispatched to plugin (async)"), this); |
|
1569 |
// The request has been delivered to the plugin thread |
|
1570 |
// - leave the main thread now and await asynchronous completion |
|
243 | 1571 |
if(pluginChainLocked) |
1572 |
FsPluginManager::UnlockChain(); |
|
0 | 1573 |
return; |
1574 |
} |
|
1575 |
||
243 | 1576 |
//DispatchToPlugin didn't (deliver then unlock) so make sure we unlock here. |
1577 |
if(pluginChainLocked) |
|
1578 |
FsPluginManager::UnlockChain(); |
|
0 | 1579 |
|
1580 |
// Is there a PostInitialise function ? |
|
1581 |
if (iReqState == EReqStatePostInitialise && aInitialise && r == KErrNone) |
|
1582 |
{ |
|
1583 |
TInt r = PostInitialise(); |
|
1584 |
if (r == EReqActionComplete) |
|
243 | 1585 |
{ |
0 | 1586 |
return; |
243 | 1587 |
} |
0 | 1588 |
else if (r == EReqActionBusy) // request postponed ? |
1589 |
SetState(EReqStatePostInitialise); // reinitialize when request is next processed |
|
1590 |
} |
|
1591 |
||
1592 |
||
1593 |
if(!IsSeparateThread() || FsThreadManager::IsDriveSync(DriveNumber(),EFalse)) |
|
1594 |
{ |
|
1595 |
__PLUGIN_PRINT1(_L("PLUGIN: CFsMessageRequest %x dispatched to plugin (sync)"), this); |
|
1596 |
FsPluginManager::DispatchSync(this); |
|
1597 |
return; |
|
1598 |
} |
|
1599 |
||
1600 |
r = DispatchToDrive(aLowPriority, aDispatchToFront); |
|
1601 |
if (r != KErrNone) |
|
1602 |
Complete(r); |
|
1603 |
} |
|
1604 |
||
1605 |
inline TInt CFsMessageRequest::DispatchToDrive(TBool aLowPriority, TBool aDispatchToFront) |
|
1606 |
{ |
|
1607 |
TInt drivenumber = DriveNumber(); |
|
1608 |
||
1609 |
if (drivenumber < EDriveA || drivenumber > EDriveZ) |
|
1610 |
return KErrNotSupported; |
|
1611 |
||
1612 |
FsThreadManager::LockDrive(drivenumber); |
|
1613 |
||
1614 |
CDriveThread* dT=NULL; |
|
1615 |
TInt r = FsThreadManager::GetDriveThread(drivenumber,&dT); |
|
1616 |
||
1617 |
if(r == KErrNone) |
|
1618 |
{ |
|
1619 |
CRequestThread* pT = (CRequestThread*)dT; |
|
1620 |
||
1621 |
if (FsThreadManager::IsDriveHung(drivenumber)) |
|
1622 |
r = KErrNotReady; |
|
1623 |
else if (aDispatchToFront) |
|
1624 |
pT->DeliverFront(this); |
|
1625 |
else |
|
1626 |
pT->DeliverBack(this, aLowPriority); |
|
1627 |
} |
|
1628 |
else if (r == KErrAccessDenied) |
|
1629 |
{ |
|
1630 |
Process(); |
|
1631 |
} |
|
1632 |
||
1633 |
FsThreadManager::UnlockDrive(drivenumber); |
|
1634 |
||
1635 |
return r; |
|
1636 |
} |
|
1637 |
||
1638 |
void CFsMessageRequest::Dispatch() |
|
1639 |
{ |
|
1640 |
Dispatch(ETrue); |
|
1641 |
} |
|
1642 |
||
1643 |
TBool CFsMessageRequest::DispatchToPlugin() |
|
1644 |
// |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1645 |
// Common route: Receive -> Process -> Dispatch -> DispatchToPlugin |
0 | 1646 |
// |
243 | 1647 |
// (Is called with FsPluginManager ReadLocked) |
0 | 1648 |
{ |
1649 |
TInt drivenumber = DriveNumber(); |
|
1650 |
if(iCurrentPlugin) |
|
1651 |
{ |
|
1652 |
FOREVER |
|
1653 |
{ |
|
1654 |
// if we've reached a plugin which is waiting for Complete(), stop going up the plugin chain |
|
1655 |
if(drivenumber >= 0 && IsPostOperation() && CurrentPluginWaiting()) |
|
1656 |
{ |
|
1657 |
// No more plug-ins need to process this request |
|
1658 |
iCurrentPlugin = NULL; |
|
1659 |
} |
|
1660 |
||
243 | 1661 |
while(iCurrentPlugin && iCurrentPlugin->OriginatedFromPlugin(*this)) |
0 | 1662 |
{ |
1663 |
// Skip the current plugin if the request originated from the plugin |
|
1664 |
if(IsPostOperation()) |
|
1665 |
{ |
|
243 | 1666 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this); |
0 | 1667 |
} |
1668 |
else |
|
1669 |
{ |
|
243 | 1670 |
FsPluginManager::NextPlugin(iCurrentPlugin, this); |
0 | 1671 |
} |
1672 |
} |
|
1673 |
||
1674 |
if(iCurrentPlugin) |
|
1675 |
{ |
|
1676 |
TFsPluginRequest request(this); |
|
1677 |
__THRD_PRINT1(_L("CFsMessageRequest::DispatchToPlugin() req %08x"), this); |
|
1678 |
||
1679 |
TInt err = iCurrentPlugin->Deliver(request); |
|
1680 |
if(err == KErrNone) |
|
1681 |
{ |
|
1682 |
||
1683 |
// The request has been delivered to the plugin thread |
|
1684 |
// - leave the main thread now |
|
1685 |
return(ETrue); |
|
1686 |
} |
|
1687 |
else if(err < KErrNone) |
|
1688 |
{ |
|
1689 |
// An error has occurred |
|
1690 |
// - complete the message |
|
1691 |
Complete(err); |
|
1692 |
return(ETrue); |
|
1693 |
} |
|
1694 |
else if(err == KPluginMessageForward) |
|
1695 |
{ |
|
1696 |
// The plugin has processed synchronously (case 1) |
|
1697 |
// - Pass the message on to the next plugin |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1698 |
if(FsFunction() != EFsPluginOpen) |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1699 |
{ |
243 | 1700 |
FsPluginManager::NextPlugin(iCurrentPlugin, this); |
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1701 |
continue; |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1702 |
} |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1703 |
else // FsFunction == EFsPluginOpen |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1704 |
{ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1705 |
/* |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1706 |
* PluginOpen requests should not be passed down the plugin stack. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1707 |
* |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1708 |
*/ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1709 |
iCurrentPlugin = NULL; |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1710 |
continue; |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1711 |
} |
0 | 1712 |
} |
1713 |
else if(err == KPluginMessageComplete) |
|
1714 |
{ |
|
1715 |
// The plugin has processed synchronously (case 2) |
|
1716 |
// - Pass the message back up the stack |
|
1717 |
SetPostOperation(ETrue); |
|
243 | 1718 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this); |
0 | 1719 |
continue; |
1720 |
} |
|
1721 |
_LIT(KPanic,"Panic: F32-BAD-PLUGIN-ERROR"); |
|
1722 |
Panic(KPanic, err); |
|
1723 |
} |
|
1724 |
else if (IsPostOperation()) |
|
1725 |
{ |
|
1726 |
// No more plugins are interested in this request |
|
1727 |
// - If in post operation, complete the request |
|
1728 |
Complete(GetError()); |
|
1729 |
return(ETrue); |
|
1730 |
} |
|
1731 |
else |
|
1732 |
{ |
|
1733 |
// No plugin is registered for pre-operation interception this message |
|
1734 |
// - pass the request onto the drive thread. |
|
1735 |
return EFalse; |
|
1736 |
} |
|
1737 |
} |
|
1738 |
} |
|
1739 |
||
243 | 1740 |
/* |
1741 |
* Special case- DismountPlugin runs in the context of the plugin thread |
|
1742 |
*/ |
|
0 | 1743 |
if(iOperation->Function() == EFsDismountPlugin) |
1744 |
{ |
|
1745 |
// Don't pass plugin dismounts to the drive thread |
|
243 | 1746 |
FsPluginManager::UnlockChain(); |
0 | 1747 |
Process(); |
243 | 1748 |
FsPluginManager::ReadLockChain(); //inverted unlock/lock to get around dismount plugin being a special case |
0 | 1749 |
return(ETrue); |
1750 |
} |
|
1751 |
return EFalse; |
|
1752 |
} |
|
1753 |
||
1754 |
TDrive* CFsMessageRequest::Drive() |
|
1755 |
// |
|
1756 |
// |
|
1757 |
// |
|
1758 |
{ |
|
1759 |
return(iDrive); |
|
1760 |
} |
|
1761 |
||
1762 |
TDrive* CFsMessageRequest::SubstedDrive() |
|
1763 |
// |
|
1764 |
// |
|
1765 |
// |
|
1766 |
{ |
|
1767 |
return(iSubstedDrive); |
|
1768 |
} |
|
1769 |
||
1770 |
void CFsMessageRequest::SetDrive(TDrive* aDrive) |
|
1771 |
// |
|
1772 |
// |
|
1773 |
// |
|
1774 |
{ |
|
1775 |
iDrive=aDrive; |
|
1776 |
if(aDrive) |
|
1777 |
{ |
|
1778 |
iDriveNumber=aDrive->DriveNumber(); |
|
1779 |
} |
|
1780 |
} |
|
1781 |
||
1782 |
void CFsMessageRequest::SetSubstedDrive(TDrive* aDrive) |
|
1783 |
// |
|
1784 |
// |
|
1785 |
// |
|
1786 |
{ |
|
1787 |
iSubstedDrive=aDrive; |
|
1788 |
} |
|
1789 |
||
1790 |
const RMessage2& CFsMessageRequest::Message() |
|
1791 |
// |
|
1792 |
// |
|
1793 |
// |
|
1794 |
{ |
|
1795 |
return(iMessage); |
|
1796 |
} |
|
1797 |
||
1798 |
||
1799 |
||
1800 |
void CFsMessageRequest::ReStart() |
|
1801 |
{ |
|
1802 |
__ASSERT_ALWAYS(CurrentOperationPtr() != NULL, Fault(EBadOperationIndex)); |
|
1803 |
||
1804 |
// restore original settings : |
|
1805 |
TMsgOperation& currentOperation = CurrentOperation(); |
|
1806 |
TInt offset = currentOperation.iReadWriteArgs.iOffset; |
|
1807 |
currentOperation.iReadWriteArgs.iPos-= offset; |
|
1808 |
currentOperation.iReadWriteArgs.iTotalLength+= offset; |
|
1809 |
currentOperation.iReadWriteArgs.iLength = currentOperation.iReadWriteArgs.iTotalLength; |
|
1810 |
currentOperation.iReadWriteArgs.iOffset = 0; |
|
1811 |
currentOperation.iState = 0; |
|
1812 |
TInt function = iOperation->Function(); |
|
1813 |
__ASSERT_ALWAYS(function == EFsFileRead || function == EFsFileWrite, Fault(EMsgRestartBadFunction)); |
|
1814 |
} |
|
1815 |
||
1816 |
||
1817 |
void CFsMessageRequest::SetOperationFunc(TInt aFunction) |
|
1818 |
{ |
|
1819 |
const TOperation& oP = OperationArray[aFunction]; |
|
299 | 1820 |
iOperation = const_cast<TOperation*>(&oP); |
0 | 1821 |
// modified because some requests were set to PostInitialise. They are set to DoRequest in Dispatch anyway, so this is possibly ok? |
1822 |
//__ASSERT_ALWAYS(iReqState == EReqStateDoRequest, Fault(EInvalidMsgState)); |
|
1823 |
} |
|
1824 |
||
1825 |
TInt CFsMessageRequest::PushOperation(TFsRequestFunc aCallback, TInt aNextState, TInt aFunction) |
|
1826 |
{ |
|
1827 |
TMsgOperation* nextOperation; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
1828 |
TInt r = OperationAllocator::GetOperation(nextOperation); |
0 | 1829 |
if (r != KErrNone) |
1830 |
return r; |
|
1831 |
||
1832 |
||
1833 |
// Store the caller's state etc in the CURRENT TMsgOperation (if there is one) |
|
1834 |
if (iCurrentOperation != NULL) |
|
1835 |
{ |
|
1836 |
__ASSERT_ALWAYS(aCallback, Fault(EPushOpNoCallback)); |
|
1837 |
iCurrentOperation->iState = aNextState; |
|
1838 |
iCurrentOperation->iCurrentPlugin = iCurrentPlugin; |
|
1839 |
iCurrentOperation->iFunction = iOperation->Function(); |
|
1840 |
iCurrentOperation->iNext = nextOperation; |
|
1841 |
nextOperation->iPrev = iCurrentOperation; |
|
1842 |
} |
|
1843 |
||
1844 |
// store the call-back routine in the NEW TMsgOperation |
|
1845 |
nextOperation->iComplete = aCallback; |
|
1846 |
nextOperation->iState = 0; |
|
1847 |
if (aFunction != KOperationFunctionUnaltered && aFunction != iOperation->Function()) |
|
1848 |
SetOperationFunc(aFunction); |
|
1849 |
||
1850 |
||
1851 |
iCurrentOperation = nextOperation; |
|
1852 |
||
1853 |
// reset post operation state: as a plugin may push more than one TMsgOperation |
|
1854 |
SetPostOperation(EFalse); |
|
1855 |
||
1856 |
return KErrNone; |
|
1857 |
} |
|
1858 |
||
1859 |
/** |
|
1860 |
PushOperation() |
|
1861 |
||
1862 |
Pushes a new TMsgOperation onto this request's "stack". After this function completes the new |
|
1863 |
TMsgOperation object becomes the "current" one (pointed at by CFsMessageRequest::iCurrentOperation). |
|
1864 |
||
1865 |
After the request has been dispatched to the drive thread, TOperation::DoRequestL() will be called. |
|
1866 |
When this has completed, CFsMessage::Complete() is called which then pops the new TMsgOperation |
|
1867 |
off the stack; and calls the callback routine (aCallback). |
|
1868 |
||
1869 |
@param aPos The position to read / write. Stored in the NEW TMsgOperation. |
|
1870 |
||
1871 |
@param aLength The length to read / write. Stored in the NEW TMsgOperation. |
|
1872 |
||
1873 |
@param aData A buffer to read the data from / write the data to. Stored in the NEW TMsgOperation. |
|
1874 |
The buffer must belong to the file server or to a plugin |
|
1875 |
||
1876 |
@param aOffset The offset onto the buffer to read from / write to. Stored in the NEW TMsgOperation. |
|
1877 |
||
1878 |
@param aCallback An optional callback routine. Stored in the OLD TMsgOperation. |
|
1879 |
MUST be supplied if there are one or more TMsgOperation's already on the stack |
|
1880 |
||
1881 |
@param aNextState State information private to the caller. Defaults to zero. Stored in the OLD TMsgOperation. |
|
1882 |
||
1883 |
@param aFunction An optional TFsMessage. Supplied if the caller wishes to change the TOperation |
|
1884 |
associated with this request. When the new TMsgOperation is popped off the stack, the |
|
1885 |
previous TOperation is restored. Used primarally for read-modify-write. |
|
1886 |
||
1887 |
*/ |
|
1888 |
TInt CFsMessageRequest::PushOperation(TInt64 aPos, TInt aLength, TUint8* aData, TInt aOffset, TFsRequestFunc aCallback, TInt aNextState, TInt aFunction) |
|
1889 |
{ |
|
1890 |
TInt r = PushOperation(aCallback, aNextState, aFunction); |
|
1891 |
if (r == KErrNone) |
|
1892 |
CurrentOperation().Set(aPos, aLength, aData, aOffset, 0); |
|
1893 |
return r; |
|
1894 |
} |
|
1895 |
||
1896 |
||
1897 |
/** |
|
1898 |
PushOperation() |
|
1899 |
||
1900 |
Pushes a new TMsgOperation onto this request's "stack". After this function completes the new |
|
1901 |
TMsgOperation object becomes the "current" one (pointed at by CFsMessageRequest::iCurrentOperation). |
|
1902 |
||
1903 |
After the request has been dispatched to the drive thread, TOperation::DoRequestL() will be called. |
|
1904 |
When this has completed, CFsMessage::Complete() is called which then pops the new TMsgOperation |
|
1905 |
off the stack; and calls the callback routine (aCallback). |
|
1906 |
||
1907 |
@param aPos The position to read / write. Stored in the NEW TMsgOperation. |
|
1908 |
||
1909 |
@param aLength The length to read / write. Stored in the NEW TMsgOperation. |
|
1910 |
||
1911 |
@param aData A buffer to read the data from / write the data to. Stored in the NEW TMsgOperation. |
|
1912 |
The buffer belongs to a client of the file server on the other side of an IPC boundary. |
|
1913 |
||
1914 |
@param aOffset The offset onto the buffer to read from / write to. Stored in the NEW TMsgOperation. |
|
1915 |
||
1916 |
@param aCallback An optional callback routine. Stored in the OLD TMsgOperation. |
|
1917 |
MUST be supplied if there are one or more TMsgOperation's already on the stack |
|
1918 |
||
1919 |
@param aNextState State information private to the caller. Defaults to zero. Stored in the OLD TMsgOperation. |
|
1920 |
||
1921 |
@param aFunction An optional TFsMessage. Supplied if the caller wishes to change the TOperation |
|
1922 |
associated with this request. When the new TMsgOperation is popped off the stack, the |
|
1923 |
previous TOperation is restored. Used primarally for read-modify-write. |
|
1924 |
||
1925 |
*/ |
|
1926 |
TInt CFsMessageRequest::PushOperation(TInt64 aPos, TInt aLength, TDesC8* aData, TInt aOffset, TFsRequestFunc aCallback, TInt aNextState, TInt aFunction) |
|
1927 |
{ |
|
1928 |
TInt r = PushOperation(aCallback, aNextState, aFunction); |
|
1929 |
if (r == KErrNone) |
|
1930 |
CurrentOperation().Set(aPos, aLength, aData, aOffset, 0); |
|
1931 |
return r; |
|
1932 |
} |
|
1933 |
||
1934 |
void CFsMessageRequest::PopOperation() |
|
1935 |
{ |
|
1936 |
__ASSERT_ALWAYS(iCurrentOperation != NULL, Fault(EInvalidOperationIndex)); |
|
1937 |
||
1938 |
TMsgOperation* currentOperation = iCurrentOperation; |
|
1939 |
||
1940 |
if (iCurrentOperation->iPrev == NULL) |
|
1941 |
{ |
|
1942 |
iCurrentOperation = NULL; |
|
1943 |
} |
|
1944 |
else |
|
1945 |
{ |
|
1946 |
TMsgOperation* prevOperation = iCurrentOperation->iPrev; |
|
1947 |
prevOperation->iNext = NULL; |
|
1948 |
iCurrentOperation = prevOperation; |
|
1949 |
||
1950 |
iCurrentPlugin = iCurrentOperation->iCurrentPlugin; |
|
1951 |
||
1952 |
if (iCurrentOperation->iFunction != iOperation->Function()) |
|
1953 |
SetOperationFunc(iCurrentOperation->iFunction); |
|
1954 |
} |
|
1955 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
1956 |
OperationAllocator::FreeOperation(currentOperation); |
0 | 1957 |
} |
1958 |
||
1959 |
TMsgOperation& CFsMessageRequest::CurrentOperation() |
|
1960 |
{ |
|
1961 |
__ASSERT_ALWAYS(iCurrentOperation != NULL, Fault(EInvalidOperationIndex)); |
|
1962 |
return *iCurrentOperation; |
|
1963 |
} |
|
1964 |
||
1965 |
||
1966 |
CFsClientMessageRequest::CFsClientMessageRequest() |
|
1967 |
: iPoolSrc (0), |
|
1968 |
iPoolDest(0) |
|
1969 |
{ |
|
1970 |
} |
|
1971 |
||
1972 |
// Return ETrue if there are ANY TMsgOperation's in the stack which were pushed by iCurrentPlugin |
|
1973 |
// If there are any, then it's NOT OK to dispatch this message to the plugin thread as it will be |
|
1974 |
// waiting on a semaphore which is only cleared by Complete() |
|
1975 |
TBool CFsMessageRequest::CurrentPluginWaiting() |
|
1976 |
{ |
|
1977 |
if (iOwnerPlugin == iCurrentPlugin) |
|
1978 |
return ETrue; |
|
1979 |
||
1980 |
// find out which plugin (if any) was the last to push a TMsgOperation |
|
1981 |
TMsgOperation* currentOperation; |
|
1982 |
||
1983 |
for (currentOperation = iCurrentOperation ? iCurrentOperation->iPrev : NULL; |
|
1984 |
currentOperation != NULL; |
|
1985 |
currentOperation = currentOperation->iPrev) |
|
1986 |
{ |
|
1987 |
if (currentOperation->iCurrentPlugin == iCurrentPlugin) |
|
1988 |
return ETrue; |
|
1989 |
} |
|
1990 |
||
1991 |
return EFalse; |
|
1992 |
} |
|
1993 |
||
1994 |
||
1995 |
TBool CFsMessageRequest::IsPluginRequest() |
|
1996 |
{ |
|
1997 |
if(iOwnerPlugin) // Check the previous operation had a plugin) |
|
1998 |
{ |
|
1999 |
return ETrue; |
|
2000 |
} |
|
2001 |
return EFalse; |
|
2002 |
} |
|
2003 |
||
2004 |
||
2005 |
void CFsClientMessageRequest::Free() |
|
2006 |
// |
|
2007 |
// |
|
2008 |
// |
|
2009 |
{ |
|
2010 |
__THRD_PRINT(_L("CFsClientMessageRequest::Free()")); |
|
2011 |
__ASSERT_ALWAYS(CurrentOperationPtr() == NULL, Fault(EFreeingMsgWithMsgOp)); |
|
2012 |
if (iPoolSrc) |
|
2013 |
{ |
|
2014 |
TParsePool::Release(iPoolSrc); |
|
2015 |
iPoolSrc = 0; |
|
2016 |
} |
|
2017 |
||
2018 |
if (iPoolDest) |
|
2019 |
{ |
|
2020 |
TParsePool::Release(iPoolDest); |
|
2021 |
iPoolDest = 0; |
|
2022 |
} |
|
2023 |
||
273 | 2024 |
Close(); |
2025 |
||
0 | 2026 |
iOperation = NULL; |
2027 |
RequestAllocator::FreeRequest(this); |
|
2028 |
} |
|
2029 |
||
2030 |
||
2031 |
TInt CFsClientMessageRequest::AllocParseObjects(const TOperation& aOperation) |
|
2032 |
{ |
|
2033 |
__ASSERT_ALWAYS(iPoolSrc == NULL && iPoolDest == NULL, Fault(ETParsePoolGet)); |
|
2034 |
||
2035 |
if (aOperation.iFlags & EParseSrc) |
|
2036 |
{ |
|
2037 |
iPoolSrc = TParsePool::Get(); |
|
2038 |
if (iPoolSrc == NULL) |
|
2039 |
return KErrNoMemory; |
|
2040 |
} |
|
2041 |
if (aOperation.iFlags & EParseDst) |
|
2042 |
{ |
|
2043 |
iPoolDest = TParsePool::Get(); |
|
2044 |
if (iPoolDest == NULL) |
|
2045 |
return KErrNoMemory; |
|
2046 |
} |
|
2047 |
return KErrNone; |
|
2048 |
} |
|
2049 |
||
2050 |
TParse& CFsClientMessageRequest::Src() |
|
2051 |
// |
|
2052 |
// |
|
2053 |
{ |
|
2054 |
__ASSERT_ALWAYS(iPoolSrc, Fault(ETParsePoolGet)); |
|
2055 |
return (iPoolSrc->GetObject()); |
|
2056 |
} |
|
2057 |
||
2058 |
TParse& CFsClientMessageRequest::Dest() |
|
2059 |
// |
|
2060 |
// |
|
2061 |
// |
|
2062 |
{ |
|
2063 |
__ASSERT_ALWAYS(iPoolDest, Fault(ETParsePoolGet)); |
|
2064 |
return (iPoolDest->GetObject()); |
|
2065 |
} |
|
2066 |
||
2067 |
||
2068 |
||
2069 |
TParsePool* TParsePool::iFreeHead = 0; |
|
2070 |
TParsePool* TParsePool::iClosedHead = 0; |
|
2071 |
TInt TParsePool::iCountFree = 0; |
|
2072 |
RFastLock TParsePool::iLock; |
|
2073 |
||
2074 |
||
2075 |
TParsePool::TParsePool() |
|
2076 |
: iNext (iFreeHead), |
|
2077 |
iPrev (0), |
|
2078 |
iFree (ETrue) |
|
2079 |
{ |
|
2080 |
} |
|
2081 |
||
2082 |
TInt TParsePool::Init() |
|
2083 |
{ |
|
2084 |
return iLock.CreateLocal(); |
|
2085 |
} |
|
2086 |
||
2087 |
TParsePool* TParsePool::Get() |
|
2088 |
// Gets a TParsePool object from the free list. If the free list does |
|
2089 |
// not contain any TParsePool objects, additional objects are manufactured. |
|
2090 |
// Returns NULL if unable to allocate a new object |
|
2091 |
{ |
|
2092 |
iLock.Wait(); |
|
2093 |
||
2094 |
TParsePool* pObject = 0; |
|
2095 |
||
2096 |
// If we don't have anything in the free list, allocate some more... |
|
2097 |
if (iCountFree < 1) |
|
2098 |
{ |
|
2099 |
__ASSERT_DEBUG(iFreeHead == NULL, Fault(ETParsePoolGet)); |
|
2100 |
for (TInt i = 0; i < KEBlockSize; i++) |
|
2101 |
{ |
|
2102 |
// if allocation fails break out of the loop. |
|
2103 |
pObject = new TParsePool; |
|
2104 |
if (pObject == NULL) |
|
2105 |
break; |
|
2106 |
||
2107 |
iCountFree++; |
|
2108 |
||
2109 |
if (iFreeHead) |
|
2110 |
iFreeHead->iPrev = pObject; |
|
2111 |
||
2112 |
iFreeHead = pObject; |
|
2113 |
} |
|
2114 |
} |
|
2115 |
||
2116 |
// if we failed to allocate even a single object, return NULL |
|
2117 |
if (iCountFree < 1) |
|
2118 |
{ |
|
2119 |
iLock.Signal(); |
|
2120 |
return NULL; |
|
2121 |
} |
|
2122 |
||
2123 |
||
2124 |
__ASSERT_ALWAYS(iFreeHead != NULL, Fault(ETParsePoolGet)); |
|
2125 |
||
2126 |
pObject = iFreeHead; |
|
2127 |
pObject->iFree = EFalse; |
|
2128 |
||
2129 |
||
2130 |
// Remove the head of the free list... |
|
2131 |
iFreeHead = pObject->iNext; |
|
2132 |
if (iFreeHead) |
|
2133 |
iFreeHead->iPrev = 0; |
|
2134 |
iCountFree--; |
|
2135 |
||
2136 |
// ... and add it to the closed list |
|
2137 |
pObject->iNext = iClosedHead; |
|
2138 |
pObject->iPrev = 0; |
|
2139 |
if (iClosedHead) |
|
2140 |
iClosedHead->iPrev = pObject; |
|
2141 |
iClosedHead = pObject; |
|
2142 |
||
2143 |
iLock.Signal(); |
|
2144 |
||
2145 |
return pObject; |
|
2146 |
} |
|
2147 |
||
2148 |
||
2149 |
void TParsePool::Release(TParsePool* aObject) |
|
2150 |
// |
|
2151 |
// Release a sub-sequence of TParsePool objects back to the free list. |
|
2152 |
// |
|
2153 |
{ |
|
2154 |
__ASSERT_ALWAYS(aObject != NULL && !aObject->iFree, Fault(ETParsePoolGet)); |
|
2155 |
||
2156 |
iLock.Wait(); |
|
2157 |
||
2158 |
aObject->iFree = ETrue; |
|
2159 |
||
2160 |
// Get the objects either side of the one we're interested in |
|
2161 |
TParsePool* pPrevious = aObject->iPrev; |
|
2162 |
TParsePool* pNext = aObject->iNext; |
|
2163 |
||
2164 |
// Remove it from the closed list |
|
2165 |
if (pPrevious) |
|
2166 |
pPrevious->iNext = pNext; |
|
2167 |
else |
|
2168 |
iClosedHead = pNext; |
|
2169 |
||
2170 |
if (pNext) |
|
2171 |
pNext->iPrev = pPrevious; |
|
2172 |
||
2173 |
||
2174 |
// Now add it to the free list |
|
2175 |
aObject->iNext = iFreeHead; |
|
2176 |
aObject->iPrev = 0; |
|
2177 |
if (iFreeHead) |
|
2178 |
iFreeHead->iPrev = aObject; |
|
2179 |
||
2180 |
iFreeHead = aObject; |
|
2181 |
iCountFree++; |
|
2182 |
||
2183 |
iLock.Signal(); |
|
2184 |
} |
|
2185 |
||
2186 |
||
2187 |
CFsInternalRequest::CFsInternalRequest() |
|
2188 |
// |
|
2189 |
// |
|
2190 |
// |
|
2191 |
{ |
|
2192 |
// iStatus=NULL; |
|
2193 |
// iIsAllocated=EFalse; |
|
2194 |
} |
|
2195 |
||
2196 |
void CFsInternalRequest::Set(const TOperation& aOperation,CSessionFs* aSession) |
|
2197 |
// |
|
2198 |
// |
|
2199 |
// |
|
2200 |
{ |
|
2201 |
CFsRequest::Set(aOperation,aSession); |
|
2202 |
} |
|
2203 |
||
2204 |
void CFsInternalRequest::Process() |
|
2205 |
// |
|
2206 |
// |
|
2207 |
// |
|
2208 |
{ |
|
2209 |
__THRD_PRINT(_L("CFsInternalRequest::Process()")); |
|
2210 |
TInt r=KErrNone; |
|
2211 |
TRAPD(leaveValue,r=iOperation->DoRequestL(this)); |
|
2212 |
// internal requests should never fail |
|
2213 |
__ASSERT_ALWAYS(leaveValue==KErrNone && (r==KErrNone||r==EReqActionBusy),Fault(EInternalRequestProcess)); |
|
2214 |
||
2215 |
// request postponed ? (e.g. if a page used by file cache is busy). |
|
2216 |
if (r == EReqActionBusy) |
|
2217 |
{ |
|
2218 |
Dispatch(); |
|
2219 |
return; |
|
2220 |
} |
|
2221 |
||
2222 |
Complete(r); |
|
2223 |
} |
|
2224 |
||
2225 |
||
2226 |
void CFsInternalRequest::Complete(TInt aError) |
|
2227 |
// |
|
2228 |
// |
|
2229 |
// |
|
2230 |
{ |
|
2231 |
__PRINT1(_L("CFsInternalRequest::Complete() with %d"),aError); |
|
2232 |
TInt func = Operation()->Function(); |
|
273 | 2233 |
if(func == KDispatchObjectClose) |
0 | 2234 |
{ |
2235 |
TFsCloseObject::Complete(this); |
|
2236 |
Free(); |
|
2237 |
} |
|
2238 |
else if(func==KFileShareClose) |
|
2239 |
{ |
|
2240 |
if (aError == EReqActionBusy) |
|
2241 |
{ |
|
2242 |
Dispatch(); |
|
2243 |
} |
|
2244 |
else |
|
2245 |
{ |
|
2246 |
TFsCloseFileShare::Complete(this); |
|
2247 |
Free(); |
|
2248 |
} |
|
2249 |
} |
|
286 | 2250 |
else if(func==KDeferredDismount) |
2251 |
{ |
|
2252 |
} |
|
0 | 2253 |
else |
2254 |
Fault(EInternalRequestComplete3); |
|
2255 |
} |
|
2256 |
||
2257 |
void CFsInternalRequest::Dispatch() |
|
2258 |
// |
|
2259 |
// |
|
2260 |
// |
|
2261 |
{ |
|
2262 |
__THRD_PRINT(_L("CFsInternalRequest::Dispatch()")); |
|
2263 |
__ASSERT_ALWAYS(Initialise()==KErrNone,Fault(EInternalRequestDispatch1)); |
|
2264 |
||
273 | 2265 |
TInt drivenumber = DriveNumber(); |
2266 |
FsThreadManager::LockDrive(drivenumber); |
|
2267 |
// shouldn't dispath if no drive available |
|
2268 |
__ASSERT_ALWAYS(FsThreadManager::IsDriveAvailable(drivenumber,EFalse) && !FsThreadManager::IsDriveSync(drivenumber,EFalse),Fault(EInternalRequestDispatch2)); |
|
2269 |
CDriveThread* dT=NULL; |
|
2270 |
TInt r=FsThreadManager::GetDriveThread(drivenumber,&dT); |
|
2271 |
__THRD_PRINT2(_L("deliver to thread 0x%x, drive number %d"),dT,drivenumber); |
|
2272 |
__ASSERT_ALWAYS(r==KErrNone && dT,Fault(EInternalRequestDispatch3)); |
|
2273 |
CRequestThread* pT = (CRequestThread*)dT; |
|
2274 |
TInt func = Operation()->Function(); |
|
2275 |
if(func == KDispatchObjectClose || func == KFileShareClose || func == KFlushDirtyData) |
|
2276 |
pT->DeliverBack(this); |
|
0 | 2277 |
else |
273 | 2278 |
pT->DeliverFront(this); |
2279 |
FsThreadManager::UnlockDrive(drivenumber); |
|
0 | 2280 |
} |
2281 |
||
2282 |
void CFsInternalRequest::Free() |
|
2283 |
// |
|
2284 |
// |
|
2285 |
// |
|
2286 |
{ |
|
2287 |
__THRD_PRINT1(_L("CFsInternalRequest::Free() isAllocated=%d"),IsAllocated()); |
|
2288 |
||
273 | 2289 |
Close(); |
0 | 2290 |
|
2291 |
if(!IsAllocated()) |
|
2292 |
delete(this); |
|
2293 |
} |
|
2294 |
||
2295 |
||
2296 |
/** |
|
2297 |
Create a new synchronous message scheduler |
|
2298 |
*/ |
|
2299 |
CFsSyncMessageScheduler* CFsSyncMessageScheduler::NewL() |
|
2300 |
{ |
|
2301 |
__PRINT(_L("CFsSyncMessageScheduler::NewL()")); |
|
2302 |
||
2303 |
CFsSyncMessageScheduler* pSelf = new(ELeave)CFsSyncMessageScheduler(); |
|
2304 |
||
2305 |
CleanupStack::PushL(pSelf); |
|
2306 |
pSelf->ConstructL(); |
|
2307 |
CleanupStack::Pop(); |
|
2308 |
||
2309 |
return(pSelf); |
|
2310 |
} |
|
2311 |
||
2312 |
||
2313 |
/** |
|
2314 |
Construct a synchronous message scheduler |
|
2315 |
*/ |
|
2316 |
CFsSyncMessageScheduler::CFsSyncMessageScheduler() |
|
2317 |
: CActive(EPriorityHigh), |
|
2318 |
iList(_FOFF(CFsRequest,iLink)) |
|
2319 |
{ |
|
2320 |
__PRINT(_L("CFsSyncMessageScheduler::CFsSyncMessageScheduler()")); |
|
2321 |
} |
|
2322 |
||
2323 |
||
2324 |
/** |
|
2325 |
Second-phase constructor |
|
2326 |
*/ |
|
2327 |
||
2328 |
void CFsSyncMessageScheduler::ConstructL() |
|
2329 |
{ |
|
2330 |
__PRINT(_L("CFsSyncMessageScheduler::ConstructL()")); |
|
2331 |
||
2332 |
User::LeaveIfError(iLock.CreateLocal()); |
|
2333 |
User::LeaveIfError(iThread.Open(RThread().Id())); |
|
2334 |
||
2335 |
CActiveScheduler::Add(this); |
|
2336 |
} |
|
2337 |
||
2338 |
||
2339 |
/** |
|
2340 |
Synchronous message scheduler |
|
2341 |
- dispatch any synchronous requests that were queued via ::Dispatch |
|
2342 |
*/ |
|
2343 |
void CFsSyncMessageScheduler::RunL() |
|
2344 |
{ |
|
2345 |
__PRINT(_L(">> CFsSyncMessageScheduler::RunL()")); |
|
2346 |
||
2347 |
FOREVER |
|
2348 |
{ |
|
2349 |
iLock.Wait(); |
|
2350 |
if(iList.IsEmpty()) |
|
2351 |
{ |
|
2352 |
break; |
|
2353 |
} |
|
2354 |
else |
|
2355 |
{ |
|
2356 |
CFsRequest* request = iList.First(); |
|
2357 |
request->iLink.Deque(); |
|
2358 |
iLock.Signal(); |
|
2359 |
__PRINT1(_L(" CFsSyncMessageScheduler - Dispatching message %08x"), request); |
|
2360 |
request->Process(); |
|
2361 |
} |
|
2362 |
} |
|
2363 |
||
2364 |
iSignalled = EFalse; |
|
2365 |
iStatus = KRequestPending; |
|
2366 |
SetActive(); |
|
2367 |
iLock.Signal(); |
|
2368 |
||
2369 |
__PRINT(_L("<< CFsSyncMessageScheduler::RunL()")); |
|
2370 |
} |
|
2371 |
||
2372 |
||
2373 |
/** |
|
2374 |
DoCancel - Not Implemented |
|
2375 |
*/ |
|
2376 |
void CFsSyncMessageScheduler::DoCancel() |
|
2377 |
{ |
|
2378 |
__PRINT(_L("CFsSyncMessageScheduler::DoCancel")); |
|
2379 |
} |
|
2380 |
||
2381 |
||
2382 |
/** |
|
2383 |
Queue synchronous requests to be processed in main thread context |
|
2384 |
- called when synchronous messages are passed from plugin threads |
|
2385 |
*/ |
|
2386 |
void CFsSyncMessageScheduler::Dispatch(CFsRequest* aRequest) |
|
2387 |
{ |
|
2388 |
__PRINT1(_L("CFsSyncMessageScheduler::Dispatch(%08x)"), aRequest); |
|
2389 |
||
2390 |
// Accquire lock and add request to queue. |
|
2391 |
iLock.Wait(); |
|
2392 |
iList.AddFirst(*aRequest); |
|
2393 |
||
2394 |
if(!iSignalled) |
|
2395 |
{ |
|
2396 |
// set iSignalled in case another thread (plug-in) is calling dispatch, then release lock. |
|
2397 |
iSignalled = ETrue; |
|
2398 |
iLock.Signal(); |
|
2399 |
||
2400 |
// signal main thread. |
|
2401 |
TRequestStatus* s = &iStatus; |
|
2402 |
iThread.RequestComplete(s, KErrNone); |
|
2403 |
} |
|
2404 |
else |
|
2405 |
{ |
|
2406 |
// main thread already signalled, just release lock. |
|
2407 |
iLock.Signal(); |
|
2408 |
} |
|
2409 |
} |
|
2410 |
||
2411 |