Skip to content

Commit

Permalink
Fix issue in bootlogd which could cause the service to enter an endle…
Browse files Browse the repository at this point in the history
…ss loop

(and use too much CPU) when it is able to open a device for writing, but not actually
able to write to it. This resulted in bootlogd closing and re-opening the device over
and over. Now bootlogd should simply fail gracefully when it cannot write to an open
file/device.
  • Loading branch information
Jesse committed Jul 29, 2024
1 parent 9deb5d4 commit ae5facf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doc/Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ sysvinit (3.10) unreleased; urgency=low
SysV init now catches this signal and initiates a shutdown (shutdown -hP now).
- floppym provided patch to accomplish this.

* Fix issue in bootlogd which could cause the service to enter an endless loop
(and use too much CPU) when it is able to open a device for writing, but not actually
able to write to it. This resulted in bootlogd closing and re-opening the device over
and over. Now bootlogd should simply fail gracefully when it cannot write to an open
file/device.

* Fix formatting in shutdown.8 manual page. Cleaned up whitespace and special characters.


sysvinit (3.09) released; urgency=low
Expand Down
8 changes: 8 additions & 0 deletions src/bootlogd.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ int main(int argc, char **argv)
#ifndef __linux__ /* BSD-style ioctl needs an argument. */
int on = 1;
#endif
int prev_eio = 0;
int considx;
struct real_cons cons[MAX_CONSOLES];
int num_consoles, consoles_left;
Expand Down Expand Up @@ -728,8 +729,15 @@ int main(int argc, char **argv)
if (i >= 0) {
m -= i;
p += i;
prev_eio = 0;
continue;
}
/* Don't try to write the same data
* again if we got EIO twice */
if ( (errno == EIO) && (prev_eio) ) {
m = 0;
}
prev_eio = (errno == EIO);
/*
* Handle EIO (somebody hung
* up our filedescriptor)
Expand Down

0 comments on commit ae5facf

Please sign in to comment.