Exemplo n.º 1
0
 public void SendFlow(Flow flow)
 {
     // Once the session flow state is added to flow, the flow frame has to be sent
     // before any additional transfers are sent; otherwise the implicit count on
     // the other side will be wrong. This is for outgoing only. Incoming seems ok.
     lock (this.SyncRoot)
     {
         this.AddFlowState(flow);
         this.Session.incomingChannel.AddFlowState(flow);
         this.Session.SendCommand(flow);
     }
 }
Exemplo n.º 2
0
            public void OnFlow(Flow flow)
            {
                uint newWindow = 0;
                lock (this.SyncRoot)
                {
                    uint flowNextIncomingId = flow.NextIncomingId.HasValue ? flow.NextIncomingId.Value : 0;
                    if (flow.IncomingWindow.Value == uint.MaxValue)
                    {
                        this.outgoingWindow = this.remoteIncomingWindow = uint.MaxValue;
                    }
                    else
                    {
                        this.remoteIncomingWindow = flowNextIncomingId + flow.IncomingWindow.Value - this.nextOutgoingId.Value;
                        this.outgoingWindow = this.remoteIncomingWindow;
                    }

                    newWindow = this.remoteIncomingWindow;
                }

                if (newWindow > 0)
                {
                    this.inflightDeliveries.ContinueWork();
                }
            }
Exemplo n.º 3
0
 public void SendFlow(Flow flow)
 {
     // Use the outgoing channel so we can synchronize this with transfers
     this.outgoingChannel.SendFlow(flow);
 }
Exemplo n.º 4
0
        void OnReceiveFlow(Flow flow)
        {
            this.outgoingChannel.OnFlow(flow);
            this.incomingChannel.OnFlow(flow);

            if (flow.Handle.HasValue)
            {
                AmqpLink link = null;
                if (!this.linksByRemoteHandle.TryGetObject(flow.Handle.Value, out link))
                {
                    this.TryClose(new AmqpException(AmqpError.UnattachedHandle));
                    return;
                }

                link.OnFlow(flow);
            }
            else if (flow.Echo())
            {
                this.SendFlow();
            }

            this.diagnostics.ReceiveFlow(flow.Handle.HasValue);
        }
Exemplo n.º 5
0
 public void OnFlow(Flow flow)
 {
     lock (this.SyncRoot)
     {
     }
 }
Exemplo n.º 6
0
 public void AddFlowState(Flow flow)
 {
     lock (this.SyncRoot)
     {
         flow.NextIncomingId = this.nextIncomingId.Value;
         flow.IncomingWindow = this.incomingWindow;
         this.needFlowCount = 0;
     }
 }
Exemplo n.º 7
0
 public void AddFlowState(Flow flow)
 {
     lock (this.SyncRoot)
     {
         flow.OutgoingWindow = this.outgoingWindow;
         flow.NextOutgoingId = this.nextOutgoingId.Value;
     }
 }
Exemplo n.º 8
0
        void SendFlow(bool echo, bool drain, ArraySegment<byte> txnId)
        {
            if (this.IsClosing())
            {
                return;
            }

            if (Interlocked.Exchange(ref this.sendingFlow, 1) == 1)
            {
                return;
            }

            try
            {
                Flow flow = new Flow();
                flow.Handle = this.LocalHandle;
                lock (this.syncRoot)
                {
                    flow.LinkCredit = this.linkCredit;
                    flow.Available = this.available;
                    flow.DeliveryCount = this.deliveryCount.Value;
                }

                if (drain)
                {
                    flow.Drain = true;
                }

                if (echo)
                {
                    flow.Echo = echo;
                }

                if (txnId.Array != null)
                {
                    flow.Properties = new Fields();
                    flow.Properties["txn-id"] = txnId;
                }

                this.Session.SendFlow(flow);
            }
            finally
            {
                Interlocked.Exchange(ref this.sendingFlow, 0);
            }
        }
Exemplo n.º 9
0
        ArraySegment<byte> GetTxnIdFromFlow(Flow flow)
        {
            object txnId;
            if (flow.Properties != null &&
                (txnId = flow.Properties["txn-id"]) != null)
            {
                return (ArraySegment<byte>)txnId;
            }

            return AmqpConstants.EmptyBinary;
        }
Exemplo n.º 10
0
        void OnReceiveFlow(Flow flow)
        {
            Utils.Trace(TraceLevel.Verbose, "{0}: Receive {1}", this, flow);
            lock (this.syncRoot)
            {
                if (this.IsReceiver)
                {
                    this.available = flow.Available ?? uint.MaxValue;
                    // this.transferCount = flow.TransferCount ?? this.transferCount;
                }
                else
                {
                    this.drain = flow.Drain ?? false;
                    if (flow.LinkCredit() != uint.MaxValue)
                    {
                        if (this.linkCredit == uint.MaxValue)
                        {
                            this.linkCredit = flow.LinkCredit.Value;
                        }
                        else
                        {
                            uint oldCredit = this.linkCredit;
                            uint otherDeliveryCount = flow.DeliveryCount ?? 0;
                            this.linkCredit = unchecked(otherDeliveryCount + flow.LinkCredit.Value - this.deliveryCount.Value);
                        }
                    }
                    else
                    {
                        this.linkCredit = uint.MaxValue;
                    }
                }
            }

            this.pendingDeliveries.ContinueWork();

            if (flow.Echo())
            {
                this.SendFlow(false);
            }

            if (this.linkCredit > 0)
            {
                ArraySegment<byte> txnId = this.GetTxnIdFromFlow(flow);
                this.OnCreditAvailable(this.linkCredit, this.drain, txnId);
            }
        }
Exemplo n.º 11
0
 public void OnFlow(Flow flow)
 {
     this.OnReceiveFlow(flow);
 }