aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Klötzke <jan@kloetzke.net>2019-12-16 22:56:52 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-11-22 14:33:58 +0100
commitd560030548cb237f9ef09a82fd6f372836655306 (patch)
tree6a6ca861cc0e533a6a77617f9fbed039dab16d08
parente3f4759019544673d654ad8a1ea256ed481fa5e3 (diff)
downloadbusybox-w32-d560030548cb237f9ef09a82fd6f372836655306.tar.gz
busybox-w32-d560030548cb237f9ef09a82fd6f372836655306.tar.bz2
busybox-w32-d560030548cb237f9ef09a82fd6f372836655306.zip
mdev: re-initialize if uevent messages were lost
If the netlink read() failed with ENOBUFS we know that we have missed at least one message due to a socket receive buffer overrun. The only way how to recover is to drop the old socket, open a fresh one and make a cold-plug scan of the current system state. Signed-off-by: Jan Klötzke <jan@kloetzke.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/mdev.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 4c00a2d7e..d4f06c128 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -1199,6 +1199,16 @@ static void daemon_loop(char *temp, int fd)
1199 1199
1200 len = safe_read(fd, netbuf, sizeof(netbuf) - 1); 1200 len = safe_read(fd, netbuf, sizeof(netbuf) - 1);
1201 if (len < 0) { 1201 if (len < 0) {
1202 if (errno == ENOBUFS) {
1203 /*
1204 * We ran out of socket receive buffer space.
1205 * Start from scratch.
1206 */
1207 dbg1s("uevent overrun, rescanning");
1208 close(fd);
1209 fd = daemon_init(temp);
1210 continue;
1211 }
1202 bb_simple_perror_msg_and_die("read"); 1212 bb_simple_perror_msg_and_die("read");
1203 } 1213 }
1204 end = netbuf + len; 1214 end = netbuf + len;