示例#1
0
            protected void HandleWrites(SocketState ss)
            {
                ArrayList socks = ss.WriteSocks;

                for (int i = 0; i < socks.Count; i++)
                {
                    Socket        s  = (Socket)socks[i];
                    CreationState cs = ss.TakeCreationState(s);
                    if (cs != null)
                    {
                        cs.HandleWritability(s);
                    }
                    else
                    {
                        //Let's try to flush the buffer:
                        try {
                            ss.FlushSocket(s);
                        }
                        catch {
                            /*
                             * We should close this edge
                             */
                            TcpEdge tcpe = ss.GetEdge(s);
                            TEL.RequestClose(tcpe);
                            //Go ahead and forget about this socket.
                            CloseAction ca = new CloseAction(tcpe, null);
                            ca.Start(ss);
                        }
                    }
                }
            }
示例#2
0
            public override void Start(SocketState ss)
            {
                /*
                 * Note, we are the only thread running actions from the queue,
                 * so, no change to ss can happen concurrently with this logic
                 */
                ArrayList close_actions = new ArrayList();

                foreach (Socket s in ss.AllSockets)
                {
                    TcpEdge e = ss.GetEdge(s);
                    TEL.RequestClose(e);

                    /*
                     * We can't just call ca.Start(ss) because that
                     * would change ss.AllSockets
                     */
                    close_actions.Add(new CloseAction(e, null));
                }
                foreach (CloseAction ca in close_actions)
                {
                    ca.Start(ss);
                }
                //Close the main socket:
                ss.ListenSock.Close();
            }
示例#3
0
            /*
             * Update the SocketState.TAA and check to see if any Edges need
             * to be closed.
             */
            public override void Start(SocketState ss)
            {
                ss.TAA = TAA;
                ArrayList bad_edges = new ArrayList();

                foreach (Socket s in ss.AllSockets)
                {
                    TcpEdge e = ss.GetEdge(s);
                    if (e != null)
                    {
                        if (TAA.Authorize(e.RemoteTA) == TAAuthorizer.Decision.Deny)
                        {
                            //We can't close now, that would invalidate the AllSockets
                            //iterator
                            bad_edges.Add(e);
                        }
                    }
                }
                foreach (TcpEdge e in bad_edges)
                {
                    EL.RequestClose(e);
                    CloseAction ca = new CloseAction(e, null);
                    ca.Start(ss);
                }
            }