소스 검색

Fix possible double dispose

Stepan Goremykin 1 년 전
부모
커밋
2360d28cbb
1개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 5 4
      Emby.Server.Implementations/Udp/UdpServer.cs

+ 5 - 4
Emby.Server.Implementations/Udp/UdpServer.cs

@@ -27,9 +27,9 @@ namespace Emby.Server.Implementations.Udp
 
         private readonly byte[] _receiveBuffer = new byte[8192];
 
-        private Socket _udpSocket;
-        private IPEndPoint _endpoint;
-        private bool _disposed = false;
+        private readonly Socket _udpSocket;
+        private readonly IPEndPoint _endpoint;
+        private bool _disposed;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="UdpServer" /> class.
@@ -125,7 +125,8 @@ namespace Emby.Server.Implementations.Udp
                 return;
             }
 
-            _udpSocket?.Dispose();
+            _udpSocket.Dispose();
+            _disposed = true;
         }
     }
 }