Example #1
0
        public unsafe bool ReadActiveSourceItem(UIntPtr sourceHandle,
                                                int item,
                                                UIntPtr *type,
                                                byte *buffer,
                                                UInt16 bufferSize)
        {
            Lock.AcquireMutex();

            object source = SourcesHandleTable[sourceHandle];

            if (source != null)
            {
                ActiveSource activeSource = source as ActiveSource;

                if (activeSource != null)
                {
                    bool success = activeSource.GetActiveEntry(item, type, buffer, bufferSize);
                    Lock.ReleaseMutex();

                    return(success);
                }
            }

            Lock.ReleaseMutex();
            return(false);
        }
Example #2
0
        public override bool GetSourceInformation(UIntPtr sourceHandle,
                                                  ref UIntPtr storageHandle,
                                                  ref UIntPtr eventType,
                                                  ref UInt16 count,
                                                  ref string bufferName)
        {
            Lock.AcquireMutex();

            EventSource source = SourcesHandleTable[sourceHandle] as EventSource;

            if (source != null)
            {
                bufferName = source.SourceName;
                ActiveSource activeSource = source as ActiveSource;

                if (activeSource != null)
                {
                    storageHandle = 0;
                    eventType     = activeSource.EventTypeHandle;
                    count         = activeSource.Count;
                }
                else
                {
                    storageHandle = source.Storage.GetHandle();
                    eventType     = 0;
                    count         = 0;
                }

                Lock.ReleaseMutex();

                return(true);
            }

            Lock.ReleaseMutex();
            return(false);
        }
Example #3
0
        // 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);
        }