internal MQManagedClientException ErrorException(string ChannelName) { uint method = 0x83; this.TrEntry(method, new object[] { ChannelName }); MQManagedClientException result = null; try { result = ErrorException(this.erd.ReturnCode, this.erd.ErrorData, ChannelName); } finally { base.TrExit(method, result); } return(result); }
public MQChannelDefinition GetChannelDefinition(string qmname, ref int pos) { uint method = 0x2f; this.TrEntry(method, new object[] { qmname, (int)pos }); MQChannelDefinition definition = null; try { if (this.tableStream == null) { this.GetStream(); } else { this.tableStream.Seek(0L, SeekOrigin.Begin); } if (this.Readuint(this.tableStream) != 0x52514d41) { throw new IOException(); } qmname = qmname.PadRight(0x30); definition = this.FindChannel(this.tableStream, qmname, ref pos); } catch (MQException) { throw; } catch (IOException exception) { base.TrException(method, exception, 1); MQManagedClientException exception2 = new MQManagedClientException(0x20009555, 0, 0, this.mqfile, null, null, 2, 0x8a0); throw exception2; } finally { base.TrExit(method); } return(definition); }
private void GetStream() { uint method = 0x30; this.TrEntry(method); string mqfile = this.mqfile; try { if (this.mqfile.IndexOf("://") == -1) { mqfile = "file://" + this.mqfile; } base.TrText("Channel table URI: '" + mqfile + "'"); WebResponse response = WebRequest.Create(mqfile).GetResponse(); if (mqfile.ToLower().StartsWith("http://")) { using (response) { byte[] buffer; int num2 = 0; int index = 0; BinaryReader reader = new BinaryReader(response.GetResponseStream()); byte[] buffer2 = new byte[0x8000]; while ((num2 = reader.Read(buffer2, index, 0x8000)) != 0) { if ((index == 0) && (BitConverter.ToUInt32(buffer2, 0) != 0x52514d41)) { throw new IOException(); } index += num2; buffer = new byte[index + 0x8000]; Buffer.BlockCopy(buffer2, 0, buffer, 0, index); buffer2 = buffer; } buffer = new byte[index]; Buffer.BlockCopy(buffer2, 0, buffer, 0, index); this.tableStream = new MemoryStream(buffer); return; } } this.tableStream = response.GetResponseStream(); } catch (MQException) { throw; } catch (WebException exception) { base.TrException(method, exception, 1); MQManagedClientException exception2 = new MQManagedClientException(0x20009518, 0, 0, this.mqfile, null, null, 2, 0x80a); throw exception2; } catch (UriFormatException exception3) { base.TrException(method, exception3, 2); MQManagedClientException exception4 = new MQManagedClientException(0x20009518, 0, 0, mqfile, null, null, 2, 0x80a); throw exception4; } catch (IOException exception5) { base.TrException(method, exception5, 3); MQManagedClientException exception6 = new MQManagedClientException(0x20009555, 0, 0, this.mqfile, null, null, 2, 0x80a); throw exception6; } finally { base.TrExit(method); } }
internal IMQCommsBuffer AllocateBuffer(int capacity) { uint method = 0x6d; this.TrEntry(method, new object[] { capacity }); MQCommsBufferImpl impl = null; try { int num2 = 0; IDictionary <int, MQCommsBufferImpl> dictionary = null; if (capacity <= 0x400) { num2 = 0x400; } else if (capacity <= 0x800) { num2 = 0x800; } else if (capacity <= 0x1400) { num2 = 0x1400; } else if (capacity <= 0x5000) { num2 = 0x5000; } else { num2 = 0x8000; } switch (num2) { case 0x1400: dictionary = this.bufferPool_5k; break; case 0x5000: dictionary = this.bufferPool_20k; break; case 0x8000: dictionary = this.bufferPool_32k; break; case 0x400: dictionary = this.bufferPool_1k; break; case 0x800: dictionary = this.bufferPool_2k; break; default: { MQManagedClientException ex = new MQManagedClientException(string.Concat(new object[] { "AllotedSize=", num2, ", AskedSize=", capacity }), 2, 0x893); base.TrException(method, ex); base.throwNewMQException(2, 0x893); break; } } lock (dictionary) { foreach (MQCommsBufferImpl impl2 in dictionary.Values) { if ((impl2.Capacity >= capacity) && !impl2.InUse) { impl = impl2; base.TrText(method, string.Concat(new object[] { "Reusing buffer of capacity=", impl.Capacity, "BufferHashcode: ", impl.HashCode })); break; } } if (impl == null) { impl = new MQCommsBufferImpl(this, num2, this.random.Next()); base.TrText(method, string.Concat(new object[] { "Alloted a new Buffer of capacity=", num2, "Buffer hashcode =", impl.HashCode })); if (this.currentAllocation < 0x1800000) { try { base.TrText(method, "Current Allocation size = " + ((int)this.currentAllocation)); this.currentAllocation += num2; dictionary.Add(impl.HashCode, impl); goto Label_0283; } catch (Exception exception2) { base.TrException(method, exception2); throw exception2; } } base.TrText(method, "Threshold buffer allocations reached, now no more new buffers to pool"); } Label_0283: impl.Reset(true); impl.DataAvailable = 0; impl.DataUsed = 0; } } finally { base.TrExit(method); } return(impl); }
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); } }