internal void ReleaseAndDisposeSocket(ManagedSocket socket)
        {
            if (socket != null)
            {
                try
                {
                    socket.Idle = false;
                    Interlocked.Decrement(ref activeSocketCount);
                    Interlocked.Decrement(ref socketCount);

                    socket.Shutdown(SocketShutdown.Both);
                    socket.Close();
                    if (growing)
                    {
                        lock (growlock)
                        {
                            sockets[((ArrayManagedSocket)socket).Index] = null;
                        }
                    }
                    else
                    {
                        sockets[((ArrayManagedSocket)socket).Index] = null;
                    }
                    socket = null;
                }
                catch (SocketException)
                { }
                catch (ObjectDisposedException)
                { }
            }
        }
Example #2
0
        private void DisposeSocket(ManagedSocket socket, bool pullFromRotation)
        {
            bool exitLimiter = false;

            if (socket != null)
            {
                try
                {
                    if (!socket.Idle)
                    {
                        exitLimiter = true;
                        Interlocked.Decrement(ref activeSocketCount);
                    }

                    if (pullFromRotation)
                    {
                        PullSocketFromRotation((LinkedManagedSocket)socket);
                    }

                    socket.Idle = false;
                    Interlocked.Decrement(ref socketCount);

                    lock (setLock)
                    {
                        sockets.Remove((LinkedManagedSocket)socket);
                    }

                    if (socket.Connected)
                    {
                        socket.Shutdown(SocketShutdown.Both);
                    }

                    socket.Close();
                }
                catch (SocketException)
                { }
                catch (ObjectDisposedException)
                {
                    exitLimiter = false;
                    if (log.IsErrorEnabled)
                    {
                        log.ErrorFormat("Attempt to release and dispose disposed socket by pool for {0}, socket {1}", destination, socket.Handle);
                    }
                }
                finally
                {
                    if (exitLimiter)
                    {
                        ExitLimiter();
                    }
                }
            }
        }
		internal void ReleaseAndDisposeSocket(ManagedSocket socket)
		{
			try
			{
				socket.Shutdown(SocketShutdown.Both);
				socket.Close();
				Interlocked.Decrement(ref activeSocketCount);
				Interlocked.Decrement(ref socketCount);
			}
			catch (SocketException)
			{ }
			catch (ObjectDisposedException)
			{ }
		}
 internal void ReleaseAndDisposeSocket(ManagedSocket socket)
 {
     try
     {
         socket.Shutdown(SocketShutdown.Both);
         socket.Close();
         Interlocked.Decrement(ref activeSocketCount);
         Interlocked.Decrement(ref socketCount);
     }
     catch (SocketException)
     { }
     catch (ObjectDisposedException)
     { }
 }
		internal void ReleaseAndDisposeSocket(ManagedSocket socket)
		{
			if (socket != null)
			{
				try
				{
					socket.Idle = false;
					Interlocked.Decrement(ref activeSocketCount);
					Interlocked.Decrement(ref socketCount);
				
					socket.Shutdown(SocketShutdown.Both);
					socket.Close();
					if (growing)
					{
						lock (growlock)
						{
							sockets[((ArrayManagedSocket)socket).Index] = null;
						}
					}
					else
					{
						sockets[((ArrayManagedSocket)socket).Index] = null;
					}
					socket = null;
				}
				catch (SocketException)
				{ }
				catch (ObjectDisposedException)
				{ }
			}

		}