private IAssetService GetConnector(string url) { IAssetService connector = null; lock (m_connectors) { if (m_connectors.ContainsKey(url)) { connector = m_connectors[url]; } else { // Still not as flexible as I would like this to be, // but good enough for now string connectorType = new HeloServicesConnector(url).Helo(); m_log.DebugFormat("[HG ASSET SERVICE]: HELO returned {0}", connectorType); if (connectorType == "opensim-simian") { connector = new SimianAssetServiceConnector(url); } else { connector = new AssetServicesConnector(url); } m_connectors.Add(url, connector); } } return(connector); }
private IAssetService GetConnector(string url) { IAssetService connector = null; m_connectorsRwLock.AcquireReaderLock(-1); try { if (m_connectors.ContainsKey(url)) { connector = m_connectors[url]; } else { LockCookie lc = m_connectorsRwLock.UpgradeToWriterLock(-1); try { /* recheck since other thread may have created it */ if (m_connectors.ContainsKey(url)) { connector = m_connectors[url]; } else { // Still not as flexible as I would like this to be, // but good enough for now string connectorType = new HeloServicesConnector(url).Helo(); m_log.DebugFormat("[HG ASSET SERVICE]: HELO returned {0}", connectorType); if (connectorType == "opensim-simian") { connector = new SimianAssetServiceConnector(url); } else { connector = new AssetServicesConnector(url); } m_connectors.Add(url, connector); } } finally { m_connectorsRwLock.DowngradeFromWriterLock(ref lc); } } } finally { m_connectorsRwLock.ReleaseReaderLock(); } return(connector); }