Пример #1
0
        public MQSession GetSession(int connectOptions, MQSSLConfigOptions sslConfigOptions, MQConnectionSecurityParameters mqcsp, MQChannelDefinition mqcd, string qMgrName, int nmqiFlags, string uidFlowUserid, string uidFlowPassword, int ccsid, int maxFapLevel)
        {
            uint method = 0x5e7;

            this.TrEntry(method, new object[] { connectOptions, mqcsp, mqcd, qMgrName, nmqiFlags, uidFlowUserid, (uidFlowPassword == null) ? uidFlowPassword : "******", ccsid, maxFapLevel });
            MQSession session = null;

            try
            {
                MQConnectionSpecification specification = new MQConnectionSpecification(base.env, this, mqcd, sslConfigOptions, nmqiFlags, uidFlowUserid, uidFlowPassword, ccsid);
                try
                {
                    this.callSync.Acquire();
                    object obj2 = null;
                    foreach (object obj3 in this.allConnectionSpecs.Keys)
                    {
                        MQConnectionSpecification specification2 = (MQConnectionSpecification)obj3;
                        if (specification2.Equals(specification))
                        {
                            specification = specification2;
                            obj2          = specification2;
                            base.TrText(method, "Found a matching connection spec..");
                            break;
                        }
                    }
                    if (obj2 == null)
                    {
                        base.TrText(method, "Couldnt find a matching connection spec. Adding new one into table");
                        this.allConnectionSpecs.Add(specification, specification);
                    }
                }
                finally
                {
                    this.callSync.Release();
                }
                session = specification.GetSession(mqcd, sslConfigOptions, mqcsp, this.fap, qMgrName, connectOptions, maxFapLevel);
                try
                {
                    this.callSync.Acquire();
                    if (!this.allConnectionSpecs.ContainsKey(specification))
                    {
                        this.allConnectionSpecs.Add(specification, specification);
                    }
                }
                finally
                {
                    this.callSync.Release();
                }
            }
            finally
            {
                base.TrExit(method);
            }
            return(session);
        }
