private void LockRcvExitForTSH(MQTSH rTSH) { uint method = 0x614; this.TrEntry(method, new object[] { rTSH }); try { while (this.rcvExitLockTSH != null) { try { this.rcvExitLock.Acquire(); continue; } catch (ThreadInterruptedException) { continue; } } this.rcvExitLockTSH = rTSH; } finally { base.TrExit(method); } }
internal MQTSH AllocateTshForPut(int size) { uint method = 0x624; this.TrEntry(method, new object[] { size }); try { if (this.tshSend == null) { this.tshSend = this.AllocateTSH(0x86, 0, true, size); base.TrText(method, "Allocated a fresh TSH for this call"); } else { if (size > this.tshSend.ParentBuffer.Capacity) { this.tshSend.ParentBuffer.Free(); this.tshSend.ParentBuffer = null; IMQCommsBuffer buffer = this.parentConnection.CommsBufferPool.AllocateBuffer(size); this.tshSend.ParentBuffer = buffer; base.TrText(method, "Allocated cached TSH with new buffer for this call"); } base.TrText(method, "Allocated a cached TSH for this call"); this.tshSend.SetTransLength(size); } } finally { base.TrExit(method, this.tshSend); } return(this.tshSend); }
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); }
internal void ReleaseOwnedTsh() { try { if (this.tshSend != null) { this.Connection.ReleaseReceivedTSH(this.tshSend); this.tshSend = null; } if (this.tshReqMsgs != null) { this.Connection.ReleaseReceivedTSH(this.tshReqMsgs); this.tshReqMsgs = null; } if (this.tshNotify != null) { this.Connection.ReleaseReceivedTSH(this.tshNotify); this.tshNotify = null; } } catch (Exception) { throw; } }
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); }
internal MQTSH AllocateTshForNotification(int size) { uint method = 0x626; this.TrEntry(method, new object[] { size }); try { if (this.tshNotify == null) { this.tshNotify = this.AllocateTSH(15, 1, true, size); base.TrText(method, "Allocated a fresh TSH for this call"); } else { if (size > this.tshNotify.ParentBuffer.Capacity) { this.tshNotify.ParentBuffer.Free(); this.tshNotify.ParentBuffer = null; IMQCommsBuffer buffer = this.parentConnection.CommsBufferPool.AllocateBuffer(size); this.tshNotify.ParentBuffer = buffer; base.TrText(method, "Allocated cached TSH with new buffer for this call"); } this.tshNotify.Offset = 0; this.tshNotify.SetRequestId(1); this.tshNotify.SetTransLength(size); base.TrText(method, "Allocated a cached TSH for this call"); } } finally { base.TrExit(method, this.tshNotify); } return(this.tshNotify); }
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); } }
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); }
internal void AddMessage(MQTSH tsh) { uint method = 0x607; this.TrEntry(method, new object[] { tsh }); try { MQASYNC_MESSAGE async = new MQASYNC_MESSAGE(); tsh.Offset = async.ReadStruct(tsh.TshBuffer, tsh.Offset); base.TrData(method, 0, "Hobj to be removed", BitConverter.GetBytes(async.asyncMsg.hObj)); MQProxyQueue queue = this.FindProxyQueue(async.asyncMsg.hObj); if (queue == null) { NmqiException exception = new NmqiException(base.env, -1, null, 2, 0x893, null); CommonServices.SetValidInserts(); CommonServices.ArithInsert1 = 1; CommonServices.CommentInsert1 = "Unable to find proxy queue for Hobj"; base.FFST("%Z% %W% %I% %E% %U%", "%C%", method, 1, 0x20009546, 0); throw exception; } queue.AddMessage(tsh, async); } finally { base.TrExit(method); } }
internal void ReceiveNotification(MQTSH tsh) { uint method = 0x608; this.TrEntry(method, new object[] { tsh }); try { MQNOTIFICATION notification = new MQNOTIFICATION(); notification.ReadStruct(tsh.TshBuffer, tsh.Offset); MQProxyQueue queue = this.FindProxyQueue(notification.notify.hObj); if (queue == null) { NmqiException exception = new NmqiException(base.env, -1, null, 2, 0x893, null); CommonServices.SetValidInserts(); CommonServices.ArithInsert1 = 1; CommonServices.CommentInsert1 = "Unable to find proxy queue for Hobj"; base.FFST("%Z% %W% %I% %E% %U%", "%C%", method, 1, 0x20009546, 0); throw exception; } queue.ReceiveNotification(notification); } finally { base.TrExit(method); } }
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 MQTSH ReceiveAsyncTSH() { uint method = 0x61a; this.TrEntry(method); MQTSH result = null; try { lock (this.asyncTshLock) { while ((this.asyncTshQueue.Count == 0) && (this.asyncFailure == null)) { try { long currentTimeInMs = NmqiTools.GetCurrentTimeInMs(); int millisecondsTimeout = 10; Monitor.Wait(this.asyncTshLock, millisecondsTimeout, true); if ((NmqiTools.GetCurrentTimeInMs() >= (currentTimeInMs + millisecondsTimeout)) && !this.Connection.IsConnected) { NmqiException ex = new NmqiException(base.env, 0x23fd, null, 2, 0x7d9, null); base.TrException(method, ex); throw ex; } continue; } catch (ThreadInterruptedException exception2) { base.TrException(method, exception2); continue; } } if (this.asyncFailure != null) { this.connectionBroken = true; this.hconn.RaiseEvent(0x7d9); NmqiException exception3 = new NmqiException(base.env, -1, null, 2, 0x7d9, this.asyncFailure); base.TrException(method, exception3); throw exception3; } } result = this.asyncTshQueue.Dequeue(); } finally { base.TrExit(method, result); } return(result); }
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 DeliverTSH(MQTSH rTSH) { uint method = 0x619; this.TrEntry(method, new object[] { rTSH }); try { lock (this.asyncTshLock) { this.asyncTshQueue.Enqueue(rTSH); Monitor.Pulse(this.asyncTshLock); } } finally { base.TrExit(method); } }
private void UnlockRcvExitForTSH(MQTSH rTSH) { uint method = 0x615; this.TrEntry(method, new object[] { rTSH }); try { this.rcvExitLock.Acquire(); if (this.rcvExitLockTSH == rTSH) { this.rcvExitLockTSH = null; } } finally { this.rcvExitLock.Release(); base.TrExit(method); } }
internal void DeliverExchangeReply(int requestId, MQTSH tsh) { uint method = 0x61e; this.TrEntry(method, new object[] { requestId, tsh }); try { tsh = this.ProcessReceivedData(tsh); lock (this.requestEntryMutex) { MQRequestEntry exchangeRequests = this.exchangeRequests; while ((exchangeRequests != null) && (exchangeRequests.RequestID != requestId)) { exchangeRequests = exchangeRequests.Next; } if (exchangeRequests == null) { CommonServices.SetValidInserts(); CommonServices.ArithInsert1 = (uint)requestId; CommonServices.ArithInsert2 = tsh.SegmentType; CommonServices.CommentInsert1 = "Unexpected flow received in DeliverExchangeReply"; CommonServices.CommentInsert2 = "Cached RequestEntry is null for given RequestId"; base.FFST("%Z% %W% %I% %E% %U%", "%C%", method, 1, 0x20009546, 0); NmqiException ex = new NmqiException(base.env, -1, null, 2, 0x893, null); base.TrException(method, ex); throw ex; } lock (exchangeRequests) { exchangeRequests.Reply = tsh; Monitor.Pulse(exchangeRequests); } } } finally { base.TrExit(method); } }
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); } }
private MQTSH ReceiveOneTSH() { uint method = 0x60f; this.TrEntry(method); int count = 0; int capacity = 0; MQTSH result = null; IMQCommsBuffer buffer = null; try { do { if ((this.commsBuffer != null) && ((count = this.commsBuffer.DataAvailable) >= 8)) { capacity = IPAddress.HostToNetworkOrder(BitConverter.ToInt32(this.commsBuffer.Buffer, this.commsBuffer.DataUsed + 4)); if (capacity <= count) { buffer = this.commsBufferPool.AllocateBuffer(capacity); try { Buffer.BlockCopy(this.commsBuffer.Buffer, this.commsBuffer.DataUsed, buffer.Buffer, 0, capacity); } catch (Exception exception) { base.TrException(method, exception); throw exception; } buffer.DataAvailable = capacity; buffer.DataUsed = 0; byte differentiator = buffer.Buffer[3]; result = new MQTSH(MQTSH.GetTshType(differentiator), buffer, true); result.Offset = result.ReadStruct(result.TshBuffer, 0); this.commsBuffer.DataUsed += capacity; this.commsBuffer.DataAvailable = count - capacity; base.TrData(method, 0, "Current TSH", 0, buffer.DataAvailable, buffer.Buffer); return(result); } } IMQCommsBuffer buffer2 = this.commsBufferPool.AllocateBuffer(this.remoteConnection.MaxTransmissionSize + 8); if (count != 0) { Buffer.BlockCopy(this.commsBuffer.Buffer, this.commsBuffer.DataUsed, buffer2.Buffer, 0, count); buffer2.DataAvailable = count; base.TrData(method, 0, "Following bytes are left from last read", 0, buffer2.DataAvailable, buffer2.Buffer); } if (this.commsBuffer != null) { this.commsBuffer.Free(); } this.commsBuffer = buffer2; }while (this.ReceiveBuffer() > 0); result = null; } finally { base.TrExit(method, result); } return(result); }
internal void StartConversation() { uint method = 0x621; this.TrEntry(method); MQSOCKACT mqsockact = new MQSOCKACT(); int translength = 0x1c + mqsockact.GetLength(); bool flag = CommonServices.TraceEnabled(); MQTSH rTSH = null; try { MQTSH tsh = this.AllocateTSH(2, 12, 0, true, translength); mqsockact.Type = 1; mqsockact.ConversationID = this.conversationId; mqsockact.RequestID = 0; mqsockact.Parm1 = Thread.CurrentThread.ManagedThreadId; mqsockact.Parm2 = this.traceIdentifier; tsh.Offset = tsh.WriteStruct(tsh.TshBuffer, tsh.Offset); tsh.Offset = mqsockact.WriteStruct(tsh.TshBuffer, tsh.Offset); tsh.Offset = 0; if (flag) { base.TrAPI(method, "__________"); base.TrAPI(method, "START CONVERSATION FLOW >>"); base.TrData(method, 0, "Conversation Id", BitConverter.GetBytes(this.ConversationId)); base.TrData(method, 0, "Buffer", tsh.Offset, tsh.Length, tsh.TshBuffer); base.TrAPIOutput(method, "CompCode"); base.TrAPIOutput(method, "Reason"); } try { try { this.parentConnection.RequestSendLock(); this.Connection.SendTSH(tsh); } finally { this.parentConnection.ReleaseSendLock(); } rTSH = this.ReceiveTSH(null); if ((rTSH.ControlFlags1 & 8) != 0) { NmqiException exception = new NmqiException(base.env, -1, null, 2, 0x80b, null); base.TrException(method, exception); throw exception; } switch (rTSH.SegmentType) { case 5: if ((rTSH.ControlFlags1 & 2) != 0) { NmqiException exception2 = new NmqiException(base.env, -1, null, 2, 0x8e1, null); base.TrException(method, exception2); throw exception2; } return; case 12: mqsockact.ReadStruct(rTSH.TshBuffer, rTSH.Offset); return; } CommonServices.SetValidInserts(); CommonServices.ArithInsert1 = (uint)this.conversationId; CommonServices.ArithInsert2 = (uint)mqsockact.Type; CommonServices.CommentInsert1 = "Start Conversation Request has been refused by QMgr"; CommonServices.CommentInsert2 = "Unknown SockACT from server for START_CONV"; base.FFST("%Z% %W% %I% %E% %U%", "%C%", method, 1, 0x8e1, 0); NmqiException ex = new NmqiException(base.env, -1, null, 2, 0x8e1, null); base.TrException(method, ex); throw ex; } finally { if (flag) { base.TrAPI(method, "__________"); base.TrAPI(method, "START CONVERSATION FLOW <<"); base.TrData(method, 0, "Name", BitConverter.GetBytes(this.ConversationId)); } this.ReleaseReceivedTSH(rTSH); } } finally { base.TrExit(method); } }
internal MQTSH ExchangeTSH(MQTSH requestTsh) { uint method = 0x622; this.TrEntry(method, new object[] { requestTsh }); MQTSH result = null; try { MQRequestEntry entry2; if (this.disconnected) { NmqiException ex = new NmqiException(base.env, -1, null, 2, 0x7d9, this.asyncFailure); base.TrException(method, ex); this.connectionBroken = true; this.hconn.RaiseEvent(0x7d9); } MQRequestEntry entry = this.AllocateRequestEntry(); requestTsh.SetRequestId(entry.RequestID); byte[] bytes = BitConverter.GetBytes(IPAddress.NetworkToHostOrder(entry.RequestID)); for (int i = 12; i < 0x10; i++) { requestTsh.TshBuffer[i] = bytes[i - 12]; } requestTsh.ControlFlags1 = (byte)(requestTsh.ControlFlags1 | 1); this.SendData(requestTsh.TshBuffer, 0, requestTsh.Length, requestTsh.SegmentType, 1); Monitor.Enter(entry2 = entry); try { while (entry.Reply == null) { Monitor.Wait(entry, this.rmtReqEntMaxPollTime, true); if ((this.asyncFailure != null) || !this.Connection.IsConnected) { NmqiException exception2 = new NmqiException(base.env, -1, null, 2, 0x7d9, this.asyncFailure); base.TrException(method, exception2); throw exception2; } } } catch (ThreadInterruptedException exception3) { string str = "Interrupted while waiting for exchange reply"; CommonServices.SetValidInserts(); CommonServices.ArithInsert1 = (uint)this.conversationId; CommonServices.ArithInsert2 = (uint)entry.RequestID; CommonServices.CommentInsert1 = str; base.FFST("%Z% %W% %I% %E% %U%", "%C%", method, 1, 0x8e1, 0); NmqiException exception4 = new NmqiException(base.env, -1, null, 2, 0x893, exception3); base.TrException(method, exception4); throw exception4; } finally { Monitor.Exit(entry2); } result = entry.Reply; this.ReleaseRequestEntry(entry); } finally { base.TrExit(method, result); } return(result); }