[PATCH] When we can't open the acpid socket, warn once, not once every second

Julien Cristau jcristau at debian.org
Tue Dec 23 04:08:49 PST 2008


---
 hw/xfree86/os-support/linux/lnx_acpi.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/os-support/linux/lnx_acpi.c b/hw/xfree86/os-support/linux/lnx_acpi.c
index bb975cc..8e11f4a 100644
--- a/hw/xfree86/os-support/linux/lnx_acpi.c
+++ b/hw/xfree86/os-support/linux/lnx_acpi.c
@@ -133,6 +133,7 @@ lnxACPIOpen(void)
     int fd;    
     struct sockaddr_un addr;
     int r = -1;
+    static int warned = 0;
 
 #ifdef DEBUG
     ErrorF("ACPI: OSPMOpen called\n");
@@ -148,8 +149,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));
+	    if (!warned)
+		xf86MsgVerb(X_WARNING,3,"Open ACPI failed (%s) (%s)\n",
+		            ACPI_SOCKET, strerror(errno));
+	    warned = 1;
 	    shutdown(fd, 2);
 	    close(fd);
 	    return NULL;
@@ -160,6 +163,7 @@ lnxACPIOpen(void)
     xf86PMConfirmEventToOs = lnxACPIConfirmEventToOs;
     ACPIihPtr = xf86AddGeneralHandler(fd,xf86HandlePMEvents,NULL);
     xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", ACPI_SOCKET);
+    warned = 0;
 
     return lnxCloseACPI;
 }
-- 
1.5.6.5




More information about the xorg mailing list