// // // private static void WriteCallback(IAsyncResult transportResult) { GlobalLog.Assert(transportResult.AsyncState is LazyAsyncResult, "WriteCallback|State type is wrong, expected LazyAsyncResult."); if (transportResult.CompletedSynchronously) { return; } LazyAsyncResult lazyResult = (LazyAsyncResult)transportResult.AsyncState; // Async completion try { NegoState authState = (NegoState)lazyResult.AsyncObject; authState._Framer.EndWriteMessage(transportResult); //special case for an error notification if (lazyResult.Result is Exception) { authState._CanRetryAuthentication = true; throw (Exception)lazyResult.Result; } authState.CheckCompletionBeforeNextReceive(lazyResult); } catch (Exception e) { if (lazyResult.InternalPeekCompleted) { // This will throw on a worker thread. throw; } lazyResult.InvokeCallback(e); } }
private static void ReadCallback(IAsyncResult transportResult) { if (!(transportResult.AsyncState is LazyAsyncResult)) { NetEventSource.Fail(transportResult, "State type is wrong, expected LazyAsyncResult."); } if (transportResult.CompletedSynchronously) { return; } LazyAsyncResult lazyResult = (LazyAsyncResult)transportResult.AsyncState; // Async completion. try { NegoState authState = (NegoState)lazyResult.AsyncObject; byte[] message = authState._framer.EndReadMessage(transportResult); authState.ProcessReceivedBlob(message, lazyResult); } catch (Exception e) { if (lazyResult.InternalPeekCompleted) { // This will throw on a worker thread. throw; } lazyResult.InvokeCallback(e); } }
private static void WriteCallback(IAsyncResult transportResult) { if (!transportResult.CompletedSynchronously) { LazyAsyncResult asyncState = (LazyAsyncResult)transportResult.AsyncState; try { NegoState asyncObject = (NegoState)asyncState.AsyncObject; asyncObject._Framer.EndWriteMessage(transportResult); if (asyncState.Result is Exception) { asyncObject._CanRetryAuthentication = true; throw ((Exception)asyncState.Result); } asyncObject.CheckCompletionBeforeNextReceive(asyncState); } catch (Exception exception) { if (asyncState.InternalPeekCompleted) { throw; } asyncState.InvokeCallback(exception); } } }
// // This will check and logically complete the auth handshake // private void CheckCompletionBeforeNextReceive(LazyAsyncResult lazyResult) { if (HandshakeComplete && _RemoteOk) { //we are done with success if (lazyResult != null) { lazyResult.InvokeCallback(); } return; } StartReceiveBlob(lazyResult); }
private void CheckCompletionBeforeNextReceive(LazyAsyncResult lazyResult) { if (this.HandshakeComplete && this._RemoteOk) { if (lazyResult != null) { lazyResult.InvokeCallback(); } } else { this.StartReceiveBlob(lazyResult); } }
private void CheckCompletionBeforeNextSend(byte[] message, LazyAsyncResult lazyResult) { if (this.HandshakeComplete) { if (!this._RemoteOk) { throw new AuthenticationException(SR.GetString("net_io_header_id", new object[] { "MessageId", this._Framer.ReadHeader.MessageId, 20 }), null); } if (lazyResult != null) { lazyResult.InvokeCallback(); } } else { this.StartSendBlob(message, lazyResult); } }
// // This will check and logically complete the auth handshake // private void CheckCompletionBeforeNextSend(byte[] message, LazyAsyncResult lazyResult) { //If we are done don't go into send if (HandshakeComplete) { if (!_RemoteOk) { throw new AuthenticationException(SR.GetString(SR.net_io_header_id, "MessageId", _Framer.ReadHeader.MessageId, FrameHeader.HandshakeDoneId), null); } if (lazyResult != null) { lazyResult.InvokeCallback(); } return; } // Not yet done, get a new blob and send it if any StartSendBlob(message, lazyResult); }
private static void ReadCallback(IAsyncResult transportResult) { if (!transportResult.CompletedSynchronously) { LazyAsyncResult asyncState = (LazyAsyncResult)transportResult.AsyncState; try { NegoState asyncObject = (NegoState)asyncState.AsyncObject; byte[] message = asyncObject._Framer.EndReadMessage(transportResult); asyncObject.ProcessReceivedBlob(message, asyncState); } catch (Exception exception) { if (asyncState.InternalPeekCompleted) { throw; } asyncState.InvokeCallback(exception); } } }
private static void WriteCallback(IAsyncResult transportResult) { if (!(transportResult.AsyncState is LazyAsyncResult)) { NetEventSource.Fail(transportResult, "State type is wrong, expected LazyAsyncResult."); } if (transportResult.CompletedSynchronously) { return; } LazyAsyncResult lazyResult = (LazyAsyncResult)transportResult.AsyncState; // Async completion. try { NegoState authState = (NegoState)lazyResult.AsyncObject; authState._framer.EndWriteMessage(transportResult); // Special case for an error notification. if (lazyResult.Result is Exception e) { authState._canRetryAuthentication = true; ExceptionDispatchInfo.Throw(e); } authState.CheckCompletionBeforeNextReceive(lazyResult); } catch (Exception e) { if (lazyResult.InternalPeekCompleted) { // This will throw on a worker thread. throw; } lazyResult.InvokeCallback(e); } }
internal void FinishRead(byte[] renegotiateBuffer) { if (Interlocked.CompareExchange(ref this._LockReadState, 0, 4) == 2) { lock (this) { LazyAsyncResult result = this._QueuedReadStateRequest as LazyAsyncResult; if (result != null) { this._QueuedReadStateRequest = null; result.InvokeCallback(renegotiateBuffer); } else { AsyncProtocolRequest state = (AsyncProtocolRequest)this._QueuedReadStateRequest; state.Buffer = renegotiateBuffer; this._QueuedReadStateRequest = null; ThreadPool.QueueUserWorkItem(new WaitCallback(this.AsyncResumeHandshakeRead), state); } } } }
// // This will check and logically complete the auth handshake. // private void CheckCompletionBeforeNextSend(byte[] message, LazyAsyncResult lazyResult) { //If we are done don't go into send. if (HandshakeComplete) { if (!_remoteOk) { throw new AuthenticationException(SR.Format(SR.net_io_header_id, "MessageId", _framer.ReadHeader.MessageId, FrameHeader.HandshakeDoneId), null); } if (lazyResult != null) { lazyResult.InvokeCallback(); } return; } // Not yet done, get a new blob and send it if any. StartSendBlob(message, lazyResult); }
// // This will check and logically complete the auth handshake. // private void CheckCompletionBeforeNextReceive(LazyAsyncResult lazyResult) { if (HandshakeComplete && _remoteOk) { // We are done with success. if (lazyResult != null) { lazyResult.InvokeCallback(); } return; } StartReceiveBlob(lazyResult); }