From 00b3ac59f4a7969d2f3a620685e19c65f8434e79 Mon Sep 17 00:00:00 2001 From: Enerdy Date: Tue, 13 Dec 2016 22:59:50 +0000 Subject: [PATCH] Catch and log on linux socket read --- TShockAPI/Sockets/LinuxTcpSocket.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/TShockAPI/Sockets/LinuxTcpSocket.cs b/TShockAPI/Sockets/LinuxTcpSocket.cs index 72e8e9d3..98df1674 100644 --- a/TShockAPI/Sockets/LinuxTcpSocket.cs +++ b/TShockAPI/Sockets/LinuxTcpSocket.cs @@ -73,7 +73,20 @@ namespace TShockAPI.Sockets private void ReadCallback(IAsyncResult result) { Tuple tuple = (Tuple)result.AsyncState; - tuple.Item1(tuple.Item2, this._connection.GetStream().EndRead(result)); + + try + { + tuple.Item1(tuple.Item2, this._connection.GetStream().EndRead(result)); + } + catch (InvalidOperationException) + { + // This is common behaviour during client disconnects + ((ISocket)this).Close(); + } + catch (Exception ex) + { + TShock.Log.Error(ex.ToString()); + } } private void SendCallback(IAsyncResult result)