summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@nwnk.net>2006-05-18 18:18:30 +0000
committerAdam Jackson <ajax@nwnk.net>2006-05-18 18:18:30 +0000
commite8b044ca913f1ac25cfb6aaf4c12fd87dcc1dcc3 (patch)
tree80e13973543a7a134b9d6336fca9231b1e3512ec
parentf398a6988e3a3740419a6cbc8cbe178aebe37272 (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)
-rw-r--r--ChangeLog7
-rw-r--r--hw/xfree86/os-support/linux/lnx_acpi.c25
2 files changed, 20 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 7eb9257c4..406b740f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2006-05-18 Adam Jackson <ajax@freedesktop.org>
+ * hw/xfree86/os-support/linux/lnx_acpi.c:
+ 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)
+
+2006-05-18 Adam Jackson <ajax@freedesktop.org>
+
* fb/fbcompose.c:
Bug #6827: Fix texel fetch in fbFetchTransformed to avoid
crashes. Still not 100% correct, but better than 7.0. (Radek
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;
}