diff options
author | Adam Jackson <ajax@nwnk.net> | 2006-05-18 18:18:41 +0000 |
---|---|---|
committer | Adam Jackson <ajax@nwnk.net> | 2006-05-18 18:18:41 +0000 |
commit | fa9a49a92db52de968d7147c71c6b9a8fd480f1e (patch) | |
tree | 153e383a251b83d28b05e141fecce03300b898da /hw | |
parent | 7893dadb2f6df218a4f4ea30a41c1aa9838da1f0 (diff) |
Bug #5877: Avoid burning CPU when acpid dies. Require acpid to be running
for ACPI support on Linux. Minor errno handling fixes. (Valery
Inozemtsev, Adam Jackson)
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_acpi.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/hw/xfree86/os-support/linux/lnx_acpi.c b/hw/xfree86/os-support/linux/lnx_acpi.c index 0c69ea172..6712c090f 100644 --- a/hw/xfree86/os-support/linux/lnx_acpi.c +++ b/hw/xfree86/os-support/linux/lnx_acpi.c @@ -16,7 +16,6 @@ #include <errno.h> #define ACPI_SOCKET "/var/run/acpid.socket" -#define ACPI_EVENTS "/proc/acpi/event" #define ACPI_VIDEO_NOTIFY_SWITCH 0x80 #define ACPI_VIDEO_NOTIFY_PROBE 0x81 @@ -47,8 +46,17 @@ lnxACPIGetEventFromOs(int fd, pmEvent *events, int num) memset(ev, 0, LINE_LENGTH); - n = read( fd, ev, LINE_LENGTH ); + do { + n = read( fd, ev, LINE_LENGTH ); + } while ((n == -1) && (errno == EAGAIN || errno == EINTR)); + if (n <= 0) { + lnxCloseACPI(); + sleep(1); + lnxACPIOpen(); + return 0; + } + /* Check that we have a video event */ if (strstr(ev, "video") == ev) { char *video = NULL; @@ -132,17 +140,10 @@ lnxACPIOpen(void) addr.sun_family = AF_UNIX; strcpy(addr.sun_path, ACPI_SOCKET); if ((r = connect(fd, (struct sockaddr*)&addr, sizeof(addr))) == -1) { + xf86MsgVerb(X_WARNING,3,"Open ACPI failed (%s) (%s)\n", ACPI_SOCKET, + strerror(errno)); shutdown(fd, 2); close(fd); - fd = -1; - } - } - - /* acpid's socket isn't available, so try going direct */ - if (fd == -1) { - if ((fd = open(ACPI_EVENTS, O_RDONLY)) < 0) { - xf86MsgVerb(X_WARNING,3,"Open ACPI failed (%s) (%s)\n", ACPI_EVENTS, - strerror(errno)); return NULL; } } @@ -150,7 +151,7 @@ lnxACPIOpen(void) xf86PMGetEventFromOs = lnxACPIGetEventFromOs; xf86PMConfirmEventToOs = lnxACPIConfirmEventToOs; ACPIihPtr = xf86AddInputHandler(fd,xf86HandlePMEvents,NULL); - xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", (r != -1) ? ACPI_SOCKET : ACPI_EVENTS); + xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", ACPI_SOCKET); return lnxCloseACPI; } |