144 {
145
146 const char* pbuff = (const char*)ptr;
147 std::string recvd_buff(pbuff, cb);
148 LOG_PRINT("munin_recv: \n" << recvd_buff, LOG_LEVEL_3);
149
150 m_cache += recvd_buff;
151
152 bool stop_handling = false;
153 while(!stop_handling)
154 {
155 switch(m_machine_state)
156 {
157 case http_state_retriving_comand_line:
158 {
159
160 std::string::size_type fpos = m_cache.find('\n');
161 if(std::string::npos != fpos )
162 {
163 bool res = handle_command(m_cache);
165 return false;
166 m_cache.erase(0, fpos+1);
167 continue;
168 }
169 stop_handling = true;
170 }
171 break;
172 case http_state_error:
173 stop_handling = true;
174 return false;
175 default:
176 LOG_ERROR(
"Error in munin state machine! Unknown state=" << m_machine_state);
177 stop_handling = true;
178 m_machine_state = http_state_error;
179 return false;
180 }
181
182 }
183
184 return true;
185 }