userlibandfileserver/fileserver/sfile/sf_thread.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
   923 	TUint id=t.Id();
   923 	TUint id=t.Id();
   924 	return(id);
   924 	return(id);
   925 	}
   925 	}
   926 
   926 
   927 
   927 
   928 CPluginThread::CPluginThread(CFsPlugin& aPlugin, RLibrary aLibrary)
   928 CPluginThread::CPluginThread(CFsPlugin& aPlugin)
   929   : iPlugin(aPlugin), iLib(aLibrary)
   929   : iPlugin(aPlugin)
   930 	{
   930 	{
   931 	/** @prototype */
   931 	/** @prototype */
   932 	iOperationLock.Close();
   932 	iOperationLock.Close();
   933 	iPlugin.Open();
   933 	iPlugin.Open();
   934 	
       
   935     /* 
       
   936     Duplicate the handle to the DLL which created the plugin to prevent 
       
   937     TFsRemovePlugin::DoRequestL() from unmapping the DLL's code segment before
       
   938     this thread's destructor has been called as the destructor closes the plugin 
       
   939     which results in a call to the plugin's derived destructor contained in the DLL (!)
       
   940     */ 
       
   941     TInt r = iLib.Duplicate(iThread, EOwnerProcess);
       
   942     __ASSERT_ALWAYS(r==KErrNone, Fault(EFsThreadConstructor));
       
   943 	}
   934 	}
   944 
   935 
   945 CPluginThread::~CPluginThread()
   936 CPluginThread::~CPluginThread()
   946     {
   937     {
   947     iPlugin.Close();
   938     iPlugin.Close();
   948 	iLib.Close();
       
   949     }
   939     }
   950 
   940 
   951 
   941 
   952 CPluginThread* CPluginThread::NewL(CFsPlugin& aPlugin, RLibrary aLibrary)
   942 CPluginThread* CPluginThread::NewL(CFsPlugin& aPlugin)
   953 	{
   943 	{
   954 	__PRINT(_L("CPluginThread::NewL()"));
   944 	__PRINT(_L("CPluginThread::NewL()"));
   955 	CPluginThread* pT=new(ELeave) CPluginThread(aPlugin, aLibrary);
   945 	CPluginThread* pT=new(ELeave) CPluginThread(aPlugin);
   956 	TInt r=pT->Initialise();
   946 	TInt r=pT->Initialise();
   957 
   947 
   958 	/** @prototype */
   948 	/** @prototype */
   959 	if(r == KErrNone)
   949 	if(r == KErrNone)
   960 		r=pT->iOperationLock.CreateLocal(0);
   950 		r=pT->iOperationLock.CreateLocal(0);