userlibandfileserver/fileserver/sfsrv/cl_fman.cpp
branchRCL_3
changeset 294 039a3e647356
parent 268 345b1ca54e88
equal deleted inserted replaced
268:345b1ca54e88 294:039a3e647356
   263 GLDEF_C TInt FManBaseThreadFunction(TAny* aPtr)
   263 GLDEF_C TInt FManBaseThreadFunction(TAny* aPtr)
   264 //
   264 //
   265 // Initialise New thread
   265 // Initialise New thread
   266 //
   266 //
   267 	{
   267 	{
   268 	TInt r = KErrNoMemory;	// return value if a trap harness cannot be created
   268 
   269 	CTrapCleanup* cleanup=CTrapCleanup::New();
   269 	CTrapCleanup* cleanup=CTrapCleanup::New();
       
   270 	if (cleanup==NULL)
       
   271 		return(KErrNoMemory);
   270 	CFileBase& fMan=*(CFileBase*)aPtr;
   272 	CFileBase& fMan=*(CFileBase*)aPtr;
   271 
   273 	fMan.iSynchronizer.Wait();
   272 	if (cleanup != NULL)
   274 	TRAPD(ret,DoFManBaseOperationL(aPtr));
   273 		{
   275 	if (ret==KErrNone)
   274 		fMan.iSynchronizer.Wait();
   276 		ret=fMan.iLastError;
   275 		TRAP(r,DoFManBaseOperationL(aPtr));
   277 	delete cleanup;
   276 		if (r == KErrNone)
       
   277 			r = fMan.iLastError;
       
   278 		delete cleanup;
       
   279 		}
       
   280 
       
   281 	fMan.iSwitches=0;
   278 	fMan.iSwitches=0;
   282 	fMan.iFs=fMan.iFsOld;
   279 	fMan.iFs=fMan.iFsOld;
   283 	fMan.iStatus=NULL;
   280 	fMan.iStatus=NULL;
   284 	fMan.iFManThread.Close();
   281 	fMan.iFManThread.Close();
   285 	return (r);
   282 	return(ret);
   286 	}
   283 	}
   287 
   284 
   288 
   285 
   289 
   286 
   290 
   287 
   293 Creates a separate thread to run the command.
   290 Creates a separate thread to run the command.
   294 
   291 
   295 @param aThreadFunction The thread function.
   292 @param aThreadFunction The thread function.
   296 */
   293 */
   297 	{
   294 	{
       
   295 	iSwitches|=KFManBusyFlag;
       
   296 	User::LeaveIfError(iFManThread.Create(KNullDesC,aThreadFunction,KDefaultStackSize,NULL,this));
       
   297 	iFManThread.SetPriority(EPriorityMuchLess);
   298 	TFileName sessionPath;
   298 	TFileName sessionPath;
   299 	User::LeaveIfError(iFs.SessionPath(sessionPath));
   299 	User::LeaveIfError(iFs.SessionPath(sessionPath));
   300 	if (iSessionPath==NULL)
   300 	if (iSessionPath==NULL)
   301 		iSessionPath=HBufC::NewL((sessionPath.Length()));
   301 		iSessionPath=HBufC::NewL((sessionPath.Length()));
   302 	else if (iSessionPath->Des().MaxLength()<sessionPath.Length())
   302 	else if (iSessionPath->Des().MaxLength()<sessionPath.Length())
   303 		iSessionPath=iSessionPath->ReAllocL(IncPathLength(sessionPath.Length()));
   303 		iSessionPath=iSessionPath->ReAllocL(IncPathLength(sessionPath.Length()));
   304 	iSessionPath->Des()=sessionPath;
   304 	iSessionPath->Des()=sessionPath;
   305 
       
   306 	User::LeaveIfError(iFManThread.Create(KNullDesC,aThreadFunction,KDefaultStackSize,NULL,this));
       
   307 
       
   308 	// The code won't leave anymore after this.
       
   309 	// The effect of any further state changes to this instance
       
   310 	// should be undone / completed by the thread function.
       
   311 	iFManThread.SetPriority(EPriorityMuchLess);
       
   312 	iSwitches|=KFManBusyFlag;
       
   313 	iFsOld=iFs;
   305 	iFsOld=iFs;
   314 	iLastError=KErrNone;
   306 	iLastError=KErrNone;
   315 	iFManThread.Logon(*iStatus);
   307 	iFManThread.Logon(*iStatus);
   316 	iFManThread.Resume();
   308 	iFManThread.Resume();
   317 	}
   309 	}