Ejemplo n.º 1
0
        internal MQTSH ReceiveTSH(MQTSH partialTSH)
        {
            uint method = 0x61d;

            this.TrEntry(method, new object[] { partialTSH });
            MQTSH tsh = null;

            try
            {
                MQFAPConnection connection = this.Connection;
                if (connection.IsMultiplexingEnabled)
                {
                    tsh = this.ReceiveAsyncTSH();
                }
                else
                {
                    tsh = connection.ReceiveTSH(partialTSH);
                }
                this.ProcessReceivedData(tsh);
            }
            finally
            {
                base.TrExit(method, tsh);
            }
            return(tsh);
        }
        private MQSession GetSessionFromNewConnection(MQChannelDefinition mqcd, MQSSLConfigOptions sslConfigOptions, MQConnectionSecurityParameters mqcsp, MQFAP fap, string qMgrName, int connectOptions, int maxFapLevel)
        {
            uint method = 0x599;

            this.TrEntry(method, new object[] { mqcsp, fap, qMgrName, connectOptions, maxFapLevel });
            MQFAPConnection connection = null;
            MQSession       session    = null;

            try
            {
                this.connectionsLock.Acquire();
                connection = this.CreateAndConnectConnection(mqcd, sslConfigOptions, mqcsp, fap, qMgrName, connectOptions, maxFapLevel);
                session    = connection.AssignSession();
                session.ParentConnection = connection;
                session.InitSendReceiveExits(true);
                if (connection.GetFreeConversations() > 0)
                {
                    this.AddConnection(connection);
                }
            }
            finally
            {
                this.connectionsLock.Release();
                base.TrExit(method);
            }
            return(session);
        }
