File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,6 +84,14 @@ class Read_buffer {
8484 buffer_t buffer ()
8585 { return buf; }
8686
87+ /* *
88+ * @brief Check if internal buffer has unhandled data
89+ *
90+ * @return True if the internal buffer is unique with data and doesnt contain hole
91+ */
92+ bool has_unhandled_data ()
93+ { return (buf.unique () && (size () > 0 ) && (missing () == 0 )); }
94+
8795 /* *
8896 * @brief Exposes the internal buffer (read only)
8997 *
Original file line number Diff line number Diff line change @@ -202,13 +202,14 @@ namespace microLB
202202 assert (outgoing->is_connected ());
203203 LBOUT (" Assigning client to node %d (%s)\n " ,
204204 algo_iterator, outgoing->to_string ().c_str ());
205- auto & session = this ->create_session (
206- std::move (conn), std::move (outgoing));
207- // flush readq to session.outgoing
205+ // flush readq to outgoing before creating session
208206 for (auto buffer : readq) {
209207 LBOUT (" *** Flushing %lu bytes\n " , buffer->size ());
210- session. outgoing ->write (buffer);
208+ outgoing->write (buffer);
211209 }
210+ auto & session = this ->create_session (
211+ std::move (conn), std::move (outgoing));
212+
212213 return nullptr ;
213214 }
214215 }
Original file line number Diff line number Diff line change @@ -202,8 +202,9 @@ namespace tcp {
202202 // if noone is using the buffer right now, (stupid yes)
203203 // AND it contains data without any holes,
204204 // return it to the user
205- if (buf-> buffer (). unique () and buf-> size () > 0 and buf->missing () == 0 )
205+ if ( buf->has_unhandled_data () )
206206 {
207+
207208 callback (buf->buffer ());
208209 }
209210 // reset the first buffer
You can’t perform that action at this time.
0 commit comments