// Storage registration routines public bool RegisterStorage(EventingStorage Storage) { Lock.AcquireMutex(); bool success = RegisterStorageImpl(Storage.GetHandle()); Lock.ReleaseMutex(); return(success); }
public void UnRegisterStorage(EventingStorage Storage) { if (!Controller.Finalized) { Lock.AcquireMutex(); UnRegisterStorageImpl(Storage.GetHandle()); Lock.ReleaseMutex(); } }
// Public methods // Private methods internal override void Initialize() { base.Initialize(); EventTable = new Hashtable(); SourcesLookupTable = new Hashtable(); SourcesHandleTable = new Hashtable(); UIntPtr RepositoryStorageHandle = FetchLocalStorage(); if (RepositoryStorageHandle != 0) { TypesRepository = EventingStorage.CreateStorageFromHandle(RepositoryStorageHandle); // Fetch now the existing source list created before initializing the controller int currentSize = 20; UIntPtr [] sourceArray = new UIntPtr[currentSize]; if (sourceArray != null) { unsafe { fixed(UIntPtr *ptr = sourceArray) { int sourceCount = QuerySystemSources(ptr, (ushort)currentSize); while (sourceCount > currentSize) { sourceArray = new UIntPtr[sourceCount]; sourceCount = QuerySystemSources(ptr, (ushort)currentSize); } for (int i = 0; i < sourceCount; i++) { UIntPtr sourceHandle = sourceArray[i]; UIntPtr storageHandle = 0; string bufferName = ""; if (GetNativeSourceName(sourceHandle, ref storageHandle, ref bufferName)) { EventSource source = new EventSource(this, bufferName, storageHandle); if (source != null) { source.Register(); } } } } } } } else { TypesRepository = EventingStorage.CreateLocalStorage(QualityOfService.PermanentEvents, BUFFER_EXPANSION_SIZE); SetRepositoryStorage(TypesRepository.GetHandle()); } string sourceName = "ControllerLog"; #if SINGULARITY_KERNEL sourceName = sourceName + "{kernel}"; #else unsafe { int argMaxLen = ProcessService.GetStartupArg(0, null, 0); char[] argArray = new char [argMaxLen]; fixed(char *argptr = &argArray[0]) { int len = ProcessService.GetStartupArg(0, argptr, argArray.Length); sourceName = sourceName + "{" + String.StringCTOR(argptr, 0, len) + "}"; sourceName = sourceName + "(PID:" + ProcessService.GetCurrentProcessId() + ")"; } } #endif InternalSource = ControllerLogger.Create(sourceName, TypesRepository); }