Exemple #1
0
        private static ICryptoTransform GetCryptoTransform(bool fEncrypt)
        {
            InterlockedStack st = (fEncrypt ? s_oEncryptorStack : s_oDecryptorStack);
            ICryptoTransform ct = (st.Pop() as ICryptoTransform);

            if (null == ct)
            {
                ct = NewCryptTransform(fEncrypt);
            }
            return(ct);
        }
Exemple #2
0
        private static void ConfigureEncryptionObject()
        {
            lock (s_initLock) {
                if (null == s_oDes)
                {
                    s_oEncryptorStack = new InterlockedStack();
                    s_oDecryptorStack = new InterlockedStack();
                    s_oHashAlgoStack  = new InterlockedStack();

                    DESCryptoServiceProvider des = new DESCryptoServiceProvider();
                    des.GenerateKey();
                    des.GenerateIV();
                    s_oDes = des;
                }
            }
        }
Exemple #3
0
        public DBObjectPool(DBObjectPoolControl ctrl)
        {
            _state = State.Initializing;
            _ctrl  = ctrl;
#if USECOUNTEROBJECT
            _poolCounter = new Counter();
#endif //USECOUNTEROBJECT
            _stackOld    = new InterlockedStack();
            _stackNew    = new InterlockedStack();
            _waitHandles = new ObjectPoolWaitHandle[3];
            _waitHandles[SEMAPHORE_HANDLE] = CreateWaitHandle(SafeNativeMethods.CreateSemaphore(IntPtr.Zero, 0, MAX_Q_SIZE, IntPtr.Zero), false);
            _waitHandles[ERROR_HANDLE]     = CreateWaitHandle(SafeNativeMethods.CreateEvent(IntPtr.Zero, 1, 0, IntPtr.Zero), false);
            _creationMutex = new Mutex();
            _waitHandles[CREATION_HANDLE] = CreateWaitHandle(_creationMutex.Handle, true);
            _errorWait   = ERROR_WAIT_DEFAULT;
            _cleanupWait = 0;    // Set in CreateCleanupTimer
            _errorTimer  = null; // No error yet.
            _objectList  = new ArrayList(_ctrl.MaxPool);

            if (ctrl.TransactionAffinity)
            {
                OperatingSystem osversion = Environment.OSVersion;

                if (PlatformID.Win32NT == osversion.Platform && 5 <= osversion.Version.Major)    // TODO: create an ADP.IsPlatformNT5 function?
                {
                    _txPool = CreateResourcePool();
                }
            }

            _cleanupTimer = CreateCleanupTimer();
            _state        = State.Running;

            // PerfCounters - this counter will never be decremented!
            IncrementPoolCount();

            // Make sure we're at quota by posting a callback to the threadpool.
            ThreadPool.QueueUserWorkItem(new WaitCallback(PoolCreateRequest));
        }
Exemple #4
0
        private static void ReturnCryptoTransform(bool fEncrypt, ICryptoTransform ct)
        {
            InterlockedStack st = (fEncrypt ? s_oEncryptorStack : s_oDecryptorStack);

            st.Push(ct);
        }