+void Server::start_client_timeout_timer(Client *client)
+{
+ // Connection timestamps must be nondecreasing. I can't find any guarantee
+ // that even the monotonic clock can't go backwards by a small amount
+ // (think switching between CPUs with non-synchronized TSCs), so if
+ // this actually should happen, we hack around it by fudging
+ // connect_time.
+ if (clock_gettime(CLOCK_MONOTONIC_COARSE, &client->connect_time) == -1) {
+ log_perror("clock_gettime(CLOCK_MONOTONIC_COARSE)");
+ } else {
+ if (!clients_ordered_by_connect_time.empty() &&
+ is_earlier(client->connect_time, clients_ordered_by_connect_time.back().first)) {
+ client->connect_time = clients_ordered_by_connect_time.back().first;
+ }
+ clients_ordered_by_connect_time.push(make_pair(client->connect_time, client->sock));
+ }
+}
+