예제 #1
0
        private PassiveReadRequest StartRead()
        {
            NetworkChannel     netChannel         = this.m_netChannel;
            PassiveReadRequest passiveReadRequest = new PassiveReadRequest(this, netChannel);
            bool flag = false;

            try
            {
                if (!this.Copier.TestHungPassiveBlockMode)
                {
                    netChannel.StartRead(new NetworkChannelCallback(PassiveBlockMode.ReadCallback), passiveReadRequest);
                    flag = true;
                }
            }
            finally
            {
                if (!flag)
                {
                    PassiveBlockMode.Tracer.TraceError((long)this.GetHashCode(), "Failed to start async read");
                }
            }
            return(passiveReadRequest);
        }
예제 #2
0
 private void ProcessReadCallback(PassiveReadRequest ioReq, int bytesAvailable, bool completionIsSynchronous, Exception readEx)
 {
     PassiveBlockMode.Tracer.TraceFunction <string>((long)this.GetHashCode(), "ProcessReadCallback({0}) entered", this.DatabaseName);
     lock (this.m_workerLock)
     {
         this.DisableTimer();
         Exception ex    = null;
         bool      flag2 = false;
         try
         {
             this.m_recursionDepth++;
             DiagCore.RetailAssert(this.m_recursionDepth == 1 || completionIsSynchronous, "recursive async completion", new object[0]);
             ioReq.CompletionWasProcessed = true;
             if (completionIsSynchronous)
             {
                 ioReq.CompletedSynchronously = completionIsSynchronous;
             }
             if (readEx != null)
             {
                 PassiveBlockMode.Tracer.TraceError <string, Exception>((long)this.GetHashCode(), "ProcessReadCallback({0}) read failed: ex={1}", this.DatabaseName, readEx);
                 ex = new NetworkCommunicationException(this.Configuration.SourceMachine, readEx.Message, readEx);
             }
             else if (bytesAvailable == 0)
             {
                 PassiveBlockMode.Tracer.TraceError <string>((long)this.GetHashCode(), "ProcessReadCallback({0}) active closed connection", this.DatabaseName);
                 ex = new NetworkEndOfDataException(this.Configuration.SourceMachine, ReplayStrings.NetworkReadEOF);
             }
             else if (ioReq.Channel != this.m_netChannel)
             {
                 ex    = new NetworkEndOfDataException(this.Configuration.SourceMachine, ReplayStrings.NetworkReadEOF);
                 flag2 = true;
                 ioReq.Channel.Close();
             }
             else if (!this.IsBlockModeActive)
             {
                 PassiveBlockMode.Tracer.TraceError <string>((long)this.GetHashCode(), "Discarding read since BM was already terminated", this.DatabaseName);
             }
             else
             {
                 QueuedBlockMsg queuedBlockMsg = this.ReadInputMessage(ioReq.Channel);
                 if (queuedBlockMsg != null)
                 {
                     this.ProcessInput(queuedBlockMsg);
                     if (BitMasker.IsOn((int)queuedBlockMsg.EmitContext.grbitOperationalFlags, 2))
                     {
                         this.HandleActiveDismount();
                         return;
                     }
                     if (BitMasker.IsOn((int)queuedBlockMsg.EmitContext.grbitOperationalFlags, 16))
                     {
                         this.Copier.TrackLastContactTime(queuedBlockMsg.MessageUtc);
                     }
                 }
                 if (this.m_recursionDepth == 1)
                 {
                     while (this.IsBlockModeActive)
                     {
                         PassiveReadRequest passiveReadRequest = this.StartRead();
                         if (!passiveReadRequest.CompletionWasProcessed)
                         {
                             if (!this.m_runningAcll)
                             {
                                 this.ScheduleTimer();
                                 break;
                             }
                             break;
                         }
                     }
                 }
                 else
                 {
                     PassiveBlockMode.Tracer.TraceDebug <int>((long)this.GetHashCode(), "Recursive read avoided. Depth={0}", this.m_recursionDepth);
                 }
             }
         }
         catch (NetworkTransportException ex2)
         {
             ex = ex2;
         }
         catch (NetworkRemoteException ex3)
         {
             ex = ex3;
         }
         catch (GranularReplicationOverflowException ex4)
         {
             ex = ex4;
         }
         finally
         {
             this.m_recursionDepth--;
             if (ex != null && !flag2)
             {
                 this.Terminate();
             }
             PassiveBlockMode.Tracer.TraceFunction <string>((long)this.GetHashCode(), "ProcessReadCallback({0}) exits", this.DatabaseName);
         }
     }
 }
예제 #3
0
        private static void ReadCallback(object asyncState, int bytesAvailable, bool completionIsSynchronous, Exception e)
        {
            PassiveReadRequest passiveReadRequest = (PassiveReadRequest)asyncState;

            passiveReadRequest.Manager.ProcessReadCallback(passiveReadRequest, bytesAvailable, completionIsSynchronous, e);
        }