using System.Transactions;
using System.ServiceModel;
using System.ServiceModel.Description;
+using System.Net.Sockets;
+using System.Xml;
+using System.IO;
namespace System.ServiceModel.Dispatcher
{
public void CloseInput ()
{
foreach (var ch in channels.ToArray ()) {
- if (ch.State == CommunicationState.Closed)
- RemoveChannel (ch);
+ if (ch.State == CommunicationState.Closed) {
+ lock (channels) {
+ RemoveChannel (ch);
+ }
+ }
else {
try {
ch.Close (close_timeout - (DateTime.Now - close_started));
{
Message msg;
var input = (IInputChannel) result.AsyncState;
- if (input.EndTryReceive (result, out msg))
- ProcessInput (input, msg);
- else
+ try {
+ if (input.EndTryReceive (result, out msg))
+ ProcessInput (input, msg);
+ else
+ input.Close ();
+ } catch (ObjectDisposedException) {
input.Close ();
+ }
}
void ProcessRequest (IReplyChannel reply, RequestContext rc)
if (ProcessErrorWithHandlers (reply, ex, out res))
return;
- rc.Reply (res);
+ if ((!(ex is SocketException)) &&
+ (!(ex is XmlException)) &&
+ (!(ex is IOException)))
+ rc.Reply (res);
reply.Close (owner.DefaultCloseTimeout); // close the channel
} finally {