Fix PASV reply for Firefox.
[dftpd.git] / SessionController.cpp
blob950becfff170de92a2e8b5d73b7c36e3d284102f
1 #include "SessionController.hpp"
2 #include "Exceptions.hpp"
3 #include "Log.hpp"
5 SessionController::SessionController()
6 {}
8 SessionController::~SessionController()
12 void SessionController::Tick( const std::list<int>& activeFds )
14 for( std::list<SessionPtr>::iterator it = m_list.begin(); it != m_list.end(); ++it )
16 std::list<int> fds = (*it)->GetFds();
18 bool work = false;
19 for( std::list<int>::const_iterator af = activeFds.begin(); af != activeFds.end(); ++af )
21 for( std::list<int>::const_iterator f = fds.begin(); f != fds.end(); ++f )
23 if( abs( *f ) == *af )
25 work = true;
26 break;
29 if( work ) break;
32 if( work )
34 (*it)->Tick();
38 while( !m_removeList.empty() )
40 unsigned int size = m_list.size();
41 m_list.remove( m_removeList.front() );
42 m_removeList.pop();
43 if( m_list.size() != size - 1 )
45 g_log->Print( "Removal of not registered session was requested" );
46 throw ServerCrashException;
51 void SessionController::Add( const SessionPtr& session )
53 m_list.push_back( session );
56 void SessionController::Remove( const SessionPtr& session )
58 m_removeList.push( session );
61 std::list<int> SessionController::GetFds() const
63 std::list<int> ret;
65 for( std::list<SessionPtr>::const_iterator it = m_list.begin(); it != m_list.end(); ++it )
67 std::list<int> fds = (*it)->GetFds();
68 ret.insert( ret.end(), fds.begin(), fds.end() );
71 return ret;