Esempio n. 1
0
static void
_restart_diskq(LogQueueDisk *self, gboolean corrupted)
{
  gchar *filename = g_strdup(qdisk_get_filename(self->qdisk));
  gchar *new_file = NULL;
  qdisk_deinit(self->qdisk);
  if (corrupted)
    {
      new_file = g_strdup_printf("%s.corrupted",filename);
      rename(filename,new_file);
      g_free(new_file);
    }
  if (self->start)
    {
      self->start(self, filename);
    }
  g_free(filename);
}
static gboolean
_push_tail (LogQueueDisk *s, LogMessage *msg, LogPathOptions *local_options, const LogPathOptions *path_options)
{
  LogQueueDiskNonReliable *self = (LogQueueDiskNonReliable *) s;

  if (HAS_SPACE_IN_QUEUE(self->qout) && qdisk_get_length (self->super.qdisk) == 0)
    {
      /* simple push never generates flow-control enabled entries to qout, they only get there
       * when rewinding the backlog */

      g_queue_push_tail (self->qout, msg);
      g_queue_push_tail (self->qout, LOG_PATH_OPTIONS_FOR_BACKLOG);
      log_msg_ref (msg);
    }
  else
    {
      if (self->qoverflow->length != 0 || !s->write_message(s, msg))
        {
          if (HAS_SPACE_IN_QUEUE(self->qoverflow))
            {
              g_queue_push_tail (self->qoverflow, msg);
              g_queue_push_tail (self->qoverflow, LOG_PATH_OPTIONS_TO_POINTER (path_options));
              log_msg_ref (msg);
              local_options->ack_needed = FALSE;
            }
          else
            {
              msg_debug ("Destination queue full, dropping message",
                         evt_tag_str ("filename", qdisk_get_filename (self->super.qdisk)),
                         evt_tag_int ("queue_len", _get_length(s)),
                         evt_tag_int ("mem_buf_length", self->qoverflow_size),
                         evt_tag_int ("size", qdisk_get_size (self->super.qdisk)),
                         evt_tag_str ("persist_name", self->super.super.persist_name));
              return FALSE;
            }
        }
    }
  return TRUE;
}
Esempio n. 3
0
static LogMessage *
_read_message(LogQueueDisk *self, LogPathOptions *path_options)
{
  LogMessage *msg = NULL;
  do
    {
      if (qdisk_get_length (self->qdisk) == 0)
        {
          break;
        }
      if (!_pop_disk (self, &msg))
        {
          msg_error("Error reading from disk-queue file, dropping disk queue",
                    evt_tag_str ("filename", qdisk_get_filename (self->qdisk)), NULL);
          self->restart_corrupted(self);
          if (msg)
            log_msg_unref (msg);
          msg = NULL;
          return NULL;
        }
    }
  while (msg == NULL);
  return msg;
}
Esempio n. 4
0
static gboolean
_pop_disk(LogQueueDisk *self, LogMessage **msg)
{
  GString *serialized;
  SerializeArchive *sa;

  *msg = NULL;

  if (!qdisk_initialized(self->qdisk))
    return FALSE;

  serialized = g_string_sized_new(64);
  if (!qdisk_pop_head(self->qdisk, serialized))
    {
      g_string_free(serialized, TRUE);
      return FALSE;
    }

  sa = serialize_string_archive_new(serialized);
  *msg = log_msg_new_empty();

  if (!log_msg_deserialize(*msg, sa))
  {
      g_string_free(serialized, TRUE);
      serialize_archive_free(sa);
      log_msg_unref(*msg);
      *msg = NULL;
      msg_error("Can't read correct message from disk-queue file",evt_tag_str("filename",qdisk_get_filename(self->qdisk)),NULL);
      return TRUE;
  }

  serialize_archive_free(sa);

  g_string_free(serialized, TRUE);
  return TRUE;
}
Esempio n. 5
0
const gchar *
log_queue_disk_get_filename(LogQueue *s)
{
  LogQueueDisk *self = (LogQueueDisk *) s;
  return qdisk_get_filename(self->qdisk);
}