Пример #2
0
        public void Run()
        {
            uint method = 0x60e;

            this.TrEntry(method);
            this.threadId = Thread.CurrentThread.GetHashCode();
            string str = "RcvThread: " + this.remoteConnection.ToString();

            Thread.CurrentThread.Name = str;
            try
            {
                int       conversationID;
                int       requestID;
                MQSession sessionByConvId;
                int       segmentType;
                MQSOCKACT mqsockact;
                MQTSH     rTSH = null;
Label_0040:
                rTSH = this.ReceiveOneTSH();
                if (rTSH == null)
                {
                    base.TrText(method, "Null TSH is received.. breaking and disconnecting now");
                    return;
                }
                if (this.remoteConnection.RemoteEncoding != rTSH.Encoding)
                {
                    this.remoteConnection.RemoteEncoding = rTSH.Encoding;
                }
                switch (rTSH.TSHType)
                {
                case 1:
                    base.TrText(method, "TSHM data has been received");
                    conversationID = rTSH.ConversationID;
                    requestID      = rTSH.RequestID;
                    base.TrText(method, "ConversationId = " + conversationID);
                    base.TrText(method, "RequestId = " + requestID);
                    sessionByConvId = this.remoteConnection.GetSessionByConvId(conversationID);
                    if ((sessionByConvId == null) || !sessionByConvId.IsEndRequested)
                    {
                        break;
                    }
                    base.TrText(method, "Current Sessions " + sessionByConvId.ToString() + " ending..");
                    goto Label_0040;

                case 2:
                {
                    if (rTSH.SegmentType != 12)
                    {
                        goto Label_0515;
                    }
                    mqsockact = new MQSOCKACT();
                    if ((rTSH.Encoding & 15) == 2)
                    {
                        goto Label_037D;
                    }
                    base.TrText(method, "We received BigEndian data, read it into our encoding");
                    byte[] dst = new byte[mqsockact.GetLength()];
                    Buffer.BlockCopy(rTSH.TshBuffer, rTSH.Offset, dst, 0, mqsockact.GetLength());
                    Array.Reverse(dst);
                    mqsockact.ReadStruct(dst, 0);
                    goto Label_0391;
                }

                default:
                {
                    CommonServices.SetValidInserts();
                    CommonServices.ArithInsert1   = 1;
                    CommonServices.CommentInsert1 = this.remoteConnection.NegotiatedChannel.ChannelName;
                    CommonServices.CommentInsert2 = "Invalid TSH flow is received on the receiver thread";
                    base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                    NmqiException exception7 = new NmqiException(base.env, -1, null, 2, 0x7d9, null);
                    base.TrException(method, exception7);
                    throw exception7;
                }
                }
                if (requestID == 0)
                {
                    if (sessionByConvId != null)
                    {
                        sessionByConvId.DeliverTSH(rTSH);
                    }
                    else if (conversationID == 1)
                    {
                        this.remoteConnection.DeliverTSH(rTSH);
                    }
                    else
                    {
                        base.TrText(method, "Unknown Conversation & RequestId");
                    }
                }
                else
                {
                    if (requestID != 1)
                    {
                        goto Label_0285;
                    }
                    if (sessionByConvId == null)
                    {
                        base.TrText(method, "Unknown Conversation and no existing Session could be found for it.");
                    }
                    else
                    {
                        MQProxyQueueManager proxyQueueManager;
                        rTSH        = sessionByConvId.ProcessReceivedData(rTSH);
                        segmentType = rTSH.SegmentType;
                        switch (segmentType)
                        {
                        case 13:
                        case 15:
                            proxyQueueManager = sessionByConvId.Hconn.ProxyQueueManager;
                            if (proxyQueueManager == null)
                            {
                                NmqiException exception = new NmqiException(base.env, -1, null, 2, 0x7d9, null);
                                CommonServices.SetValidInserts();
                                CommonServices.ArithInsert1   = 1;
                                CommonServices.ArithInsert2   = (uint)segmentType;
                                CommonServices.CommentInsert1 = "PQM couldn't be found on obtained Session for TSH flow";
                                base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                                throw exception;
                            }
                            break;

                        default:
                            goto Label_0237;
                        }
                        switch (segmentType)
                        {
                        case 13:
                            proxyQueueManager.AddMessage(rTSH);
                            break;

                        case 15:
                            proxyQueueManager.ReceiveNotification(rTSH);
                            break;
                        }
                        sessionByConvId.ReleaseReceivedTSH(rTSH);
                    }
                }
                goto Label_0040;
Label_0237:
                CommonServices.SetValidInserts();
                CommonServices.ArithInsert1   = 1;
                CommonServices.ArithInsert2   = (uint)segmentType;
                CommonServices.CommentInsert1 = "Incorrect Segment type received on multiplexing flow";
                base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                NmqiException exception2 = new NmqiException(base.env, -1, null, 2, 0x7d9, null);
                throw exception2;
Label_0285:
                if ((requestID % 2) != 0)
                {
                    if (sessionByConvId == null)
                    {
                        base.TrText(method, "Unknown Conversation and no existing Session could be found for it.");
                    }
                    else
                    {
                        sessionByConvId.DeliverExchangeReply(requestID, rTSH);
                    }
                    goto Label_0040;
                }
                NmqiException ex = new NmqiException(base.env, -1, null, 2, 0x893, null);
                CommonServices.SetValidInserts();
                CommonServices.ArithInsert1   = 1;
                CommonServices.CommentInsert1 = this.remoteConnection.NegotiatedChannel.ChannelName;
                CommonServices.CommentInsert2 = "Unknown request id flow on the multiplexed connection";
                base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                base.TrException(method, ex);
                throw ex;
Label_037D:
                mqsockact.ReadStruct(rTSH.TshBuffer, rTSH.Offset);
Label_0391:
                switch (mqsockact.Type)
                {
                case 1:
                case 4:
                case 5:
                case 6:
                    goto Label_0040;

                case 2:
                {
                    bool informQmgr = false;
                    if ((rTSH.ControlFlags1 & 1) != 0)
                    {
                        base.TrText(method, "rfpSAT_END_CONV request with rfpTCF_CONFIRM_REQUEST received");
                        informQmgr = true;
                    }
                    int       convId   = mqsockact.ConversationID;
                    MQSession session2 = this.remoteConnection.GetSessionByConvId(convId);
                    if (session2 != null)
                    {
                        this.remoteConnection.RemoveSession(session2.ConversationId, informQmgr);
                        NmqiException exception4 = new NmqiException(base.env, -1, null, 2, 0x7d9, null);
                        base.TrException(method, exception4);
                        session2.AsyncFailureNotify(exception4);
                    }
                    else if (convId == 1)
                    {
                        NmqiException exception5 = new NmqiException(base.env, -1, null, 2, 0x7d9, null);
                        base.TrException(method, exception5);
                        this.remoteConnection.AsyncFailureNotify(exception5, false);
                    }
                    else
                    {
                        base.TrData(method, 1, "hConn not recognised by connection,ConversationID ", BitConverter.GetBytes(mqsockact.ConversationID));
                    }
                    goto Label_057D;
                }

                case 3:
                {
                    NmqiException exception6 = new NmqiException(base.env, -1, null, 2, 0x89a, null);
                    base.TrException(method, exception6);
                    this.remoteConnection.AsyncFailureNotify(exception6, true);
                    goto Label_0040;
                }

                case 7:
                    this.remoteConnection.QmQuiescing();
                    goto Label_057D;

                case 9:
                    switch (mqsockact.Parm1)
                    {
                    case 1:
                        goto Label_0507;
                    }
                    goto Label_057D;

                default:
                    goto Label_057D;
                }
                this.remoteConnection.NotifyReconnect(false);
                goto Label_057D;
Label_0507:
                this.remoteConnection.NotifyReconnect(true);
                goto Label_057D;
Label_0515:
                if ((rTSH.ControlFlags1 & 8) != 0)
                {
                    this.remoteConnection.AnalyseErrorSegment(rTSH);
                    goto Label_057D;
                }
                if (rTSH.SegmentType != 9)
                {
                    goto Label_0570;
                }
                if (this.remoteConnection.FapLevel >= 10)
                {
                    if ((rTSH.ControlFlags1 & 1) != 0)
                    {
                        goto Label_0562;
                    }
                    goto Label_0040;
                }
                if ((rTSH.ControlFlags1 & 1) != 0)
                {
                    goto Label_0040;
                }
Label_0562:
                this.remoteConnection.SendHeartbeat(2);
                goto Label_057D;
Label_0570:
                if (rTSH.SegmentType == 11)
                {
                    goto Label_0040;
                }
Label_057D:
                this.remoteConnection.ReleaseReceivedTSH(rTSH);
                goto Label_0040;
            }
            catch (Exception exception8)
            {
                base.TrException(method, exception8, 1);
                NmqiException e = null;
                if (exception8 is NmqiException)
                {
                    e = (NmqiException)exception8;
                }
                else if (exception8 is MQException)
                {
                    e = new NmqiException(base.env, -1, null, (exception8 as MQException).CompCode, (exception8 as MQException).Reason, null);
                }
                else
                {
                    int compCode = 2;
                    int reason   = 0x893;
                    CommonServices.SetValidInserts();
                    CommonServices.ArithInsert1   = 1;
                    CommonServices.CommentInsert1 = this.remoteConnection.NegotiatedChannel.ChannelName.Trim();
                    CommonServices.CommentInsert2 = "System Exception generated on Receiver thread - " + exception8.Message;
                    CommonServices.CommentInsert3 = "Exception Stack - " + exception8.StackTrace;
                    base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                    e = new NmqiException(base.env, -1, null, compCode, reason, exception8);
                }
                try
                {
                    if (this.remoteConnection != null)
                    {
                        this.remoteConnection.AsyncFailureNotify(e, false);
                    }
                }
                catch (NmqiException exception10)
                {
                    base.TrException(method, exception10, 2);
                }
                catch (Exception exception11)
                {
                    base.TrException(method, exception11, 3);
                    CommonServices.SetValidInserts();
                    CommonServices.ArithInsert1   = 1;
                    CommonServices.CommentInsert1 = this.remoteConnection.NegotiatedChannel.ChannelName;
                    CommonServices.CommentInsert2 = "System Exception generated on AsyncFailureNotify - " + exception11.Message;
                    CommonServices.CommentInsert3 = "Exception Stack - " + exception11.StackTrace;
                    base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                }
                if (!this.disconnecting)
                {
                    try
                    {
                        if (this.remoteConnection != null)
                        {
                            this.remoteConnection.Disconnect();
                        }
                    }
                    catch (NmqiException exception12)
                    {
                        base.TrException(method, exception12, 4);
                    }
                    catch (Exception exception13)
                    {
                        base.TrException(method, exception13, 5);
                        CommonServices.SetValidInserts();
                        CommonServices.ArithInsert1   = 1;
                        CommonServices.CommentInsert1 = this.remoteConnection.NegotiatedChannel.ChannelName;
                        CommonServices.CommentInsert2 = "System Exception generated while Disconnecting - " + exception13.Message;
                        CommonServices.CommentInsert3 = "Exception Stack - " + exception13.StackTrace;
                        base.FFST("%Z% %W%  %I% %E% %U%", "%C%", method, 1, 0x20009213, 0);
                    }
                }
            }
            finally
            {
                if (this.commsBuffer != null)
                {
                    this.commsBuffer.Free();
                }
                base.TrExit(method);
            }
        }