| 140 | } |
| 141 | |
| 142 | void UnsentPacketQueue::sent(int bytes) { |
| 143 | while (bytes) { |
| 144 | ASSERT(unsent_first); |
| 145 | PacketBuffer* b = unsent_first; |
| 146 | |
| 147 | if (b->bytes_sent + bytes <= b->bytes_written && |
| 148 | (b->bytes_sent + bytes != b->bytes_written || (!b->next && b->bytes_unwritten()))) { |
| 149 | b->bytes_sent += bytes; |
| 150 | ASSERT(b->bytes_sent <= b->size()); |
| 151 | break; |
| 152 | } |
| 153 | |
| 154 | // We've sent an entire buffer |
| 155 | bytes -= b->bytes_written - b->bytes_sent; |
| 156 | b->bytes_sent = b->bytes_written; |
| 157 | ASSERT(b->bytes_written <= b->size()); |
| 158 | double queue_time = now() - b->enqueue_time; |
| 159 | sendQueueLatencyHistogram->sampleSeconds(queue_time); |
| 160 | unsent_first = b->nextPacketBuffer(); |
| 161 | if (!unsent_first) |
| 162 | unsent_last = nullptr; |
| 163 | b->delref(); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | void UnsentPacketQueue::discardAll() { |
| 168 | while (unsent_first) { |