622 |
622 |
623 /** |
623 /** |
624 Create a plugin thread |
624 Create a plugin thread |
625 Should only by called from main file server thread with plugin thread unavailable |
625 Should only by called from main file server thread with plugin thread unavailable |
626 */ |
626 */ |
627 TInt FsPluginManager::InitPlugin(CFsPlugin& aPlugin) |
627 TInt FsPluginManager::InitPlugin(CFsPlugin& aPlugin, RLibrary aLibrary) |
628 { |
628 { |
629 TInt err = KErrNone; |
629 TInt err = KErrNone; |
630 |
630 |
631 if(!aPlugin.iThreadP) |
631 if(!aPlugin.iThreadP) |
632 { |
632 { |
633 TRAP(err,aPlugin.iThreadP=CPluginThread::NewL(aPlugin)); |
633 TRAP(err,aPlugin.iThreadP=CPluginThread::NewL(aPlugin, aLibrary)); |
634 if(err!=KErrNone) |
634 if(err!=KErrNone) |
635 return err; |
635 return err; |
636 } |
636 } |
637 |
637 |
638 aPlugin.iThreadId = aPlugin.iThreadP->StartL(); |
638 aPlugin.iThreadId = aPlugin.iThreadP->StartL(); |
743 // Iterate through all plugins, cancelling outstanding session requests |
743 // Iterate through all plugins, cancelling outstanding session requests |
744 aRequest->Set(CancelPluginOp, aSession); |
744 aRequest->Set(CancelPluginOp, aSession); |
745 |
745 |
746 FsPluginManager::LockChain(); |
746 FsPluginManager::LockChain(); |
747 TInt count = FsPluginManager::ChainCount(); |
747 TInt count = FsPluginManager::ChainCount(); |
|
748 TInt oldCount = count; |
748 TInt i; |
749 TInt i; |
749 for(i=0; i<count; i++) |
750 for(i=0; i<count; i++) |
750 { |
751 { |
751 CFsPlugin* plugin = NULL; |
752 CFsPlugin* plugin = NULL; |
752 User::LeaveIfError(FsPluginManager::Plugin(plugin, i)); |
753 (void) FsPluginManager::Plugin(plugin, i); // (void) as chain is locked. |
753 __ASSERT_DEBUG(plugin, User::Leave(KErrNotFound)); |
754 __ASSERT_DEBUG(plugin, User::Leave(KErrNotFound)); |
754 aRequest->iCurrentPlugin = plugin; |
755 aRequest->iCurrentPlugin = plugin; |
755 aRequest->Status() = KRequestPending; |
756 aRequest->Status() = KRequestPending; |
756 aRequest->Dispatch(); |
757 aRequest->Dispatch(); |
757 //Cancel is delivered to the front of the request queue |
758 //Cancel is delivered to the front of the request queue |
759 FsPluginManager::UnlockChain(); |
760 FsPluginManager::UnlockChain(); |
760 User::WaitForRequest(aRequest->Status()); |
761 User::WaitForRequest(aRequest->Status()); |
761 FsPluginManager::LockChain(); |
762 FsPluginManager::LockChain(); |
762 __ASSERT_ALWAYS(aRequest->Status().Int()==KErrNone||aRequest->Status().Int()==KErrCancel,Fault(ESessionDisconnectThread2)); |
763 __ASSERT_ALWAYS(aRequest->Status().Int()==KErrNone||aRequest->Status().Int()==KErrCancel,Fault(ESessionDisconnectThread2)); |
763 count = FsPluginManager::ChainCount(); |
764 count = FsPluginManager::ChainCount(); |
|
765 //If a plugin was removed whilst the chain was unlocked we need to make sure we don't skip any plugins |
|
766 if(count != oldCount) |
|
767 { |
|
768 i=0; |
|
769 oldCount = count; |
|
770 } |
764 } |
771 } |
765 FsPluginManager::UnlockChain(); |
772 FsPluginManager::UnlockChain(); |
766 |
773 |
767 // RDebug::Print(_L("FsPluginManager::CompleteSessionRequests - CSRs")); |
774 // RDebug::Print(_L("FsPluginManager::CompleteSessionRequests - CSRs")); |
768 iScheduler->CompleteSessionRequests(aSession, aValue); |
775 iScheduler->CompleteSessionRequests(aSession, aValue); |