private static void CloseReason0(params IChannelHandler[] handlers) { EmbeddedChannel ch = new EmbeddedChannel( new HttpObjectAggregator(42)); ch.Pipeline.AddLast(handlers); Upgrade0(ch, new WebSocketServerHandshaker13("ws://example.com/chat", "chat", WebSocketDecoderConfig.NewBuilder().MaxFramePayloadLength(4).CloseOnProtocolViolation(true).Build())); ch.WriteOutbound(new BinaryWebSocketFrame(Unpooled.WrappedBuffer(new byte[8]))); var buffer = ch.ReadOutbound <IByteBuffer>(); try { ch.WriteInbound(buffer); Assert.False(true); } catch (CorruptedWebSocketFrameException) { // expected } IReferenceCounted closeMessage = ch.ReadOutbound <IReferenceCounted>(); Assert.True(closeMessage is IByteBuffer); closeMessage.Release(); Assert.False(ch.Finish()); }
public static void SafeRelease(this IReferenceCounted msg, int decrement) { try { msg?.Release(decrement); } catch (Exception ex) { Logger.Warn("Failed to release a message: {} (decrement: {})", msg, decrement, ex); } }
public static void SafeRelease(this IReferenceCounted msg) { try { msg?.Release(); } catch (Exception ex) { Logger.Warn("Failed to release a message: {}", msg, ex); } }
public static void SafeRelease(this IReferenceCounted msg, int decrement) { try { _ = msg?.Release(decrement); } catch (Exception ex) { Logger.FailedToReleaseAMessage(msg, decrement, ex); } }
public static void SafeRelease(this IReferenceCounted msg) { try { _ = (msg?.Release()); } catch (Exception ex) { Logger.FailedToReleaseAMessage(msg, ex); } }
public static void SafeRelease(this IReferenceCounted msg, int decrement) { try { msg?.Release(decrement); } catch (Exception ex) { Debug.Log("Failed to release a message: " + msg + " decrement=" + decrement + " -> " + ex); } }
public static void SafeRelease(this IReferenceCounted msg) { try { msg?.Release(); } catch (Exception ex) { if (Logger.IsWarnEnabled) { Logger.Warn(msg, ex); } } }
IByteBuffer CreateNewDirectBuffer(IReferenceCounted holder, IByteBuffer buffer) { Contract.Requires(holder != null); Contract.Requires(buffer != null); int readableBytes = buffer.ReadableBytes; if (readableBytes == 0) { holder.SafeRelease(); return(Unpooled.Empty); } // Composite IByteBuffer data = this.Allocator.Buffer(readableBytes); data.WriteBytes(buffer, buffer.ReaderIndex, readableBytes); holder.SafeRelease(); return(data); }
static string FormatReleaseString(IReferenceCounted referenceCounted, int decrement) => $"{referenceCounted.GetType().Name}.Release({decrement.ToString()}) refCnt: {referenceCounted.ReferenceCount.ToString()}";
public PooledNonRetainedSlicedByteBuffer(IReferenceCounted referenceCountDelegate, AbstractByteBuffer buffer, int index, int length) : base(buffer, index, length) { this.referenceCountDelegate = referenceCountDelegate; }
internal PooledNonRetainedDuplicateByteBuffer(IReferenceCounted referenceCountDelegate, AbstractByteBuffer buffer) : base(buffer) { this.referenceCountDelegate = referenceCountDelegate; }
internal static string FormatReleaseString(IReferenceCounted referenceCounted, int decrement) => $"{referenceCounted.GetType().Name}.Release({decrement.ToString(CultureInfo.InvariantCulture)}) refCnt: {referenceCounted.ReferenceCount.ToString(CultureInfo.InvariantCulture)}";
public static void ReleasedObject(this IInternalLogger logger, IReferenceCounted referenceCounted, int decrement) { logger.Debug("Released: {}", ReferenceCountUtil.FormatReleaseString(referenceCounted, decrement)); }
public static void NonZeroRefCnt(this IInternalLogger logger, IReferenceCounted referenceCounted, int decrement) { logger.Warn("Non-zero refCnt: {}", ReferenceCountUtil.FormatReleaseString(referenceCounted, decrement)); }
public static void FailedToReleaseAObject(this IInternalLogger logger, IReferenceCounted referenceCounted, Exception ex) { logger.Warn("Failed to release an object: {}", referenceCounted, ex); }
static string FormatReleaseString(IReferenceCounted referenceCounted, int decrement) { return(referenceCounted.GetType().Name + ".Release(" + decrement.ToString() + ") refCnt: " + referenceCounted.ReferenceCount.ToString()); }