diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2004-10-13 23:13:26 -0700 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 21:47:44 -0700 |
commit | 7e89a569cc4db0c1482662dc4df5f60df7aef3ff (patch) | |
tree | 815fbb823b795e99cb04096a38f3b049c71a9ee2 /udev.c | |
parent | c36f0ac34fa3bf8b952889b9197a5ee1ea5d2714 (diff) |
[PATCH] prevent deadlocks on an corrupt udev database
Here is the patch, that should prevent all of the known deadlocks with
corrupt tdb databases we discovered.
Thanks to Frank Steiner <fsteiner-mail@bio.ifi.lmu.de>, who tested all this
endlessly with a NFS mounted /dev. The conclusion is, that udev will not work
on filesystems without proper record locking, but we should prevent the
endless loops anyway. This patch implements:
o recovery from a corrupted udev database. udev will continue
without database support now, instead of doing nothing. So the node should
be generated in any case, remove will obviously not work for custom names.
o added iteration limits to the tdb-code at the places we discovered endless
loops. In the case tdb tries to find more than 100.000 entries with the
same hash, we better give up :)
o prevent a {all_partitions} loop caused by corrupt db data
o log all tdb errors to syslog
o switch sleep() to usleep() cause we want to use alarm()
Diffstat (limited to 'udev.c')
-rw-r--r-- | udev.c | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -36,6 +36,9 @@ #include "namedev.h" #include "udevdb.h" +/* timeout flag for udevdb */ +extern sig_atomic_t gotalarm; + /* global variables */ char **main_argv; char **main_envp; @@ -58,6 +61,10 @@ void log_message(int level, const char *format, ...) asmlinkage static void sig_handler(int signum) { switch (signum) { + case SIGALRM: + gotalarm = 1; + info("error: timeout reached, event probably not handled correctly"); + break; case SIGINT: case SIGTERM: udevdb_exit(); @@ -94,7 +101,8 @@ int main(int argc, char *argv[], char *envp[]) dbg("version %s", UDEV_VERSION); - /* initialize our configuration */ + init_logging("udev"); + udev_init_config(); if (strstr(argv[0], "udevstart")) { @@ -146,16 +154,19 @@ int main(int argc, char *argv[], char *envp[]) /* set signal handlers */ act.sa_handler = sig_handler; + sigemptyset (&act.sa_mask); - act.sa_flags = SA_RESTART; + /* alarm must interrupt syscalls*/ + sigaction(SIGALRM, &act, NULL); sigaction(SIGINT, &act, NULL); sigaction(SIGTERM, &act, NULL); + /* trigger timout to interrupt blocking syscalls */ + alarm(ALARM_TIMEOUT); + /* initialize udev database */ - if (udevdb_init(UDEVDB_DEFAULT) != 0) { - dbg("unable to initialize database"); - goto exit; - } + if (udevdb_init(UDEVDB_DEFAULT) != 0) + info("error: unable to initialize database, continuing without database"); switch(act_type) { case UDEVSTART: |