summaryrefslogtreecommitdiffstats
path: root/plugins/imklog
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-04-12 17:09:50 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2010-04-12 17:09:50 +0200
commit2a8d484a73654c26e427a11fb10162a41a7be79d (patch)
tree80edec55637063ca2d05052d8bcfb43ee1fbfa75 /plugins/imklog
parent7053a438efd07361b6e33de4bdf254b1d3b58553 (diff)
downloadrsyslog-2a8d484a73654c26e427a11fb10162a41a7be79d.tar.gz
rsyslog-2a8d484a73654c26e427a11fb10162a41a7be79d.tar.xz
rsyslog-2a8d484a73654c26e427a11fb10162a41a7be79d.zip
some cleanup of solaris imklog
Diffstat (limited to 'plugins/imklog')
-rw-r--r--plugins/imklog/solaris.c9
-rw-r--r--plugins/imklog/solaris_cddl.c62
-rw-r--r--plugins/imklog/solaris_cddl.h1
3 files changed, 23 insertions, 49 deletions
diff --git a/plugins/imklog/solaris.c b/plugins/imklog/solaris.c
index c2aec30a..8a6d5af1 100644
--- a/plugins/imklog/solaris.c
+++ b/plugins/imklog/solaris.c
@@ -42,6 +42,7 @@
#include "rsyslog.h"
#include "imklog.h"
+#include "srUtils.h"
#include "unicode-helper.h"
#include "solaris_cddl.h"
@@ -70,8 +71,8 @@ klogWillRun(void)
char errStr[1024];
int err = errno;
rs_strerror_r(err, errStr, sizeof(errStr));
- DBGPRINTF("error %d opening log socket: %s\n",
- GetPath(), errStr);
+ DBGPRINTF("error %s opening log socket: %s\n",
+ errStr, GetPath());
iRet = RS_RET_ERR; // TODO: better error code
}
@@ -79,6 +80,7 @@ klogWillRun(void)
}
+#if 0
/* Read /dev/klog while data are available, split into lines.
* Contrary to standard BSD syslogd, we do a blocking read. We can
* afford this as imklog is running on its own threads. So if we have
@@ -125,7 +127,7 @@ readklog(void)
break;
}
- for (p = pRcv; (q = strchr(p, '\n')) != NULL; p = q + 1) {
+ for(p = pRcv; (q = strchr(p, '\n')) != NULL; p = q + 1) {
*q = '\0';
Syslog(LOG_INFO, (uchar*) p);
}
@@ -143,6 +145,7 @@ readklog(void)
if(pRcv != NULL && (size_t) iMaxLine >= sizeof(bufRcv) - 1)
free(pRcv);
}
+#endif
/* to be called in the module's AfterRun entry point
diff --git a/plugins/imklog/solaris_cddl.c b/plugins/imklog/solaris_cddl.c
index 1053de66..7e86c68c 100644
--- a/plugins/imklog/solaris_cddl.c
+++ b/plugins/imklog/solaris_cddl.c
@@ -1,4 +1,3 @@
-#define MAXLINE 4096
/*
* CDDL HEADER START
*
@@ -53,6 +52,15 @@
#include <sys/strlog.h>
#include "rsyslog.h"
+#include "imklog.h"
+
+/* TODO: this define should be changed over time to the more generic
+ * system-provided (configurable) upper limit. However, it is quite
+ * unexpected that Solaris-emitted messages are so long, so it seems
+ * acceptable to set a fixed (relatively high) limit for the time
+ * being -- and gain some experience with it. -- rgerhars, 2010-04-12
+ */
+#define MAXLINE 4096
static struct pollfd Pfd; /* Pollfd for local the log device */
@@ -70,11 +78,6 @@ findnl_bkwd(const char *buf, const size_t len)
{
const char *p;
size_t mb_cur_max;
- pthread_t mythreadno;
-
- if (Debug) {
- mythreadno = pthread_self();
- }
if (len == 0) {
return (0);
@@ -104,8 +107,7 @@ findnl_bkwd(const char *buf, const size_t len)
/*
* Invalid character found.
*/
- dbgprintf("klog:findnl_bkwd(%u): Invalid MB "
- "sequence\n", mythreadno);
+ dbgprintf("klog:findnl_bkwd: Invalid MB sequence\n");
/*
* handle as a single byte character.
*/
@@ -148,7 +150,6 @@ sun_openklog(char *name, int mode)
struct strioctl str;
if ((fd = open(name, mode)) < 0) {
- //logerror("cannot open %s", name);
dbgprintf("klog:openklog: cannot open %s (%d)\n",
name, errno);
return (-1);
@@ -158,7 +159,6 @@ sun_openklog(char *name, int mode)
str.ic_len = 0;
str.ic_dp = NULL;
if (ioctl(fd, I_STR, &str) < 0) {
- //logerror("cannot register to log console messages");
dbgprintf("klog:openklog: cannot register to log "
"console messages (%d)\n", errno);
return (-1);
@@ -200,18 +200,7 @@ sun_getkmsg()
(void) memcpy(tmpbuf, buf, len);
tmpbuf[len] = '\0';
- /* Format sys will enqueue the log message.
- * Set the sync flag if timeout != 0, which
- * means that we're done handling all the
- * initial messages ready during startup.
- */
- Syslog(LOG_INFO, buf);
- /*if (timeout == 0) {
- formatsys(&hdr, tmpbuf, 0);
- //sys_init_msg_count++;
- } else {
- formatsys(&hdr, tmpbuf, 1);
- }*/
+ Syslog(LOG_INFO, (uchar*) buf);
if (len != buflen) {
/* If anything remains in buf */
@@ -238,8 +227,7 @@ sun_getkmsg()
if (i == 0 && dat.len > 0) {
dat.buf[dat.len] = '\0';
- /*
- * Format sys will enqueue the log message.
+ /* Format sys will enqueue the log message.
* Set the sync flag if timeout != 0, which
* means that we're done handling all the
* initial messages ready during startup.
@@ -249,15 +237,9 @@ sun_getkmsg()
dbgprintf("klog:getkmsg: getmsg: strlen(dat.buf) = %d\n", strlen(dat.buf));
dbgprintf("klog:getkmsg: getmsg: dat.buf = \"%s\"\n", dat.buf);
dbgprintf("klog:getkmsg: buf len = %d\n", strlen(buf));
- //if (timeout == 0) {
- //formatsys(&hdr, buf, 0);
- //--sys_init_msg_count++;
- //} else {
- //formatsys(&hdr, buf, 1);
- //}
- Syslog(LOG_INFO, buf);
+ Syslog(LOG_INFO, (uchar*) buf);
} else if (i < 0 && errno != EINTR) {
- if(1){ // (!shutting_down) {
+ if(1){ /* V5-TODO: rsyslog-like termination! (!shutting_down) { */
dbgprintf("klog:kernel log driver read error");
}
// TODO trigger retry logic
@@ -279,15 +261,6 @@ sun_sys_poll()
dbgprintf("klog:sys_poll: sys_thread started\n");
- /*
- * Try to process as many messages as we can without blocking on poll.
- * We count such "initial" messages with sys_init_msg_count and
- * enqueue them without the SYNC_FILE flag. When no more data is
- * waiting on the local log device, we set timeout to INFTIM,
- * clear sys_init_msg_count, and generate a flush message to sync
- * the previously counted initial messages out to disk.
- */
-
for (;;) {
errno = 0;
@@ -298,16 +271,13 @@ sun_sys_poll()
if (nfds < 0) {
if (errno != EINTR)
- dbgprintf("klog:poll error");// logerror("poll");
+ dbgprintf("klog:poll error");
continue;
}
if (Pfd.revents & POLLIN) {
sun_getkmsg();
} else {
- // TODO: shutdown, the rsyslog way (in v5!)
- //if (shutting_down) {
- //pthread_exit(0);
- //}
+ /* TODO: shutdown, the rsyslog way (in v5!) -- check shutdown flag */
if (Pfd.revents & (POLLNVAL|POLLHUP|POLLERR)) {
// TODO: trigger retry logic
/* logerror("kernel log driver poll error");
diff --git a/plugins/imklog/solaris_cddl.h b/plugins/imklog/solaris_cddl.h
index 22295658..d48ef628 100644
--- a/plugins/imklog/solaris_cddl.h
+++ b/plugins/imklog/solaris_cddl.h
@@ -1 +1,2 @@
+void *sun_sys_poll();
int sun_openklog(char *name, int mode);