* than the daemon could process them, which would then necessitate some
* sort of throttling. In practice, KMSG doesn't really get flooded with
* logs the same way Android Logger devices are so the throttling is mostly
- * there because we get it for free anyway and consistency doesn't hurt. */
+ * there because we got it for free anyway. */
- int max_loop_iterations = g_backend.logger_device_throttling[LOG_ID_KMSG];
+ int max_loop_iterations = g_backend.kmsg_throttling;
while (max_loop_iterations--) {
int r = read(wr->fd_entity.fd, wr->buffer, sizeof wr->buffer - 1);
const dlogutil_sorting_order_e sort_by = get_order_from_config(&conf);
- int throttling_default = log_config_get_int(&conf, "logger_dev_throttling", LOGGER_DEVICE_THROTTLING_DEFAULT);
const char *const dynamic_config_dir = log_config_get(&conf, DYNAMIC_CONFIG_CONF_KEY);
const char * const backend = log_config_claim_backend(&conf);
goto end;
}
- for (int i = 0; i < LOG_ID_MAX; i++) {
- char key[MAX_CONF_KEY_LEN];
- const int r = snprintf(key, sizeof key, "logger_dev_throttling_%s", log_name_by_id((log_id_t)i));
- if (r < 0)
- continue;
-
- g_backend.logger_device_throttling[i] = max_int(1, log_config_get_int(&conf, key, throttling_default));
- }
+ g_backend.kmsg_throttling = max_int(1, log_config_get_int(&conf, "logger_dev_throttling_kmsg", LOGGER_DEVICE_THROTTLING_DEFAULT));
if (dynamic_config_dir && dynamic_config_dir[0] == '/') {
data->dynamic_config_dir = strdup(dynamic_config_dir);
extern struct backend_data {
bool use_logger_by_default;
char logger_devices[LOG_ID_MAX][MAX_CONF_VAL_LEN];
- int logger_device_throttling[LOG_ID_MAX];
+ int kmsg_throttling;
struct reader_logger *logger_readers[LOG_ID_MAX];
/* Lazy polling is Android Logger specific, since in that case
struct reader_logger *const reader = (struct reader_logger *) _reader;
assert(reader);
- /* The devices for the Android Logger only return one log per read().
- * So using an 'if' here would be wasteful and, more importantly, too slow in the case where other logs come in.
- * However, with an unlimited loop, if there are extreme amounts of logs incoming,
- * the loop handles them slower than they come so the program stays in the loop
- * for a very long time, starving all other log sources. Using a limited loop
- * makes sure that the daemon works efficiently in the usual case while preventing
- * starvation under heavy load. */
- int max_loop_iterations = g_backend.logger_device_throttling[reader->buf_id];
- while (max_loop_iterations--) {
+ while (true) {
/* Note, nominally we had been polling the source FD entity and not
* `device_fd`, but that is the same FD (see the init and free ops).
* This is temporary redundancy due to the migration to threads. */