Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Unhinged/Engine/UnhingedEngine.Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ private static unsafe void WorkerLoop(Worker W)
}

/// <summary>
/// Parses as many complete HTTP requests as are present in the receive buffer.
/// Parses as many complete HTTP requests as are present in the receiving buffer.
/// For each complete request:
/// - extracts the route
/// - invokes the configured request handler to stage a response into WriteBuffer
/// The receive window is compacted when partial data remains.
/// The receiving window is compacted when partial data remains.
/// Returns true if any response data was staged and should be flushed.
/// </summary>
private static async ValueTask TryParseRequests(
Expand Down Expand Up @@ -275,6 +275,7 @@ private static async ValueTask TryParseRequests(
await _sRequestHandler(connection);

// Clear pooled dictionaries (query parameters + headers)
// Currently Clear won't reset the buffers, if it changes, adapt here too
connection.Clear();

// Mark that there is data to flush (a request was fully processed)
Expand Down
20 changes: 17 additions & 3 deletions Unhinged/Engine/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,23 @@ public bool IsUsed(int index)

public void Dispose()
{
try { if (Ep >= 0) close(Ep); } catch { /* log */ }
try { if (NotifyEfd >= 0) close(NotifyEfd); } catch { /* log */ }
if (EventsBuf != IntPtr.Zero) Marshal.FreeHGlobal(EventsBuf);
try
{
if (Ep >= 0)
close(Ep);

} catch { /* log */ }

try
{
if (NotifyEfd >= 0)
close(NotifyEfd);

} catch { /* log */ }

if (EventsBuf != IntPtr.Zero)
Marshal.FreeHGlobal(EventsBuf);

// Optionally GC.SuppressFinalize(this);
}
}
Loading