hal/hald/linux2/addons addon-acpi.c,1.12,1.13
Danny Kukawka
dkukawka at freedesktop.org
Wed Nov 9 13:13:33 PST 2005
Update of /cvs/hal/hal/hald/linux2/addons
In directory gabe:/tmp/cvs-serv15322/hald/linux2/addons
Modified Files:
addon-acpi.c
Log Message:
2005-11-09 Danny Kukawka <danny.kukawka at web.de>
* hald/linux2/addons/addon-acpi.c: (acpi_get_event_fp_kernel),
(acpi_get_event_fp_acpid), (main): fix problems with addon if acpid socket
is not available if HAL starts. In this case retry to connect until we get
the socket. Also added the proc kernel eventinterface to the loop to prevent
problems on resume from suspend. This should prevent restart the whole HAL
if lost acpid or proc event source.
* tools/lshal.c: (dump_devices), (usage), (main): added new option -s|--short
for short output, changed short option for show to -u, added new status line
to --monitor mode, allowed combine --monitor with --long|short|tree, added
restrict check for incorrect command options (e.g. 'lshal --'), set --long
as default if called lshal without option.
Index: addon-acpi.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/addons/addon-acpi.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- addon-acpi.c 12 Oct 2005 02:24:33 -0000 1.12
+++ addon-acpi.c 9 Nov 2005 21:13:30 -0000 1.13
@@ -41,27 +41,27 @@
#include "../probing/shared.h"
+#ifdef ACPI_PROC
static FILE *
acpi_get_event_fp_kernel (void)
{
FILE *fp = NULL;
-#ifdef ACPI_PROC
fp = fopen ("/proc/acpi/event", "r");
if (fp == NULL)
dbg ("Cannot open /proc/acpi/event: %s", strerror (errno));
-#endif
return fp;
}
+#endif
+#ifdef ACPI_ACPID
static FILE *
acpi_get_event_fp_acpid (void)
{
FILE *fp = NULL;
-#ifdef ACPI_ACPID
struct sockaddr_un addr;
int fd;
@@ -86,10 +86,11 @@
close (fd);
}
}
-#endif
return fp;
}
+#endif
+
static void
main_loop (LibHalContext *ctx, FILE *eventfp)
@@ -142,7 +143,6 @@
main (int argc, char **argv)
{
LibHalContext *ctx = NULL;
- int reconnecting = FALSE;
DBusError error;
FILE *eventfp;
@@ -156,26 +156,28 @@
return 1;
}
- /* If we can connect directly to the kernel then do so. */
- if ((eventfp = acpi_get_event_fp_kernel ())) {
- main_loop (ctx, eventfp);
- return 1;
- }
-
- /* Else, try to use acpid. */
- while ((eventfp = acpi_get_event_fp_acpid ()) || reconnecting)
+ while (1)
{
- if (eventfp != NULL)
+#ifdef ACPI_PROC
+ /* If we can connect directly to the kernel then do so. */
+ if ((eventfp = acpi_get_event_fp_kernel ())) {
main_loop (ctx, eventfp);
-
+ dbg ("Lost connection to kernel acpi event source - retry connect");
+ }
+#endif
+#ifdef ACPI_ACPID
+ /* Else, try to use acpid. */
+ if ((eventfp = acpi_get_event_fp_acpid ())) {
+ main_loop (ctx, eventfp);
+ dbg ("Cannot connect to acpid event socket - retry connect");
+ }
+#endif
+
/* If main_loop exits or we failed a reconnect attempt then
* sleep for 5s and try to reconnect (again). */
- reconnecting = TRUE;
sleep (5);
}
- dbg ("Cannot connect to acpi event source - bailing out");
-
return 1;
}
More information about the hal-commit
mailing list