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 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 MQTSH(int tshType, IMQCommsBuffer buffer) { base.TrConstructor("%Z% %W% %I% %E% %U%"); this.multiplexing = false; if (!this.multiplexing) { this.tsh = new structMQTSH(); this.tsh._Id = new byte[4]; this.tsh._LUWID = BLANK_LUWID; if (tshType == 2) { Buffer.BlockCopy(rfpTSH_C_ID, 0, this.tsh._Id, 0, 4); } else { this.tsh._Id = rfpTSH_ID; Buffer.BlockCopy(rfpTSH_ID, 0, this.tsh._Id, 0, 4); } } else { this.tshM = new structMQTSHM(); this.tshM._Id = new byte[4]; Buffer.BlockCopy(rfpTSH_M_ID, 0, this.tshM._Id, 0, 4); this.tshM._LUWID = BLANK_LUWID; } if (buffer != null) { this.parentBuffer = buffer; this.tshBuffer = this.parentBuffer.Buffer; this.Offset = this.parentBuffer.DataPosition; this.Length = 0; } }
internal MQTSH(bool IsMultiplexingEnabled, IMQCommsBuffer buffer) { base.TrConstructor("%Z% %W% %I% %E% %U%", new object[] { IsMultiplexingEnabled }); this.multiplexing = IsMultiplexingEnabled; if (!this.multiplexing) { this.tsh = new structMQTSH(); this.tsh._Id = new byte[4]; Buffer.BlockCopy(rfpTSH_ID, 0, this.tsh._Id, 0, 4); this.tsh._LUWID = BLANK_LUWID; } else { this.tshM = new structMQTSHM(); this.tshM._Id = new byte[4]; Buffer.BlockCopy(rfpTSH_M_ID, 0, this.tshM._Id, 0, 4); this.tshM._LUWID = BLANK_LUWID; } if (buffer != null) { this.parentBuffer = buffer; this.tshBuffer = this.parentBuffer.Buffer; this.Offset = this.parentBuffer.DataPosition; this.Length = 0; } }
internal void FreeBuffer(IMQCommsBuffer iBuffer) { uint method = 0x6c; this.TrEntry(method, new object[] { iBuffer }); try { MQCommsBufferImpl impl = (MQCommsBufferImpl)iBuffer; IDictionary <int, MQCommsBufferImpl> dictionary = null; impl.CheckPool(this); impl.IsValid(); switch (iBuffer.Capacity) { case 0x1400: if (this.bufferPool_5k.ContainsKey(impl.HashCode)) { dictionary = this.bufferPool_5k; } break; case 0x5000: if (this.bufferPool_20k.ContainsKey(impl.HashCode)) { dictionary = this.bufferPool_20k; } break; case 0x8000: if (this.bufferPool_32k.ContainsKey(impl.HashCode)) { dictionary = this.bufferPool_32k; } break; case 0x400: if (this.bufferPool_1k.ContainsKey(impl.HashCode)) { dictionary = this.bufferPool_1k; } break; case 0x800: if (this.bufferPool_2k.ContainsKey(impl.HashCode)) { dictionary = this.bufferPool_2k; } break; default: { MQManagedClientException ex = new MQManagedClientException("BufferId=" + impl.HashCode, 2, 0x893); base.TrException(method, ex); base.throwNewMQException(2, 0x893); break; } } if (dictionary != null) { lock (dictionary) { impl.UseCount--; if (impl.UseCount == 0) { base.TrText(method, "UseCount on this buffer is found to be 0,Reseting this buffer of capacity " + impl.Capacity); impl.Reset(false); } return; } } lock (this) { impl.UseCount--; if (impl.UseCount == 0) { impl.Dispose(false); impl = null; } } } finally { 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); }