コード例 #1
0
void
log_proto_buffered_server_free_method(LogProtoServer *s)
{
  LogProtoBufferedServer *self = (LogProtoBufferedServer *) s;

  log_transport_aux_data_destroy(&self->buffer_aux);

  g_free(self->buffer);
  if (self->state1)
    {
      g_free(self->state1);
    }
  if (self->convert != (GIConv) -1)
    g_iconv_close(self->convert);
  log_proto_server_free_method(s);
}
コード例 #2
0
ファイル: test_aux_data.c プロジェクト: pzoleex/syslog-ng
static void
test_aux_data_copy_creates_an_identical_copy(void)
{
  LogTransportAuxData *aux = construct_aux_with_some_data();
  LogTransportAuxData aux_copy;
  gchar *orig, *copy;

  log_transport_aux_data_copy(&aux_copy, aux);

  orig = _concat_nvpairs(aux);
  copy = _concat_nvpairs(&aux_copy);
  assert_string(orig, copy, "copy incorrectly copied aux->nvpairs");
  g_free(orig);
  g_free(copy);
  log_transport_aux_data_destroy(&aux_copy);
  free_aux(aux);
}
コード例 #3
0
ファイル: test_aux_data.c プロジェクト: Achint08/syslog-ng
static void
test_aux_data_copy_separates_the_copies(void)
{
  LogTransportAuxData *aux = construct_aux_with_some_data();
  LogTransportAuxData aux_copy;
  gchar *orig, *copy;
  
  log_transport_aux_data_copy(&aux_copy, aux);
  log_transport_aux_data_add_nv_pair(aux, "super", "lativus");
  
  orig = _concat_nvpairs(aux);
  copy = _concat_nvpairs(&aux_copy);
  assert_false(strcmp(orig, copy) == 0, "copy incorrectly copied aux->nvpairs as change to one of them affected the other, orig=%s, copy=%s", orig, copy);
  g_free(orig);
  g_free(copy);
  log_transport_aux_data_destroy(&aux_copy);
  free_aux(aux);
}
コード例 #4
0
ファイル: test_aux_data.c プロジェクト: pzoleex/syslog-ng
static void
free_aux(LogTransportAuxData *aux)
{
  log_transport_aux_data_destroy(aux);
  g_free(aux);
}
コード例 #5
0
ファイル: logreader.c プロジェクト: jszigetvari/syslog-ng
/* returns: notify_code (NC_XXXX) or 0 for success */
static gint
log_reader_fetch_log(LogReader *self)
{
  gint msg_count = 0;
  gboolean may_read = TRUE;
  LogTransportAuxData aux;

  log_transport_aux_data_init(&aux);
  if (log_proto_server_handshake_in_progress(self->proto))
    {
      return log_reader_process_handshake(self);
    }

  /* NOTE: this loop is here to decrease the load on the main loop, we try
   * to fetch a couple of messages in a single run (but only up to
   * fetch_limit).
   */
  while (msg_count < self->options->fetch_limit && !main_loop_worker_job_quit())
    {
      Bookmark *bookmark;
      const guchar *msg;
      gsize msg_len;
      LogProtoStatus status;

      msg = NULL;

      /* NOTE: may_read is used to implement multi-read checking. It
       * is initialized to TRUE to indicate that the protocol is
       * allowed to issue a read(). If multi-read is disallowed in the
       * protocol, it resets may_read to FALSE after the first read was issued.
       */

      log_transport_aux_data_reinit(&aux);
      bookmark = ack_tracker_request_bookmark(self->super.ack_tracker);
      status = log_proto_server_fetch(self->proto, &msg, &msg_len, &may_read, &aux, bookmark);
      switch (status)
        {
        case LPS_EOF:
          g_sockaddr_unref(aux.peer_addr);
          return NC_CLOSE;
        case LPS_ERROR:
          g_sockaddr_unref(aux.peer_addr);
          return NC_READ_ERROR;
        case LPS_SUCCESS:
          break;
        default:
          g_assert_not_reached();
          break;
        }

      if (!msg)
        {
          /* no more messages for now */
          break;
        }
      if (msg_len > 0 || (self->options->flags & LR_EMPTY_LINES))
        {
          msg_count++;

          ScratchBuffersMarker mark;
          scratch_buffers_mark(&mark);
          if (!log_reader_handle_line(self, msg, msg_len, &aux))
            {
              scratch_buffers_reclaim_marked(mark);
              /* window is full, don't generate further messages */
              break;
            }
          scratch_buffers_reclaim_marked(mark);
        }
    }
  log_transport_aux_data_destroy(&aux);

  if (msg_count == self->options->fetch_limit)
    self->immediate_check = TRUE;
  return 0;
}