Esempio n. 1
0
        //
        // Combined sync/async write method. For sync case asyncRequest==null
        //
        private void ProcessWrite(BufferOffsetSize[] buffers, SplitWriteAsyncProtocolRequest asyncRequest)
        {
            _SslState.CheckThrow(authSuccessCheck: true, shutdownCheck: true);

            foreach (BufferOffsetSize buffer in buffers)
            {
                ValidateParameters(buffer.Buffer, buffer.Offset, buffer.Size);
            }

            if (Interlocked.Exchange(ref _NestedWrite, 1) == 1)
            {
                throw new NotSupportedException(SR.GetString(SR.net_io_invalidnestedcall, (asyncRequest != null? "BeginWrite":"Write"), "write"));
            }

            bool failed = false;

            try
            {
                SplitWritesState splitWrite = new SplitWritesState(buffers);
                if (asyncRequest != null)
                {
                    asyncRequest.SetNextRequest(splitWrite, _ResumeAsyncWriteCallback);
                }

                StartWriting(splitWrite, asyncRequest);
            }
            catch (Exception e)
            {
                _SslState.FinishWrite();

                failed = true;
                if (e is IOException)
                {
                    throw;
                }
                throw new IOException(SR.GetString(SR.net_io_write), e);
            }
            finally
            {
                if (asyncRequest == null || failed)
                {
                    _NestedWrite = 0;
                }
            }
        }
Esempio n. 2
0
        private void ProcessWrite(BufferOffsetSize[] buffers, SplitWriteAsyncProtocolRequest asyncRequest)
        {
            foreach (BufferOffsetSize size in buffers)
            {
                this.ValidateParameters(size.Buffer, size.Offset, size.Size);
            }
            if (Interlocked.Exchange(ref this._NestedWrite, 1) == 1)
            {
                throw new NotSupportedException(SR.GetString("net_io_invalidnestedcall", new object[] { (asyncRequest != null) ? "BeginWrite" : "Write", "write" }));
            }
            bool flag = false;

            try
            {
                SplitWritesState splitWritesState = new SplitWritesState(buffers);
                if (asyncRequest != null)
                {
                    asyncRequest.SetNextRequest(splitWritesState, _ResumeAsyncWriteCallback);
                }
                this.StartWriting(splitWritesState, asyncRequest);
            }
            catch (Exception exception)
            {
                this._SslState.FinishWrite();
                flag = true;
                if (exception is IOException)
                {
                    throw;
                }
                throw new IOException(SR.GetString("net_io_write"), exception);
            }
            finally
            {
                if ((asyncRequest == null) || flag)
                {
                    this._NestedWrite = 0;
                }
            }
        }
Esempio n. 3
0
        //
        // Combined [....]/async write method. For [....] case asyncRequest==null
        //
        private void ProcessWrite(BufferOffsetSize[] buffers, SplitWriteAsyncProtocolRequest asyncRequest)
        {
            foreach (BufferOffsetSize buffer in buffers)
            {
                ValidateParameters(buffer.Buffer, buffer.Offset, buffer.Size);
            }

            if (Interlocked.Exchange(ref _NestedWrite, 1) == 1)
            {
                throw new NotSupportedException(SR.GetString(SR.net_io_invalidnestedcall, (asyncRequest != null? "BeginWrite":"Write"), "write"));
            }

            bool failed = false;
            try
            {
                SplitWritesState splitWrite = new SplitWritesState(buffers);
                if (asyncRequest != null)
                    asyncRequest.SetNextRequest(splitWrite, _ResumeAsyncWriteCallback);

                StartWriting(splitWrite, asyncRequest);
            }
            catch (Exception e)
            {
                _SslState.FinishWrite();

                failed = true;
                if (e is IOException) {
                    throw;
                }
                throw new IOException(SR.GetString(SR.net_io_write), e);
            }
            finally
            {
                if (asyncRequest == null || failed)
                {
                    _NestedWrite = 0;
                }
            }
        }
 private void ProcessWrite(BufferOffsetSize[] buffers, SplitWriteAsyncProtocolRequest asyncRequest)
 {
     foreach (BufferOffsetSize size in buffers)
     {
         this.ValidateParameters(size.Buffer, size.Offset, size.Size);
     }
     if (Interlocked.Exchange(ref this._NestedWrite, 1) == 1)
     {
         throw new NotSupportedException(SR.GetString("net_io_invalidnestedcall", new object[] { (asyncRequest != null) ? "BeginWrite" : "Write", "write" }));
     }
     bool flag = false;
     try
     {
         SplitWritesState splitWritesState = new SplitWritesState(buffers);
         if (asyncRequest != null)
         {
             asyncRequest.SetNextRequest(splitWritesState, _ResumeAsyncWriteCallback);
         }
         this.StartWriting(splitWritesState, asyncRequest);
     }
     catch (Exception exception)
     {
         this._SslState.FinishWrite();
         flag = true;
         if (exception is IOException)
         {
             throw;
         }
         throw new IOException(SR.GetString("net_io_write"), exception);
     }
     finally
     {
         if ((asyncRequest == null) || flag)
         {
             this._NestedWrite = 0;
         }
     }
 }