summaryrefslogtreecommitdiff
path: root/qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs
diff options
context:
space:
mode:
authorAidan Skinner <aidan@apache.org>2008-05-07 14:09:16 +0000
committerAidan Skinner <aidan@apache.org>2008-05-07 14:09:16 +0000
commit0fb8d3ab90269c9f4df552fd0b03f0c557cfbd97 (patch)
tree9ea486339735ffea63ba801b7d13bbd6d28780a5 /qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs
parent328d705d29ce55bd98ce87c42b0df608fde7c9ae (diff)
downloadqpid-python-0fb8d3ab90269c9f4df552fd0b03f0c557cfbd97.tar.gz
Merged revisions 653420-654109 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.x ........ r653447 | aidan | 2008-05-05 13:26:29 +0100 (Mon, 05 May 2008) | 1 line Check if consumer is closed and dont reclose it ........ r653451 | aidan | 2008-05-05 13:29:15 +0100 (Mon, 05 May 2008) | 1 line QPID-1022 Use synchronous writes to fix race conditions ........ r653452 | aidan | 2008-05-05 13:30:45 +0100 (Mon, 05 May 2008) | 1 line QPID-1023 increase some timeouts ........ r653760 | aidan | 2008-05-06 13:40:34 +0100 (Tue, 06 May 2008) | 3 lines QPID-1029: Generate temporary queue names using GUIDs to ensure uniqueness. ........ r654097 | aidan | 2008-05-07 14:25:38 +0100 (Wed, 07 May 2008) | 2 lines QPID-952, QPID-951, QPID-1032 Fix failover, ensure that it is properly detected, that frames are replayed approrpiately and that failover does not timeout. ........ r654104 | aidan | 2008-05-07 14:46:51 +0100 (Wed, 07 May 2008) | 1 line QPID-952 should have been part of previous commit ........ r654109 | aidan | 2008-05-07 14:56:09 +0100 (Wed, 07 May 2008) | 2 lines QPID-1036 increase timeouts to more reasonable levels, ensure that durable queues are deleted when no longer needed ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@654113 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs')
-rw-r--r--qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs b/qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs
index badaa48111..b62b11a3db 100644
--- a/qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs
+++ b/qpid/dotnet/Qpid.Client.Transport.Socket.Blocking/BlockingSocketProcessor.cs
@@ -53,6 +53,11 @@ namespace Apache.Qpid.Client.Transport.Socket.Blocking
{
_socket = new System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ /// For future note TCP Set NoDelay options may help, though with the blocking io not sure
+ /// The Don't linger may help with detecting disconnect but that hasn't been the case in testing.
+ /// _socket.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.NoDelay, 0);
+ /// _socket.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.DontLinger, 0);
+
IPHostEntry ipHostInfo = Dns.Resolve(_host); // Note: don't fix this warning. We do this for .NET 1.1 compatibility.
IPAddress ipAddress = ipHostInfo.AddressList[0];
@@ -77,6 +82,8 @@ namespace Apache.Qpid.Client.Transport.Socket.Blocking
{
_log.Error("Write caused exception", e);
_protocolListener.OnException(e);
+ // We should provide the error synchronously as we are doing blocking io.
+ throw e;
}
}
@@ -87,6 +94,17 @@ namespace Apache.Qpid.Client.Transport.Socket.Blocking
int numOctets = _networkStream.Read(bytes, 0, bytes.Length);
+ /// Read only returns 0 if the socket has been gracefully shutdown.
+ /// http://msdn2.microsoft.com/en-us/library/system.net.sockets.networkstream.read(VS.71).aspx
+ /// We can use this to block Send so the next Read will force an exception forcing failover.
+ /// Otherwise we need to wait ~20 seconds for the NetworkStream/Socket code to realise that
+ /// the socket has been closed.
+ if (numOctets == 0)
+ {
+ _socket.Shutdown(SocketShutdown.Send);
+ _socket.Close();
+ }
+
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
byteBuffer.limit(numOctets);