@@ -143,6 +143,10 @@ size_t Connection::receive(seq_t seq, const uint8_t* data, size_t n, bool PUSH)
143143
144144void Connection::write (Chunk buffer)
145145{
146+ if (UNLIKELY (buffer.size () == 0 )) {
147+ throw TCP_error (" Can't write zero bytes to TCP stream" );
148+ }
149+
146150 // Only write if allowed
147151 if (state_->is_writable ())
148152 {
@@ -199,9 +203,9 @@ void Connection::offer(size_t& packets)
199203 debug2 (" <Connection::offer> Finished working offer with [%u] packets left and a queue of (%u) with a usable window of %i\n " ,
200204 packets, writeq.size (), usable_window ());
201205
202- if ( can_send () and not queued_ )
206+ if ( this -> can_send () and not this -> is_queued () )
203207 {
204- host_.queue_offer (retrieve_shared () );
208+ host_.queue_offer (* this );
205209 }
206210}
207211
@@ -267,8 +271,11 @@ void Connection::receive_disconnect() {
267271 Expects (read_request and read_request->buffer .buffer ());
268272 auto & buf = read_request->buffer ;
269273
270- if (read_request->callback )
271- read_request->callback (buf.buffer (), buf.size ());
274+ if (read_request->callback ) {
275+ // TODO: consider adding back when SACK is complete
276+ // if (buf.size() > 0 && buf.missing() == 0)
277+ // read_request->callback(buf.buffer(), buf.size());
278+ }
272279}
273280
274281void Connection::segment_arrived (Packet_ptr incoming)
0 commit comments