Hello,
The following patch fixes the circular log buffer in syslogd. Currently the
head pointer is never moved forward. The 'logread' command will always read
from the beginning of the buffer, even if the log buffer wraps.
The head pointer is not moved forward because it is 0 by default, so the
comparison (old_tail < shbuf->head) never evaluates to true.
I have only been able to test this patch on Busybox 1.4.2. I've included a
patch for 1.6.0 as well, if someone would please test and commit it. Thank you!
Regards,
Jari
--- busybox-1.4.2/sysklogd/syslogd.c 2007-06-29 13:50:37.000000000 -0400
+++ busybox-1.4.2/sysklogd/syslogd.c 2007-08-09 14:45:38.000000000 -0400
@@ -215,7 +215,7 @@
if (new_tail < shbuf->size) {
/* No need to move head if shbuf->head <= old_tail,
* else... */
- if (old_tail < shbuf->head && shbuf->head <= new_tail) {
+ if (old_tail <= shbuf->head && shbuf->head <= new_tail) {
/* ...need to move head forward */
c = memchr(shbuf->data + new_tail, '\0',
shbuf->size - new_tail);
--- busybox-1.6.1/sysklogd/syslogd.c 2007-06-30 11:06:35.000000000 -0400
+++ busybox-1.6.1/sysklogd/syslogd.c 2007-08-09 15:16:33.000000000 -0400
@@ -253,7 +253,7 @@
if (new_tail < G.shbuf->size) {
/* No need to move head if shbuf->head <= old_tail,
* else... */
- if (old_tail < G.shbuf->head && G.shbuf->head <= new_tail) {
+ if (old_tail <= G.shbuf->head && G.shbuf->head <= new_tail) {
/* ...need to move head forward */
c = memchr(G.shbuf->data + new_tail, '\0',
G.shbuf->size - new_tail);
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox