Attach and probably start a service through the first available subsystem.
| 6695 | |
| 6696 | // Attach and probably start a service through the first available subsystem. |
| 6697 | IService* Dispatcher::internalServiceAttach(CheckStatusWrapper* status, const PathName& svcName, |
| 6698 | ClumpletReader& spb, std::function<void(CheckStatusWrapper*, IService*)> start, |
| 6699 | IProvider** retProvider) |
| 6700 | { |
| 6701 | IService* service = NULL; |
| 6702 | |
| 6703 | // Build correct config |
| 6704 | RefPtr<const Config> config(Config::getDefaultConfig()); |
| 6705 | if (spb.find(isc_spb_config)) |
| 6706 | { |
| 6707 | string spb_config; |
| 6708 | spb.getString(spb_config); |
| 6709 | Config::merge(config, &spb_config); |
| 6710 | } |
| 6711 | |
| 6712 | FbLocalStatus temp1, temp2; |
| 6713 | CheckStatusWrapper* currentStatus = &temp1; |
| 6714 | |
| 6715 | for (GetPlugins<IProvider> providerIterator(IPluginManager::TYPE_PROVIDER, config); |
| 6716 | providerIterator.hasData(); |
| 6717 | providerIterator.next()) |
| 6718 | { |
| 6719 | IProvider* p = providerIterator.plugin(); |
| 6720 | |
| 6721 | if (cryptCallback) |
| 6722 | { |
| 6723 | p->setDbCryptCallback(currentStatus, cryptCallback); |
| 6724 | if (currentStatus->getState() & IStatus::STATE_ERRORS) |
| 6725 | continue; |
| 6726 | } |
| 6727 | |
| 6728 | service = p->attachServiceManager(currentStatus, svcName.c_str(), |
| 6729 | spb.getBufferLength(), spb.getBuffer()); |
| 6730 | |
| 6731 | if (!(currentStatus->getState() & IStatus::STATE_ERRORS)) |
| 6732 | { |
| 6733 | start(currentStatus, service); |
| 6734 | |
| 6735 | if (!(currentStatus->getState() & IStatus::STATE_ERRORS)) |
| 6736 | { |
| 6737 | fb_utils::copyStatus(status, currentStatus); |
| 6738 | if (retProvider) |
| 6739 | { |
| 6740 | p->addRef(); |
| 6741 | *retProvider = p; |
| 6742 | } |
| 6743 | |
| 6744 | return service; |
| 6745 | } |
| 6746 | } |
| 6747 | |
| 6748 | switch (currentStatus->getErrors()[1]) |
| 6749 | { |
| 6750 | case isc_service_att_err: |
| 6751 | currentStatus = &temp2; |
| 6752 | // fall down... |
| 6753 | case isc_unavailable: |
| 6754 | case isc_wrong_ods: |
no test coverage detected