From 50d3779d9b5e42fbc8193bcad010a3f94bd78732 Mon Sep 17 00:00:00 2001
From: Stefano Merotta <97297186+stefanomerotta@users.noreply.github.com>
Date: Tue, 21 May 2024 22:40:03 +0200
Subject: [PATCH] fix: Adds dispose call to LibDeflateBinding on process exits
(#1784)
---
Projects/Server/Compression/Deflate.cs | 16 ++++++++++++++--
Projects/Server/Server.csproj | 2 +-
Projects/UOContent/UOContent.csproj | 2 +-
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/Projects/Server/Compression/Deflate.cs b/Projects/Server/Compression/Deflate.cs
index 0442794c4..6810ef7d6 100644
--- a/Projects/Server/Compression/Deflate.cs
+++ b/Projects/Server/Compression/Deflate.cs
@@ -1,4 +1,4 @@
-/*************************************************************************
+/*************************************************************************
* ModernUO *
* Copyright 2019-2024 - ModernUO Development Team *
* Email: hi@modernuo.com *
@@ -13,11 +13,23 @@
* along with this program. If not, see . *
*************************************************************************/
+using System;
using System.IO.Compression;
namespace Server.Compression;
public static class Deflate
{
- public static LibDeflateBinding Standard { get; } = new();
+ public static LibDeflateBinding Standard { get; }
+
+ static Deflate()
+ {
+ Standard = new LibDeflateBinding();
+ AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
+ }
+
+ private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
+ {
+ Standard.Dispose();
+ }
}
diff --git a/Projects/Server/Server.csproj b/Projects/Server/Server.csproj
index acac1aea1..c68dda346 100755
--- a/Projects/Server/Server.csproj
+++ b/Projects/Server/Server.csproj
@@ -35,7 +35,7 @@
-
+
diff --git a/Projects/UOContent/UOContent.csproj b/Projects/UOContent/UOContent.csproj
index 4fce86e72..e53ef779c 100644
--- a/Projects/UOContent/UOContent.csproj
+++ b/Projects/UOContent/UOContent.csproj
@@ -34,7 +34,7 @@
false
-
+