Changeset 874fd19 for logging.c


Ignore:
Timestamp:
Aug 5, 2017, 11:21:53 PM (7 years ago)
Author:
Jason Gross <jasongross9@gmail.com>
Branches:
master
Children:
1917e53
Parents:
edb14cc
git-author:
Jason Gross <jgross@mit.edu> (12/04/16 12:40:17)
git-committer:
Jason Gross <jasongross9@gmail.com> (08/05/17 23:21:53)
Message:
Fix the sense of drop_failed_logs

Previously, :flush-logs was dropping failed logs, while :flush-logs -f
was not.  Additionally, :flush-logs -f was enqueing the failed messages
at the end of the queue, breaking message ordering.

This commit fixes both of these issues.  I chose to optimize for the
case where :flush-logs is run without renewing tickets (where the
correct behavior is to stop at the first message that fails), rather
than the case where the user is logging to a directory they never have
permission to access (where the correct behavior is to try to log all of
the messages, and keep only the ones that fail).  This way, we won't
ever flood the system with lots of requests for files we don't have
permissions to access, and the user will have to :flush-logs -f if they
log to a directory they don't have permission to write to.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • logging.c

    redb14cc r874fd19  
    195195{
    196196  g_queue_push_tail(deferred_entry_queue, owl_log_new_entry(buffer, filename));
     197}
     198
     199static void owl_log_deferred_enqueue_first_message(const char *buffer, const char *filename)
     200{
     201  g_queue_push_head(deferred_entry_queue, owl_log_new_entry(buffer, filename));
    197202}
    198203
     
    259264                    msg->filename,
    260265                    g_strerror(ret));
    261       owl_log_deferred_enqueue_message(msg->message, msg->filename);
     266      /* If we were not in deferred logging mode, either the queue should be
     267       * empty, or we are attempting to log a message that we just popped off
     268       * the head of the queue.  Either way, we should enqueue this message as
     269       * the first message in the queue, rather than the last, so that we
     270       * preserve message ordering. */
     271      owl_log_deferred_enqueue_first_message(msg->message, msg->filename);
    262272    } else if (ret != 0) {
    263273      owl_log_file_error(msg, ret);
     
    279289    logged_at_least_one_message = true;
    280290    entry = (owl_log_entry*)g_queue_pop_head(deferred_entry_queue);
    281     if (drop_failed_logs) {
     291    if (!drop_failed_logs) {
     292      /* Attempt to write the log entry.  If it fails, re-queue the entry at
     293       * the head of the queue. */
    282294      owl_log_eventually_write_entry(entry);
    283295    } else {
     296      /* Attempt to write the log entry. If it fails, print an error message,
     297       * drop the log, and keep going through the queue. */
    284298      ret = owl_log_try_write_entry(entry);
    285299      if (ret != 0) {
Note: See TracChangeset for help on using the changeset viewer.