mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Fix crashing yet again
This commit is contained in:
parent
82ffc8dce5
commit
0935da50de
@ -147,8 +147,11 @@ namespace MCGalaxy.Network {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void SendCallback(object sender, SocketAsyncEventArgs e) {
|
static void SendCallback(object sender, SocketAsyncEventArgs e) {
|
||||||
TcpSocket s = (TcpSocket)e.UserToken;
|
Player p = null;
|
||||||
try {
|
try {
|
||||||
|
TcpSocket s = (TcpSocket)e.UserToken;
|
||||||
|
p = s.player;
|
||||||
|
|
||||||
// TODO: Need to check if all data was sent or not?
|
// TODO: Need to check if all data was sent or not?
|
||||||
int sent = e.BytesTransferred;
|
int sent = e.BytesTransferred;
|
||||||
lock (s.sendLock) {
|
lock (s.sendLock) {
|
||||||
@ -159,13 +162,15 @@ namespace MCGalaxy.Network {
|
|||||||
// If that happens, SendCallback isn't called so we need to send data here instead
|
// If that happens, SendCallback isn't called so we need to send data here instead
|
||||||
if (s.DoSendAsync(s.sendQueue.Dequeue())) return;
|
if (s.DoSendAsync(s.sendQueue.Dequeue())) return;
|
||||||
|
|
||||||
if (s.player.disconnected) s.sendQueue.Clear();
|
if (p.disconnected) s.sendQueue.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SocketException) {
|
} catch (SocketException) {
|
||||||
s.player.Disconnect();
|
if (p != null) p.Disconnect();
|
||||||
} catch (ObjectDisposedException) {
|
} catch (ObjectDisposedException) {
|
||||||
// Socket was already closed by another thread
|
// Socket was already closed by another thread
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.LogError(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user