// Eventing source support routines public override bool RegisterSource(EventSource source) { // Sanity check against double registration if (source.SourceHandle != 0) { return(false); } UIntPtr sourceHandle = 0; Lock.AcquireMutex(); object obj = SourcesLookupTable[source.SourceName]; if (obj != null) { sourceHandle = (UIntPtr)obj; } if (sourceHandle != 0) { object existingSource = SourcesHandleTable[sourceHandle]; if (existingSource != null) { // Type already registered. Return the existing value Lock.ReleaseMutex(); return(false); } } else { // The handle for this source has not been allocated // Register a new one sourceHandle = AllocateSourceHandleImpl(source.SourceName); while (sourceHandle == 0) { if (!TypesRepository.AddBuffer(BUFFER_EXPANSION_SIZE)) { Lock.ReleaseMutex(); return(false); } sourceHandle = AllocateSourceHandleImpl(source.SourceName); } SourcesLookupTable[source.SourceName] = sourceHandle; } // We must have here a valid source handle source.SourceHandle = sourceHandle; SourcesHandleTable[sourceHandle] = source; ActiveSource activeSource = source as ActiveSource; if (activeSource == null) { // regular sources with associated memory storage RegisterSourceStorageImpl(sourceHandle, source.Storage.GetHandle(), source.ControlFlags); } else { RegisterActiveSourceImpl(sourceHandle, activeSource.EventTypeHandle, activeSource.DebugBufferAddress, activeSource.Count, activeSource.EntrySize); // Active sources, the object does the event buffer management } Lock.ReleaseMutex(); return(true); }
public virtual void UnRegisterSource(EventSource source) { }
// 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); }
// // Source related methods // public virtual bool RegisterSource(EventSource source) { return(false); }