Esempio n. 1
0
        int StartOperation(ref AsyncProtocolRequest nestedRequest, ref BufferOffsetSize2 internalBuffer, AsyncOperation operation, AsyncProtocolRequest asyncRequest, string name)
        {
            if (Interlocked.CompareExchange(ref nestedRequest, asyncRequest, null) != null)
            {
                throw new InvalidOperationException("Invalid nested call.");
            }

            bool failed = false;

            try {
                internalBuffer.Reset();
                asyncRequest.StartOperation(operation);
                return(asyncRequest.UserResult);
            } catch (Exception e) {
                failed = true;
                if (e is IOException)
                {
                    throw;
                }
                throw new IOException(name + " failed", e);
            } finally {
                if (asyncRequest.UserAsyncResult == null || failed)
                {
                    internalBuffer.Reset();
                    nestedRequest = null;
                }
            }
        }
Esempio n. 2
0
        internal void ProcessAuthentication(LazyAsyncResult lazyResult)
        {
            var asyncRequest = new AsyncProtocolRequest(this, lazyResult);

            if (Interlocked.CompareExchange(ref asyncHandshakeRequest, asyncRequest, null) != null)
            {
                throw new InvalidOperationException("Invalid nested call.");
            }

            try {
                if (lastException != null)
                {
                    throw lastException;
                }
                if (xobileTlsContext == null)
                {
                    throw new InvalidOperationException();
                }

                readBuffer.Reset();
                writeBuffer.Reset();

                try {
                    asyncRequest.StartOperation(ProcessHandshake);
                } catch (Exception ex) {
                    throw SetException(ex);
                }
            } finally {
                if (lazyResult == null || lastException != null)
                {
                    readBuffer.Reset();
                    writeBuffer.Reset();
                    asyncHandshakeRequest = null;
                }
            }
        }
Esempio n. 3
0
        int StartOperation(ref AsyncProtocolRequest nestedRequest, ref BufferOffsetSize internalBuffer, AsyncOperation operation, AsyncProtocolRequest asyncRequest, string name)
        {
            if (Interlocked.CompareExchange (ref nestedRequest, asyncRequest, null) != null)
                throw new InvalidOperationException ("Invalid nested call.");

            bool failed = false;
            try {
                internalBuffer.Reset ();
                asyncRequest.StartOperation (operation);
                return asyncRequest.UserResult;
            } catch (Exception e) {
                failed = true;
                if (e is IOException)
                    throw;
                throw new IOException (name + " failed", e);
            } finally {
                if (asyncRequest.UserAsyncResult == null || failed) {
                    internalBuffer.Reset ();
                    nestedRequest = null;
                }
            }
        }
Esempio n. 4
0
        internal void ProcessAuthentication(LazyAsyncResult lazyResult)
        {
            var asyncRequest = new AsyncProtocolRequest (this, lazyResult);
            if (Interlocked.CompareExchange (ref asyncHandshakeRequest, asyncRequest, null) != null)
                throw new InvalidOperationException ("Invalid nested call.");

            try {
                if (lastException != null)
                    throw lastException;
                if (xobileTlsContext == null)
                    throw new InvalidOperationException ();

                readBuffer.Reset ();
                writeBuffer.Reset ();

                try {
                    asyncRequest.StartOperation (ProcessHandshake);
                } catch (Exception ex) {
                    throw SetException (ex);
                }
            } finally {
                if (lazyResult == null || lastException != null) {
                    readBuffer.Reset ();
                    writeBuffer.Reset ();
                    asyncHandshakeRequest = null;
                }
            }
        }