FD_SET(gre_b.fd(), &fds);
pacer_a.possibly_adjust_tv(&tv);
pacer_b.possibly_adjust_tv(&tv);
+ reorder_a.possibly_adjust_tv(&tv);
+ reorder_b.possibly_adjust_tv(&tv);
int ret = select(1024, &fds, NULL, NULL, &tv);
if (ret == -1) {
perror("select");
gettimeofday(&last_sent_packet, NULL);
}
+void Reorderer::possibly_adjust_tv(timeval *tv)
+{
+ if (packet_buffer.empty()) {
+ return;
+ }
+
+ timeval now;
+ gettimeofday(&now, NULL);
+ timeval tdiff = subtract_timeval_saturate(
+ offset_timeval_seconds(packet_buffer.top().ts, TIMEOUT_SEC), now);
+ if (less_than(tdiff, *tv)) {
+ *tv = tdiff;
+ }
+}
+
void Reorderer::send_packet(uint16_t proto, const string& data, int seq)
{
timeval now;
last_seq + 1, packet_buffer.top().seq);
silence = true;
last_seq = packet_buffer.top().seq - 1;
- // TODO: Rerun immediately after we've cleared out,
- // in case there are more timeouts.
}
// In case of restarts.
public:
Reorderer(Sender* sender);
void send_packet(uint16_t proto, const std::string& data, int seq);
+ void possibly_adjust_tv(timeval *tv);
private:
void check_ts_discontinuity(uint16_t proto, const std::string &data, bool silence);