Skip to content

Commit

Permalink
Merge branch 'main' into handle_dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
tmds committed Jun 19, 2024
2 parents 76d5c43 + b447942 commit 7561068
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/Tmds.DBus.Protocol/MessageBuffer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Tmds.DBus.Protocol;

public sealed class MessageBuffer : IDisposable
public sealed class MessageBuffer
{
private readonly MessageBufferPool _messagePool;

Expand All @@ -25,10 +25,12 @@ internal void Init(uint serial, MessageFlags flags, UnixFdCollection? handles)
Handles = handles;
}

public void Dispose() => ReturnToPool();

public void RefHandles() => Handles?.RefHandles();
internal void RefHandles() => Handles?.RefHandles();

// Users should create a message using a MessageWriter
// and then hand it to the Connection class which is responsible for calling this method.
// A library user is never considered the owner of this message and therefore
// we don't provide a public method for a user to Dispose/ReturnToPool.
internal void ReturnToPool()
{
_data.Reset();
Expand Down
2 changes: 1 addition & 1 deletion src/Tmds.DBus.Protocol/MethodContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Reply(MessageBuffer message)
{
if (ReplySent || NoReplyExpected)
{
message.Dispose();
message.ReturnToPool();
if (ReplySent)
{
throw new InvalidOperationException("A reply has already been sent.");
Expand Down
4 changes: 2 additions & 2 deletions src/Tmds.DBus.Protocol/Variant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Variant(ulong value)
_l = (long)value;
_o = UInt64Type;
}
internal unsafe Variant(double value)
public unsafe Variant(double value)
{
_l = *(long*)&value;
_o = DoubleType;
Expand Down Expand Up @@ -448,4 +448,4 @@ internal unsafe void WriteTo(ref MessageWriter writer)
throw new InvalidOperationException($"Cannot write Variant of type {Type}.");
}
}
}
}

0 comments on commit 7561068

Please sign in to comment.