资源简介
syslog-ng-3.8.1.tar.gz syslog-ng-3.8.1.tar.gz
syslog-ng-3.8.1.tar.gz syslog-ng-3.8.1.tar.gz
代码片段和文件信息
/*
* Copyright (c) 2002-2012 Balabit
* Copyright (c) 1998-2012 Balázs Scheidler
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not write to the Free Software
* Foundation Inc. 51 Franklin St Fifth Floor Boston MA 02110-1301 USA
*
* As an additional exemption you are allowed to compile & link against the
* OpenSSL libraries as published by the OpenSSL project. See the file
* COPYING for details.
*
*/
#include “afinter.h“
#include “logreader.h“
#include “stats/stats-registry.h“
#include “messages.h“
#include “apphook.h“
#include “mainloop.h“
#include
typedef struct _AFInterSource AFInterSource;
static GStaticMutex internal_msg_lock = G_STATIC_MUTEX_INIT;
static GQueue *internal_msg_queue;
static AFInterSource *current_internal_source;
static StatsCounterItem *internal_queue_length;
/* the expiration timer of the next MARK message */
static struct timespec next_mark_target = { -1 0 };
/* as different sources from different threads can call afinter_postpone_mark
and we use the value in the init thread we need to syncronize the value references
*/
static GStaticMutex internal_mark_target_lock = G_STATIC_MUTEX_INIT;
/*
* This class is parallel to LogReader e.g. it hangs on the
* AFInterSourceDriver on the left (e.g. feeds messages to
* AFInterSourceDriver).
*
* Threading:
* ==========
*
* syslog-ng can generate internal() messages in any of its threads thus
* some care must be taken to make the internal() source multithreaded.
* This is how it works:
*
* Whenever a thread decides to send a message using the msg_() API it puts
* an entry into the internal_msg_queue under the protection of
* “internal_msg_lock“.
*
* The receiving side of this queue is in the main thread where the
* internal() source is operating. This object will publish a pointer to
* itself into current_internal_source. This pointer will be set under the
* protection of the internal_msg_lock. The internal source will define an
* ivykis event a post is submitted to this event whenever a new message is
* added to the queue.
*
* Once the event arrives to the main loop it wakes up and feeds all
* internal messages into the log path.
*
* If the window is depleted (e.g. flow control is enabled and the
* destination is unable to process any more messages)
* current_internal_source will be set to NULL which means that messages
* will be add
评论
共有 条评论