Ejemplo n.º 3
0
        internal void ReleaseReceivedTSH(MQTSH rTSH)
        {
            uint method = 0x623;

            this.TrEntry(method, new object[] { rTSH });
            try
            {
                MQFAPConnection connection = null;
                try
                {
                    connection = this.Connection;
                }
                finally
                {
                    this.UnlockRcvExitForTSH(rTSH);
                }
                if (connection != null)
                {
                    connection.ReleaseReceivedTSH(rTSH);
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
Ejemplo n.º 4
0
        internal MQTSH AllocateTSH(int tshType, byte segmentType, int requestId, bool initialize, int translength)
        {
            uint method = 0x618;

            this.TrEntry(method, new object[] { tshType, segmentType, requestId, initialize, translength });
            MQTSH tshHeaderP = null;

            try
            {
                MQFAPConnection connection = this.Connection;
                if (this.parentConnection.IsMultiplexingEnabled)
                {
                    tshHeaderP = connection.AllocateTSH(tshType, segmentType, tshHeaderP, translength);
                    tshHeaderP.SetConversationId(this.conversationId);
                    tshHeaderP.SetRequestId(requestId);
                    return(tshHeaderP);
                }
                tshHeaderP = connection.AllocateTSH(0, segmentType, tshHeaderP, translength);
            }
            finally
            {
                base.TrExit(method, tshHeaderP);
            }
            return(tshHeaderP);
        }
Ejemplo n.º 5
0
        internal MQTSH AllocateTSH(int segmentType, int requestId, MQTSH tshP)
        {
            uint method = 0x616;

            this.TrEntry(method, new object[] { segmentType, requestId, tshP });
            MQTSH tshHeaderP = tshP;

            try
            {
                MQFAPConnection connection = this.Connection;
                if (this.parentConnection.IsMultiplexingEnabled)
                {
                    tshHeaderP = connection.AllocateTSH(1, segmentType, tshHeaderP);
                    tshHeaderP.SetConversationId(this.conversationId);
                    tshHeaderP.SetRequestId(requestId);
                    return(tshHeaderP);
                }
                tshHeaderP = connection.AllocateTSH(0, segmentType, tshHeaderP);
            }
            finally
            {
                base.TrExit(method, tshHeaderP);
            }
            return(tshHeaderP);
        }
        private MQSession GetSessionFromEligibleConnection()
        {
            uint method = 0x59b;

            this.TrEntry(method);
            MQSession session = null;
            bool      flag    = true;

            try
            {
                this.connectionsLock.Acquire();
                if (this.eligibleConnections.Count != 0)
                {
                    MQFAPConnection connection = (MQFAPConnection)this.eligibleConnections[0];
                    if (connection.GetFreeConversations() == 1)
                    {
                        this.RemoveConnection(connection);
                    }
                    if (connection.IsReconnectRequested)
                    {
                        this.RemoveConnection(connection);
                        base.TrExit(method, null, 1);
                        return(null);
                    }
                    if (!connection.IsConnected)
                    {
                        this.RemoveConnection(connection);
                        base.TrExit(method, null, 2);
                        return(null);
                    }
                    session = connection.AssignSession();
                    session.InitSendReceiveExits(false);
                    session.StartConversation();
                    flag = false;
                }
                else if (this.connectingConnections > 0)
                {
                    try
                    {
                        flag = false;
                        this.connectionsLock.Wait();
                    }
                    catch (ThreadInterruptedException exception)
                    {
                        base.TrException(method, exception);
                    }
                }
                if (flag)
                {
                    Thread.Sleep(0);
                }
            }
            finally
            {
                this.connectionsLock.Release();
                base.TrExit(method, 3);
            }
            return(session);
        }
Ejemplo n.º 7
0
        internal MQTSH ProcessReceivedData(MQTSH tsh)
        {
            uint method = 0x613;

            this.TrEntry(method, new object[] { tsh });
            try
            {
                MQFAPConnection connection = this.Connection;
                if ((!this.exitsActive || (connection.NegotiatedChannel.ReceiveExitsDefined == 0)) || (this.exits == null))
                {
                    return(tsh);
                }
                try
                {
                    try
                    {
                        byte[] tshBuffer = tsh.TshBuffer;
                        int    offset    = 0;
                        int    length    = tsh.Length;
                        int    maxlength = length;
                        this.LockRcvExitForTSH(tsh);
                        byte[] buf = this.exits.ProcessReceiveExits(ref tshBuffer, ref offset, ref length, ref maxlength);
                        base.TrData(method, 2, "Data after ReceiveExit call", 0, length, buf);
                        tsh.Offset    = tsh.ReadStruct(buf, offset);
                        tsh.TshBuffer = buf;
                        tsh.Length    = length;
                    }
                    catch (NmqiException exception)
                    {
                        base.TrException(method, exception);
                        if ((exception.Reason == 0x80b) || (exception.Reason == 0x80f))
                        {
                            this.Disconnect();
                        }
                        return(tsh);
                    }
                    catch (MQException exception2)
                    {
                        base.TrException(method, exception2);
                        if ((exception2.Reason == 0x80b) || (exception2.Reason == 0x80f))
                        {
                            this.Disconnect();
                        }
                        return(tsh);
                    }
                    return(tsh);
                }
                finally
                {
                    this.UnlockRcvExitForTSH(tsh);
                }
            }
            finally
            {
                base.TrExit(method);
            }
            return(tsh);
        }
        internal void RegisterConnection(MQFAPConnection connection)
        {
            uint method = 0x597;

            this.TrEntry(method, new object[] { connection });
            if (!this.eligibleConnections.Contains(connection))
            {
                base.TrText(method, "ConnectionId of current connection being added - " + connection.GetHashCode());
                this.eligibleConnections.Add(connection);
            }
            base.TrExit(method);
        }
Ejemplo n.º 9
0
        internal MQSession(NmqiEnvironment env, MQFAPConnection connection) : base(env)
        {
            this.rcvExitLockCheck     = new Lock();
            this.rcvExitLock          = new Lock();
            this.asyncTshLock         = new Lock();
            this.asyncTshQueue        = new Queue <MQTSH>();
            this.rmid                 = -1;
            this.requestEntryMutex    = new Lock();
            this.rmtReqEntMaxPollTime = 0x7d0;
            this.sessionMultiplexed   = -1;
            base.TrConstructor("%Z% %W% %I% %E% %U%", new object[] { env, connection });
            MQClientCfg cfg = env.Cfg;

            this.parentConnection = connection;
        }
Ejemplo n.º 10
0
        internal void SendTSH(MQTSH tsh)
        {
            uint method = 0x61c;

            this.TrEntry(method, new object[] { tsh });
            MQFAPConnection connection = this.Connection;

            try
            {
                if (this.IsEndRequested || (this.asyncFailure != null))
                {
                    NmqiException exception = new NmqiException(base.env, -1, null, 2, 0x7d9, this.asyncFailure);
                    throw exception;
                }
                byte[] tshBuffer = tsh.TshBuffer;
                byte[] buffer    = null;
                int    offset    = tsh.Offset;
                int    length    = tsh.Length;
                int    maxlength = length;
                base.TrData(method, 0, "Data before Processed by SendExits(if no exits are defined, this is final)", tshBuffer);
                if ((this.exitsActive && (this.exits != null)) && this.exits.sendExitDefined)
                {
                    buffer = this.exits.ProcessSendExits(ref tshBuffer, ref offset, ref length, ref maxlength);
                    base.TrData(method, 0, "Data after processed by SendExits", tshBuffer);
                }
                else
                {
                    buffer = tshBuffer;
                }
                try
                {
                    this.parentConnection.RequestSendLock();
                    connection.Send(buffer, offset, length, tsh.SegmentType, tsh.TSHType);
                }
                finally
                {
                    this.parentConnection.ReleaseSendLock();
                }
            }
            finally
            {
                tsh.ParentBuffer.Free();
                tsh.ParentBuffer = null;
                base.TrExit(method);
            }
        }
        internal void AddConnection(MQFAPConnection connection)
        {
            uint method = 0x59e;

            this.TrEntry(method, new object[] { connection });
            try
            {
                this.connectionsLock.AssertOnCurrentThreadHoldsLock();
                if (!this.eligibleConnections.Contains(connection))
                {
                    this.eligibleConnections.Add(connection);
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
        internal void RemoveConnection(MQFAPConnection connection)
        {
            uint method = 0x59d;

            this.TrEntry(method, new object[] { connection });
            try
            {
                this.connectionsLock.AssertOnCurrentThreadHoldsLock();
                this.eligibleConnections.Remove(connection);
                if (this.eligibleConnections.Count == 0)
                {
                    this.connectionPool.RemoveSpec(this);
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
Ejemplo n.º 13
0
        internal void SendData(byte[] bytes, int offset, int length, byte segmentType, int tshType)
        {
            uint method = 0xb1;

            this.TrEntry(method, new object[] { bytes, offset, length });
            MQFAPConnection connection = this.Connection;

            byte[] buffer    = null;
            int    maxlength = length;

            try
            {
                if (this.IsEndRequested || (this.asyncFailure != null))
                {
                    NmqiException exception = new NmqiException(base.env, -1, null, 2, 0x7d9, this.asyncFailure);
                    throw exception;
                }
                base.TrData(method, 0, "Data before Processed by SendExits(if no exits are defined, this is final)", bytes);
                if ((this.exitsActive && (this.exits != null)) && this.exits.sendExitDefined)
                {
                    buffer = this.exits.ProcessSendExits(ref bytes, ref offset, ref length, ref maxlength);
                    base.TrData(method, 0, "Data after processed by SendExits", bytes);
                }
                else
                {
                    buffer = bytes;
                }
                try
                {
                    this.parentConnection.RequestSendLock();
                    connection.Send(buffer, offset, length, segmentType, tshType);
                    buffer = null;
                }
                finally
                {
                    this.parentConnection.ReleaseSendLock();
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
Ejemplo n.º 14
0
        internal void InitSendReceiveExits(bool firstConv)
        {
            uint method = 0x628;

            this.TrEntry(method, new object[] { firstConv });
            try
            {
                MQFAPConnection     conn              = this.Connection;
                MQChannelDefinition clientConn        = conn.ClientConn;
                MQChannelDefinition negotiatedChannel = conn.NegotiatedChannel;
                if (this.exits == null)
                {
                    this.exits = new MQChannelExitHandler(conn);
                }
                if ((clientConn.SendExit != null) && (clientConn.SendExit != ""))
                {
                    this.exits.LoadExits(13);
                    this.exits.InitializeExits(13, firstConv);
                    clientConn.SendExitsDefined        = 1;
                    negotiatedChannel.SendExitsDefined = 1;
                    this.exitsActive = true;
                }
                if ((clientConn.ReceiveExit != null) && (clientConn.ReceiveExit != ""))
                {
                    this.exits.LoadExits(14);
                    this.exits.InitializeExits(14, firstConv);
                    clientConn.ReceiveExitsDefined        = 1;
                    negotiatedChannel.ReceiveExitsDefined = 1;
                    this.exitsActive = true;
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
Ejemplo n.º 15
0
 internal MQChannelExitHandler(MQFAPConnection conn)
 {
     base.TrConstructor("%Z% %W%  %I% %E% %U%", new object[] { conn });
     this.fapConnection = conn;
     this.cd            = this.fapConnection.NegotiatedChannel;
 }
Ejemplo n.º 16
0
 public MQRcvThread(NmqiEnvironment nmqiEnv, MQFAPConnection remoteConn) : base(nmqiEnv)
 {
     base.TrConstructor("%Z% %W%  %I% %E% %U%", new object[] { nmqiEnv, remoteConn });
     this.remoteConnection = remoteConn;
     this.commsBufferPool  = this.remoteConnection.CommsBufferPool;
 }