28 m_protocol(protocol) ,
30 m_line_buffer(
GNet::LineBuffer::
Config::smtp()) ,
38 m_protocol.changeSignal().disconnect() ;
43 applySome( data , size ) ;
44 if( m_timer.active() && overLimit() )
48void GSmtp::ServerBufferIn::onTimeout()
50 applySome(
nullptr , 0U ) ;
51 if( !m_timer.active() )
55void GSmtp::ServerBufferIn::applySome(
const char * data , std::size_t size )
57 if( m_protocol.inBusyState() )
59 G_ASSERT( m_timer.active() ) ;
60 m_line_buffer.add( data , size ) ;
66 G_ASSERT( m_protocol.inBusyState() ) ;
71 m_timer.cancelTimer() ;
73 G_ASSERT( m_timer.active() == m_protocol.inBusyState() ) ;
78bool GSmtp::ServerBufferIn::overLimit()
const
80 return m_line_buffer.buffersize() >= std::max(std::size_t(1U),m_config.input_buffer_soft_limit) ;
83bool GSmtp::ServerBufferIn::overHardLimit()
const
85 return m_config.input_buffer_hard_limit && m_line_buffer.buffersize() >= m_config.input_buffer_hard_limit ;
88void GSmtp::ServerBufferIn::flowOn()
93 m_flow_signal.emit(
true ) ;
97void GSmtp::ServerBufferIn::flowOff()
102 m_flow_signal.emit(
false ) ;
106void GSmtp::ServerBufferIn::onProtocolChange()
108 if( m_timer.active() )
109 m_timer.startTimer( 0U ) ;
114 m_line_buffer.expect( n ) ;
119 return m_line_buffer.state().head() ;
124 return m_flow_signal ;
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
A helper class for GSmtp::ServerProtocol that does buffering of data received from the remote peer an...
G::Slot::Signal< bool > & flowSignal() noexcept
Returns a signal that should be connected to a function that controls network flow control,...
std::string head() const
Returns GNet::LineBufferState::head().
~ServerBufferIn()
Destructor.
void expect(std::size_t)
Forwards to GNet::LineBuffer::expect().
void apply(const char *, std::size_t)
Called when raw data is received from the peer.
ServerBufferIn(GNet::EventState, ServerProtocol &, const Config &)
Constructor.
Implements the SMTP server-side protocol.
G::Slot::Signal & changeSignal() noexcept
A signal that is emitted at the end of apply() or whenever the protocol state might have changed by s...
bool apply(const ApplyArgsTuple &)
Called on receipt of a complete line of text from the client, or possibly a line fragment iff this ob...
bool inDataState() const
Returns true if currently in a data-transfer state meaning that the next apply() does not need to con...
static TimeInterval limit()
Factory function for the maximum valid interval.
Slot< Args... > slot(TSink &sink, void(TSink::*method)(Args...))
A factory function for Slot objects.
A configuration structure for GSmtp::ServerBufferIn.