~ubuntu-branches/ubuntu/oneiric/rsyslog/oneiric

« back to all changes in this revision

Viewing changes to runtime/batch.h

  • Committer: Dave Walker (Daviey)
  • Author(s): Scott Moser
  • Date: 2011-06-17 20:59:38 UTC
  • mfrom: (36.1.8 oneiric.merge)
  • Revision ID: davewalker@ubuntu.com-20110617205938-pfkizxz2wsgzi2ot
Tags: 5.8.1-1ubuntu1
* Resynchronise with Debian (LP: #794230).  Remaining changes:
  - Run as rsyslog:rsyslog, set $FileOwner to syslog
  - Replace init script with debian/rsyslog.upstart.
  - debian/rsyslog.logrotate: Use reload command to restart rsyslog
  - debian/rsyslog.conf: enable $RepeatedMsgReduction 
    to avoid bloating the syslog file (LP #453444)
  - Add debian/rsyslog.dmesg.upstart to save initial dmesg into a file.
    Install it in debian/rules.
  - debian/50-default.conf: set of default rules for syslog (forwarded to
    Debian #603160). remove file in postrm on purge. manage with ucf.
  - debian/rules: build with LDFLAGS=""
* Dropped:
  - debian/control: Bump build-dependency on debhelper
    debian now depends on dh >= 8
* New upstream release.
* Bump Standards-Version to 3.9.2. No further changes.
* Enable and install impstats module. (Closes: #620114)
* Update logcheck rule. (Closes: #616659)
* debian/rsyslog.init: Set correct compat level (5).
* The way rsyslog processes SIGHUP has changed. It no longer does a reload
  of its configuration, but simply closes all open files. To apply a changed
  configuration, rsyslogd needs to be restarted now.
  - Drop "reload" action from debian/rsyslog.init, map "force-reload" to
    "restart". (Closes: #580897)
  - Add "rotate" action to debian/rsyslog.init which sends SIGHUP to
    rsyslogd. Use that in debian/rsyslog.logrotate. (Closes: #626365)
  - Update debian/rsyslog-mysql.postinst and rsyslog-pgsql.postinst to use
    restart instead of reload.
  - Add a NEWS file explaining the changed SIGHUP handling.
* New upstream stable release.
* New upstream release.
  - Properly handle ANSI SQL strings in ompgsql. (Closes: #600479)
* New upstream release.
* debian/patches/02-pmaixforwardedfrom_type_nokeep.patch
  - Remove, merged upstream.
* debian/patches/03-epoll_create1-fallback.patch
  - Remove, merged upstream.
* debian/patches/03-epoll_create1-fallback.patch
  - If epoll_create1() is not available during runtime, fall back to
    epoll_create(). This fixes remote syslog when runnig rsyslog on a
    lenny kernel. (Closes: #617996)
* New upstream release.
* debian/rsyslog.links
  - Create symlink for rsyslog.service in multi-user.target.wants so rsyslog
    is enabled by default when using systemd.
* debian/patches/02-pmaixforwardedfrom_type_nokeep.patch
  - Fix build failure in aixforwardedfrom parser module by setting the
    module type to NOKEEP.
* debian/rsyslog.preinst
  - Remove old rsyslog.socket symlink from sockets.target.wants on upgrades
    as rsyslog uses syslog.socket now which is provided by systemd.
* debian/rsyslog.install
  - Stop installing rsyslog.socket.
* New upstream release.
* New upstream release.
  - Fix regression in imuxsock plugin which did no longer sanitize received
    messages. This makes 02-cleanup-trailing-lf.patch obsolete and also
    fixes the SQL syntax errors in the mysql output if the input contained
    NUL bytes. Closes: #614061
* Enable and install omprog output plugin. Closes: #552095
* Improve package description. Closes: #612948
  Thanks to Justin B Rye for the patch.
* debian/patches/02-cleanup-trailing-lf.patch
  - Fix regression in imuxsock plugin which did not remove a trailing LF
    anymore. Patch cherry-picked from upstream Git. Closes: #612829
* New upstream release.
* Enable and install parser modules.
* New upstream release.
* Upload to unstable.
* debian/patches/02-typo_fix_equation_sign.patch
  - Removed, merged upstream.
* debian/patches/03-atomic_operations.patch
  - Removed, merged upstream.
* debian/patches/03-atomic_operations.patch
  - Fix build failures on platforms which don't have 64 bit atomic
    operations. Patch cherry-picked from upstream Git. Closes: #600930
* New upstream development release.
* Remove patches, merged upstream
  - debian/patches/02-install_also_rsyslog_socket.patch
  - debian/patches/02-tls_loop_fix.patch
* debian/patches/02-typo_fix_equation_sign.patch
  - Fix small typo ("equation sign"). Closes: #575589
* debian/rsyslog.postinst
  - Remove pre-lenny migration code to rotate old log files from sysklogd.
* New upstream development release.
* debian/rsyslog.install
  - Install omruleset.so plugin: http://www.rsyslog.com/doc/omruleset.html
* debian/rsyslog.default
  - Start rsyslogd with native -c5 mode.
* Install systemd unit files which allow to run rsyslog in socket activation
  mode when systemd is used.
* debian/patches/02-install_also_rsyslog_socket.patch
  - When enabling rsyslog.service also enable rsyslog.socket. Patch
    cherry-picked from upstream Git.
* Bump debhelper compatibility level to 8. Update Build-Depends accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Definition of the batch_t data structure.
 
2
 * I am not sure yet if this will become a full-blown object. For now, this header just
 
3
 * includes the object definition and is not accompanied by code.
 
4
 *
 
5
 * Copyright 2009 by Rainer Gerhards and Adiscon GmbH.
 
6
 *
 
7
 * This file is part of the rsyslog runtime library.
 
8
 *
 
9
 * The rsyslog runtime library is free software: you can redistribute it and/or modify
 
10
 * it under the terms of the GNU Lesser General Public License as published by
 
11
 * the Free Software Foundation, either version 3 of the License, or
 
12
 * (at your option) any later version.
 
13
 *
 
14
 * The rsyslog runtime library is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU Lesser General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU Lesser General Public License
 
20
 * along with the rsyslog runtime library.  If not, see <http://www.gnu.org/licenses/>.
 
21
 *
 
22
 * A copy of the GPL can be found in the file "COPYING" in this distribution.
 
23
 * A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution.
 
24
 */
 
25
 
 
26
#ifndef BATCH_H_INCLUDED
 
27
#define BATCH_H_INCLUDED
 
28
 
 
29
#include <string.h>
 
30
#include "msg.h"
 
31
 
 
32
/* enum for batch states. Actually, we violate a layer here, in that we assume that a batch is used
 
33
 * for action processing. So far, this seems acceptable, the status is simply ignored inside the
 
34
 * main message queue. But over time, it could potentially be useful to split the two.
 
35
 * rgerhad, 2009-05-12
 
36
 */
 
37
typedef enum {
 
38
        BATCH_STATE_RDY  = 0,   /* object ready for processing */
 
39
        BATCH_STATE_BAD  = 1,   /* unrecoverable failure while processing, do NOT resubmit to same action */
 
40
        BATCH_STATE_SUB  = 2,   /* message submitted for processing, outcome yet unknown */
 
41
        BATCH_STATE_COMM = 3,   /* message successfully commited */
 
42
        BATCH_STATE_DISC = 4,   /* discarded - processed OK, but do not submit to any other action */
 
43
} batch_state_t;
 
44
 
 
45
 
 
46
/* an object inside a batch, including any information (state!) needed for it to "life".
 
47
 */
 
48
struct batch_obj_s {
 
49
        obj_t *pUsrp;           /* pointer to user object (most often message) */
 
50
        batch_state_t state;    /* associated state */
 
51
        /* work variables for action processing; these are reused for each action (or block of
 
52
         * actions)
 
53
         */
 
54
        sbool bFilterOK;        /* work area for filter processing (per action, reused!) */
 
55
        sbool bPrevWasSuspended;
 
56
        /* following are caches to save allocs if not absolutely necessary */
 
57
        uchar *staticActStrings[CONF_OMOD_NUMSTRINGS_MAXSIZE]; /**< for strings */
 
58
                                /* a cache to save malloc(), if not absolutely necessary */
 
59
        void *staticActParams[CONF_OMOD_NUMSTRINGS_MAXSIZE]; /**< for anything else */
 
60
        size_t staticLenStrings[CONF_OMOD_NUMSTRINGS_MAXSIZE];
 
61
                                /* and the same for the message length (if used) */
 
62
        /* end action work variables */
 
63
};
 
64
 
 
65
/* the batch
 
66
 * This object is used to dequeue multiple user pointers which are than handed over
 
67
 * to processing. The size of elements is fixed after queue creation, but may be 
 
68
 * modified by config variables (better said: queue properties).
 
69
 * Note that a "user pointer" in rsyslog context so far always is a message 
 
70
 * object. We stick to the more generic term because queues may potentially hold
 
71
 * other types of objects, too.
 
72
 * rgerhards, 2009-05-12
 
73
 * Note that nElem is not necessarily equal to nElemDeq. This is the case when we
 
74
 * discard some elements (because of configuration) during dequeue processing. As
 
75
 * all Elements are only deleted when the batch is processed, we can not immediately
 
76
 * delete them. So we need to keep their number that we can delete them when the batch
 
77
 * is completed (else, the whole process does not work correctly).
 
78
 */
 
79
struct batch_s {
 
80
        int maxElem;            /* maximum number of elements that this batch supports */
 
81
        int nElem;              /* actual number of element in this entry */
 
82
        int nElemDeq;           /* actual number of elements dequeued (and thus to be deleted) - see comment above! */
 
83
        int iDoneUpTo;          /* all messages below this index have state other than RDY */
 
84
        qDeqID  deqID;          /* ID of dequeue operation that generated this batch */
 
85
        int *pbShutdownImmediate;/* end processing of this batch immediately if set to 1 */
 
86
        sbool bSingleRuleset;   /* do all msgs of this batch use a single ruleset? */
 
87
        batch_obj_t *pElem;     /* batch elements */
 
88
};
 
89
 
 
90
 
 
91
/* some inline functions (we may move this off to an object .. or not) */
 
92
static inline void
 
93
batchSetSingleRuleset(batch_t *pBatch, sbool val) {
 
94
        pBatch->bSingleRuleset = val;
 
95
}
 
96
 
 
97
/* get the batches ruleset (if we have a single ruleset) */
 
98
static inline ruleset_t*
 
99
batchGetRuleset(batch_t *pBatch) {
 
100
        return (pBatch->nElem > 0) ? ((msg_t*) pBatch->pElem[0].pUsrp)->pRuleset : NULL;
 
101
}
 
102
 
 
103
/* get the ruleset of a specifc element of the batch (index not verified!) */
 
104
static inline ruleset_t*
 
105
batchElemGetRuleset(batch_t *pBatch, int i) {
 
106
        return ((msg_t*) pBatch->pElem[i].pUsrp)->pRuleset;
 
107
}
 
108
 
 
109
/* get number of msgs for this batch */
 
110
static inline int
 
111
batchNumMsgs(batch_t *pBatch) {
 
112
        return pBatch->nElem;
 
113
}
 
114
 
 
115
 
 
116
/* set the status of the i-th batch element. Note that once the status is
 
117
 * DISC, it will never be reset. So this function can NOT be used to initialize
 
118
 * the state table. -- rgerhards, 2010-06-10
 
119
 */
 
120
static inline void
 
121
batchSetElemState(batch_t *pBatch, int i, batch_state_t newState) {
 
122
        if(pBatch->pElem[i].state != BATCH_STATE_DISC)
 
123
                pBatch->pElem[i].state = newState;
 
124
}
 
125
 
 
126
 
 
127
/* check if an element is a valid entry. We do NOT verify if the
 
128
 * element index is valid. -- rgerhards, 2010-06-10
 
129
 */
 
130
static inline int
 
131
batchIsValidElem(batch_t *pBatch, int i) {
 
132
        return(pBatch->pElem[i].bFilterOK && pBatch->pElem[i].state != BATCH_STATE_DISC);
 
133
}
 
134
 
 
135
 
 
136
/* copy one batch element to another.
 
137
 * This creates a complete duplicate in those cases where
 
138
 * it is needed. Use duplication only when absolutely necessary!
 
139
 * Note that all working fields are reset to zeros. If that were 
 
140
 * not done, we would have potential problems with invalid
 
141
 * or double pointer frees.
 
142
 * rgerhards, 2010-06-10
 
143
 */
 
144
static inline void
 
145
batchCopyElem(batch_obj_t *pDest, batch_obj_t *pSrc) {
 
146
        memset(pDest, 0, sizeof(batch_obj_t));
 
147
        pDest->pUsrp = pSrc->pUsrp;
 
148
        pDest->state = pSrc->state;
 
149
}
 
150
 
 
151
 
 
152
/* free members of a batch "object". Note that we can not do the usual
 
153
 * destruction as the object typically is allocated on the stack and so the
 
154
 * object itself cannot be freed! -- rgerhards, 2010-06-15
 
155
 */
 
156
static inline void
 
157
batchFree(batch_t *pBatch) {
 
158
        int i;
 
159
        int j;
 
160
        for(i = 0 ; i < pBatch->maxElem ; ++i) {
 
161
                for(j = 0 ; j < CONF_OMOD_NUMSTRINGS_MAXSIZE ; ++j) {
 
162
                        /* staticActParams MUST be freed immediately (if required),
 
163
                         * so we do not need to do that!
 
164
                         */
 
165
                        free(pBatch->pElem[i].staticActStrings[j]);
 
166
                }
 
167
        }
 
168
        free(pBatch->pElem);
 
169
}
 
170
 
 
171
 
 
172
/* initialiaze a batch "object". The record must already exist,
 
173
 * we "just" initialize it. The max number of elements must be
 
174
 * provided. -- rgerhards, 2010-06-15
 
175
 */
 
176
static inline rsRetVal
 
177
batchInit(batch_t *pBatch, int maxElem) {
 
178
        DEFiRet;
 
179
        pBatch->iDoneUpTo = 0;
 
180
        pBatch->maxElem = maxElem;
 
181
        CHKmalloc(pBatch->pElem = calloc((size_t)maxElem, sizeof(batch_obj_t)));
 
182
        // TODO: replace calloc by inidividual writes?
 
183
finalize_it:
 
184
        RETiRet;
 
185
}
 
186
 
 
187
 
 
188
/* primarily a helper for debug purposes, get human-readble name of state */
 
189
static inline char *
 
190
batchState2String(batch_state_t state) {
 
191
        switch(state) {
 
192
        case BATCH_STATE_RDY:
 
193
                return "BATCH_STATE_RDY";
 
194
        case BATCH_STATE_BAD:
 
195
                return "BATCH_STATE_BAD";
 
196
        case BATCH_STATE_SUB:
 
197
                return "BATCH_STATE_SUB";
 
198
        case BATCH_STATE_COMM:
 
199
                return "BATCH_STATE_COMM";
 
200
        case BATCH_STATE_DISC:
 
201
                return "BATCH_STATE_DISC";
 
202
        }
 
203
        return "ERROR, batch state not known!";
 
204
}
 
205
#endif /* #ifndef BATCH_H_INCLUDED */