diff options
Diffstat (limited to 'sysklogd')
-rw-r--r-- | sysklogd/Config.in | 19 | ||||
-rw-r--r-- | sysklogd/logread.c | 7 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 14 |
3 files changed, 32 insertions, 8 deletions
diff --git a/sysklogd/Config.in b/sysklogd/Config.in index cb2ee0865..a671f59f1 100644 --- a/sysklogd/Config.in +++ b/sysklogd/Config.in | |||
@@ -56,6 +56,14 @@ config CONFIG_FEATURE_IPC_SYSLOG | |||
56 | entire filesystem, which may cause your system to | 56 | entire filesystem, which may cause your system to |
57 | break badly. | 57 | break badly. |
58 | 58 | ||
59 | config CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE | ||
60 | int " Circular buffer size in Kbytes (minimum 4KB)" | ||
61 | default 16 | ||
62 | depends on CONFIG_FEATURE_IPC_SYSLOG | ||
63 | help | ||
64 | This option sets the size of the circular buffer | ||
65 | used to record system log messages. | ||
66 | |||
59 | config CONFIG_LOGREAD | 67 | config CONFIG_LOGREAD |
60 | bool " logread" | 68 | bool " logread" |
61 | default y | 69 | default y |
@@ -66,6 +74,17 @@ config CONFIG_LOGREAD | |||
66 | utility will allow you to read the messages that are | 74 | utility will allow you to read the messages that are |
67 | stored in the syslogd circular buffer. | 75 | stored in the syslogd circular buffer. |
68 | 76 | ||
77 | config CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING | ||
78 | bool " logread double buffering" | ||
79 | default n | ||
80 | depends on CONFIG_LOGREAD | ||
81 | help | ||
82 | 'logread' ouput to slow serial terminals can have | ||
83 | side effects on syslog because of the semaphore. | ||
84 | This option make logread to double buffer copy | ||
85 | from circular buffer, minimizing semaphore | ||
86 | contention at some minor memory expense. | ||
87 | |||
69 | config CONFIG_KLOGD | 88 | config CONFIG_KLOGD |
70 | bool "klogd" | 89 | bool "klogd" |
71 | default n | 90 | default n |
diff --git a/sysklogd/logread.c b/sysklogd/logread.c index 524178fe8..207e78b57 100644 --- a/sysklogd/logread.c +++ b/sysklogd/logread.c | |||
@@ -108,8 +108,7 @@ extern int logread_main(int argc, char **argv) | |||
108 | i = follow ? buf->tail : buf->head; | 108 | i = follow ? buf->tail : buf->head; |
109 | 109 | ||
110 | do { | 110 | do { |
111 | #undef RC_LOGREAD | 111 | #ifdef CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING |
112 | #ifdef RC_LOGREAD | ||
113 | char *buf_data; | 112 | char *buf_data; |
114 | int log_len,j; | 113 | int log_len,j; |
115 | #endif | 114 | #endif |
@@ -128,7 +127,7 @@ extern int logread_main(int argc, char **argv) | |||
128 | } | 127 | } |
129 | 128 | ||
130 | // Read Memory | 129 | // Read Memory |
131 | #ifdef RC_LOGREAD | 130 | #ifdef CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING |
132 | log_len = buf->tail - i; | 131 | log_len = buf->tail - i; |
133 | if (log_len < 0) | 132 | if (log_len < 0) |
134 | log_len += buf->size; | 133 | log_len += buf->size; |
@@ -155,7 +154,7 @@ extern int logread_main(int argc, char **argv) | |||
155 | // release the lock on the log chain | 154 | // release the lock on the log chain |
156 | sem_up(log_semid); | 155 | sem_up(log_semid); |
157 | 156 | ||
158 | #ifdef RC_LOGREAD | 157 | #ifdef CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING |
159 | for (j=0; j < log_len; j+=strlen(buf_data+j)+1) { | 158 | for (j=0; j < log_len; j+=strlen(buf_data+j)+1) { |
160 | printf("%s", buf_data+j); | 159 | printf("%s", buf_data+j); |
161 | if (follow) | 160 | if (follow) |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 622500e48..42426ed80 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -94,6 +94,12 @@ static int local_logging = FALSE; | |||
94 | 94 | ||
95 | /* circular buffer variables/structures */ | 95 | /* circular buffer variables/structures */ |
96 | #ifdef CONFIG_FEATURE_IPC_SYSLOG | 96 | #ifdef CONFIG_FEATURE_IPC_SYSLOG |
97 | |||
98 | #if CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE < 4 | ||
99 | #error Sorry, you must set the syslogd buffer size to at least 4KB. | ||
100 | #error Please check CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE | ||
101 | #endif | ||
102 | |||
97 | #include <sys/ipc.h> | 103 | #include <sys/ipc.h> |
98 | #include <sys/sem.h> | 104 | #include <sys/sem.h> |
99 | #include <sys/shm.h> | 105 | #include <sys/shm.h> |
@@ -114,7 +120,7 @@ static struct sembuf SMwdn[3] = { {0, 0}, {1, 0}, {1, +1} }; // set SMwdn | |||
114 | 120 | ||
115 | static int shmid = -1; // ipc shared memory id | 121 | static int shmid = -1; // ipc shared memory id |
116 | static int s_semid = -1; // ipc semaphore id | 122 | static int s_semid = -1; // ipc semaphore id |
117 | static int data_size = 16000; // default data size | 123 | static int shm_size = ((CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE)*1024); // default shm size |
118 | static int circular_logging = FALSE; | 124 | static int circular_logging = FALSE; |
119 | 125 | ||
120 | /* | 126 | /* |
@@ -156,7 +162,7 @@ void ipcsyslog_cleanup(void) | |||
156 | void ipcsyslog_init(void) | 162 | void ipcsyslog_init(void) |
157 | { | 163 | { |
158 | if (buf == NULL) { | 164 | if (buf == NULL) { |
159 | if ((shmid = shmget(KEY_ID, data_size, IPC_CREAT | 1023)) == -1) { | 165 | if ((shmid = shmget(KEY_ID, shm_size, IPC_CREAT | 1023)) == -1) { |
160 | bb_perror_msg_and_die("shmget"); | 166 | bb_perror_msg_and_die("shmget"); |
161 | } | 167 | } |
162 | 168 | ||
@@ -164,7 +170,7 @@ void ipcsyslog_init(void) | |||
164 | bb_perror_msg_and_die("shmat"); | 170 | bb_perror_msg_and_die("shmat"); |
165 | } | 171 | } |
166 | 172 | ||
167 | buf->size = data_size - sizeof(*buf); | 173 | buf->size = shm_size - sizeof(*buf); |
168 | buf->head = buf->tail = 0; | 174 | buf->head = buf->tail = 0; |
169 | 175 | ||
170 | // we'll trust the OS to set initial semval to 0 (let's hope) | 176 | // we'll trust the OS to set initial semval to 0 (let's hope) |
@@ -654,7 +660,7 @@ extern int syslogd_main(int argc, char **argv) | |||
654 | if (optarg) { | 660 | if (optarg) { |
655 | int buf_size = atoi(optarg); | 661 | int buf_size = atoi(optarg); |
656 | if (buf_size >= 4) { | 662 | if (buf_size >= 4) { |
657 | data_size = buf_size; | 663 | shm_size = buf_size; |
658 | } | 664 | } |
659 | } | 665 | } |
660 | circular_logging = TRUE; | 666 | circular_logging = TRUE; |