Ejemplo n.º 1
0
static gboolean
msg_limit_internal_message(const gchar *msg)
{
  MsgContext *context;

  if (!evt_context)
    return FALSE;

  context = msg_get_context();

  if (context->recurse_state >= RECURSE_STATE_SUPPRESS)
    {
      if (!context->recurse_warning)
        {
          msg_event_send(
            msg_event_create(EVT_PRI_WARNING,
                             "internal() messages are looping back, preventing loop by suppressing all internal messages until the current message is processed",
                             evt_tag_str("trigger-msg", context->recurse_trigger),
                             evt_tag_str("first-suppressed-msg", msg),
                             NULL));
          context->recurse_warning = TRUE;
        }
      return FALSE;
    }
  return TRUE;
}
Ejemplo n.º 2
0
void
msg_set_context(LogMessage *msg)
{
    MsgContext *context = msg_get_context();

    if (msg && (msg->flags & LF_INTERNAL))
    {
        context->recurse_count = msg->recurse_count + 1;
    }
    else
    {
        context->recurse_count = 0;
    }
}
Ejemplo n.º 3
0
void
msg_set_context(LogMessage *msg)
{
  MsgContext *context = msg_get_context();

  if (msg && (msg->flags & LF_INTERNAL))
    {
      if (msg->recursed)
        context->recurse_state = RECURSE_STATE_SUPPRESS;
      else
        context->recurse_state = RECURSE_STATE_WATCH;
    }
  else
    {
      context->recurse_state = RECURSE_STATE_OK;
    }
}
Ejemplo n.º 4
0
static void
msg_send_internal_message(int prio, const char *msg)
{
  if (G_UNLIKELY(log_stderr || (msg_post_func == NULL && (prio & 0x7) <= EVT_PRI_WARNING)))
    {
      fprintf(stderr, "%s\n", msg);
    }
  else
    {
      LogMessage *m;
      
      MsgContext *context = msg_get_context();

      if (context->recurse_count == 0)
        context->recurse_warning = FALSE;
      m = log_msg_new_internal(prio, msg);
      m->recurse_count = context->recurse_count;
      msg_post_message(m);
    }
}
Ejemplo n.º 5
0
static void
msg_send_internal_message(int prio, const char *msg)
{
    if (G_UNLIKELY(log_stderr || (!syslog_started && (prio & 0x7) <= EVT_PRI_WARNING)))
    {
        fprintf(stderr, "%s\n", msg);
    }
    else
    {
        LogMessage *m;

        if (G_LIKELY(internal_msg_queue))
        {
            MsgContext *context = msg_get_context();

            if (context->recurse_count == 0)
                context->recurse_warning = FALSE;
            m = log_msg_new_internal(prio, msg, LP_INTERNAL | LP_LOCAL);
            m->recurse_count = context->recurse_count;
            msg_queue_push(internal_msg_queue, m);
        }
    }
}
Ejemplo n.º 6
0
void
msg_send_formatted_message(int prio, const char *msg)
{
  if (G_UNLIKELY(log_stderr || (msg_post_func == NULL && (prio & 0x7) <= EVT_PRI_WARNING)))
    {
      msg_send_formatted_message_to_stderr(msg);
    }
  else if (msg_post_func)
    {
      LogMessage *m;

      MsgContext *context = msg_get_context();

      if (context->recurse_state == RECURSE_STATE_OK)
        {
          context->recurse_warning = FALSE;
          g_strlcpy(context->recurse_trigger, msg, sizeof(context->recurse_trigger));
        }
      m = log_msg_new_internal(prio, msg);
      m->recursed = context->recurse_state >= RECURSE_STATE_WATCH;
      msg_post_message(m);
    }
}
Ejemplo n.º 7
0
gboolean
msg_limit_internal_message(void)
{
    MsgContext *context;

    if (!evt_context)
        return FALSE;

    context = msg_get_context();

    if (context->recurse_count > MAX_RECURSIONS)
    {
        if (!context->recurse_warning)
        {
            msg_event_send(
                msg_event_create(EVT_PRI_WARNING, "syslog-ng internal() messages are looping back, preventing loop by suppressing further messages",
                                 evt_tag_int("recurse_count", context->recurse_count),
                                 NULL));
            context->recurse_warning = TRUE;
        }
        return FALSE;
    }
    return TRUE;
}