chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] prevent deadlocks on an corrupt udev database
[elogind.git]
/
udev.c
diff --git
a/udev.c
b/udev.c
index e6f2744fcbefe0826255550a0879e9f2f1c440a3..974b9582d0723440f218249263ee82f1c1f5ae3c 100644
(file)
--- a/
udev.c
+++ b/
udev.c
@@
-36,6
+36,9
@@
#include "namedev.h"
#include "udevdb.h"
#include "namedev.h"
#include "udevdb.h"
+/* timeout flag for udevdb */
+extern sig_atomic_t gotalarm;
+
/* global variables */
char **main_argv;
char **main_envp;
/* 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) {
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();
case SIGINT:
case SIGTERM:
udevdb_exit();
@@
-94,7
+101,8
@@
int main(int argc, char *argv[], char *envp[])
dbg("version %s", UDEV_VERSION);
dbg("version %s", UDEV_VERSION);
- /* initialize our configuration */
+ init_logging("udev");
+
udev_init_config();
if (strstr(argv[0], "udevstart")) {
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;
/* set signal handlers */
act.sa_handler = sig_handler;
+
sigemptyset (&act.sa_mask);
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);
sigaction(SIGINT, &act, NULL);
sigaction(SIGTERM, &act, NULL);
+ /* trigger timout to interrupt blocking syscalls */
+ alarm(ALARM_TIMEOUT);
+
/* initialize udev database */
/* 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:
switch(act_type) {
case UDEVSTART: