Skip to content

Commit 7c3b134

Browse files
YoEighthayley-jean
authored andcommitted
Merge pull request #2834 from EventStore/fix-tcp-regression
Fix regression in TCP connection
1 parent 838c289 commit 7c3b134

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/EventStore.Transport.Tcp/TcpConnection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace EventStore.Transport.Tcp {
1313
public class TcpConnection : TcpConnectionBase, ITcpConnection {
14-
internal const int MaxSendPacketSize = 64 * 1024;
14+
internal const int MaxSendPacketSize = 65535 /*Max IP packet size*/ - 20 /*IP packet header size*/ - 32 /*TCP min header size*/;
1515

1616
internal static readonly BufferManager BufferManager =
1717
new BufferManager(TcpConfiguration.BufferChunksCount, TcpConfiguration.SocketBufferSize);
@@ -151,7 +151,7 @@ private void TrySend() {
151151
try {
152152
do {
153153
lock (_sendLock) {
154-
if (_isSending || _sendQueue.IsEmpty || _sendSocketArgs == null) return;
154+
if (_isSending || (_sendQueue.IsEmpty && _memoryStreamOffset >= _memoryStream.Length) || _sendSocketArgs == null) return;
155155
if (TcpConnectionMonitor.Default.IsSendBlocked()) return;
156156
_isSending = true;
157157
}

src/EventStore.Transport.Tcp/TcpConnectionSsl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ private void TrySend() {
345345
try {
346346
do {
347347
lock (_streamLock) {
348-
if (_isSending || _sendQueue.IsEmpty || _sslStream == null || !_isAuthenticated) return;
348+
if (_isSending || (_sendQueue.IsEmpty && _memoryStreamOffset >= _memoryStream.Length) || _sslStream == null || !_isAuthenticated) return;
349349
if (TcpConnectionMonitor.Default.IsSendBlocked()) return;
350350
_isSending = true;
351351
}

0 commit comments

Comments
 (0)