mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
fix sending stop working after a while with .NET core
This commit is contained in:
parent
51ac5a1576
commit
7a3e1ba385
@ -786,7 +786,7 @@ namespace MCGalaxy.SQL {
|
||||
}
|
||||
|
||||
public float GetFloat(int i) { return (float)GetDouble(i); }
|
||||
public short GetInt16(int i) { return (short)GetInt16(i); }
|
||||
public short GetInt16(int i) { return (short)GetInt32(i); }
|
||||
public string GetName(int i) { return stmt.ColumnName(i); }
|
||||
|
||||
public int GetInt32(int i) {
|
||||
|
@ -177,7 +177,7 @@ namespace MCGalaxy.Network {
|
||||
if (sendInProgress) {
|
||||
sendQueue.Enqueue(buffer);
|
||||
} else {
|
||||
if (!DoSendAsync(buffer)) sendInProgress = false;
|
||||
sendInProgress = TrySendAsync(buffer);
|
||||
}
|
||||
}
|
||||
} catch (SocketException) {
|
||||
@ -190,8 +190,7 @@ namespace MCGalaxy.Network {
|
||||
// TODO: do this seprately
|
||||
public override void SendLowPriority(byte[] buffer) { Send(buffer, false); }
|
||||
|
||||
bool DoSendAsync(byte[] buffer) {
|
||||
sendInProgress = true;
|
||||
bool TrySendAsync(byte[] buffer) {
|
||||
// BlockCopy has some overhead, not worth it for very small data
|
||||
if (buffer.Length <= 16) {
|
||||
for (int i = 0; i < buffer.Length; i++) {
|
||||
@ -217,8 +216,9 @@ namespace MCGalaxy.Network {
|
||||
while (s.sendQueue.Count > 0) {
|
||||
// DoSendAsync returns false if SendAsync completed sync
|
||||
// If that happens, SendCallback isn't called so we need to send data here instead
|
||||
if (s.DoSendAsync(s.sendQueue.Dequeue())) return;
|
||||
|
||||
s.sendInProgress = s.TrySendAsync(s.sendQueue.Dequeue());
|
||||
|
||||
if (s.sendInProgress) return;
|
||||
if (s.Disconnected) s.sendQueue.Clear();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user