94 LOG_ERROR_CC(m_conn_context,
"Command handler not set!");
97 m_cach_in_buffer.append((
const char*)ptr, cb);
99 bool is_continue =
true;
104 case conn_state_reading_head:
105 if(m_cach_in_buffer.size() <
sizeof(bucket_head))
109 LOG_ERROR_CC(m_conn_context,
"Signature mismatch on accepted connection");
116 #if BYTE_ORDER == LITTLE_ENDIAN 117 bucket_head &phead = *(bucket_head*)m_cach_in_buffer.data();
119 bucket_head phead = *(bucket_head*)m_cach_in_buffer.data();
120 phead.m_signature =
SWAP64LE(phead.m_signature);
122 phead.m_command =
SWAP32LE(phead.m_command);
123 phead.m_return_code =
SWAP32LE(phead.m_return_code);
124 phead.m_reservedA =
SWAP32LE(phead.m_reservedA);
125 phead.m_reservedB =
SWAP32LE(phead.m_reservedB);
129 LOG_ERROR_CC(m_conn_context,
"Signature mismatch on accepted connection");
132 m_current_head = phead;
134 m_cach_in_buffer.erase(0,
sizeof(bucket_head));
135 m_state = conn_state_reading_body;
137 case conn_state_reading_body:
138 if(m_cach_in_buffer.size() < m_current_head.
m_cb)
145 if(m_cach_in_buffer.size() == m_current_head.
m_cb)
146 buff_to_invoke.swap(m_cach_in_buffer);
149 buff_to_invoke.assign(m_cach_in_buffer, 0, (std::string::size_type)m_current_head.
m_cb);
150 m_cach_in_buffer.erase(0, (std::string::size_type)m_current_head.
m_cb);
158 m_current_head.
m_cb = return_buff.size();
160 std::string send_buff((
const char*)&m_current_head,
sizeof(m_current_head));
161 send_buff += return_buff;
163 if(!m_psnd_hndlr->
do_send(send_buff.data(), send_buff.size()))
168 m_config.
m_pcommands_handler->notify(m_current_head.m_command, buff_to_invoke, m_conn_context);
170 m_state = conn_state_reading_head;
173 LOG_ERROR_CC(m_conn_context,
"Undefined state in levin_server_impl::connection_handler, m_state=" << m_state);
bool m_have_to_return_data
unsigned __int64 uint64_t
levin_commands_handler< t_connection_context > * m_pcommands_handler
#define LOG_ERROR_CC(ct, message)
virtual bool do_send(const void *ptr, size_t cb)=0