wmbattery: upower - don't exit after suspend/hibernation wakup
Immediately after suspend/hibernation wakup cycle, up_client_get_devices() can fail: libupower-glib-WARNING **: up_client_get_devices failed: Timeout was reached Since we do not interpret the UPower signals, just don't exit wmbattery after first up_client_get_devices() failure.
This commit is contained in:
parent
a8858dedde
commit
9c6faa3682
|
@ -9,6 +9,8 @@
|
||||||
#include <upower.h>
|
#include <upower.h>
|
||||||
#include "apm.h"
|
#include "apm.h"
|
||||||
|
|
||||||
|
#define MAX_RETRIES 3
|
||||||
|
|
||||||
static UpClient * up;
|
static UpClient * up;
|
||||||
|
|
||||||
struct context {
|
struct context {
|
||||||
|
@ -74,6 +76,7 @@ int upower_supported(void)
|
||||||
int upower_read(int battery, apm_info *info)
|
int upower_read(int battery, apm_info *info)
|
||||||
{
|
{
|
||||||
GPtrArray *devices = NULL;
|
GPtrArray *devices = NULL;
|
||||||
|
static int retries = 0;
|
||||||
|
|
||||||
up = up_client_new();
|
up = up_client_new();
|
||||||
|
|
||||||
|
@ -87,9 +90,15 @@ int upower_read(int battery, apm_info *info)
|
||||||
|
|
||||||
devices = up_client_get_devices(up);
|
devices = up_client_get_devices(up);
|
||||||
|
|
||||||
if (!devices)
|
if (!devices) {
|
||||||
|
retries++;
|
||||||
|
if (retries < MAX_RETRIES)
|
||||||
|
return 0; /* fine immediately after hibernation */
|
||||||
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
retries = 0;
|
||||||
info->battery_flags = 0;
|
info->battery_flags = 0;
|
||||||
info->using_minutes = 0;
|
info->using_minutes = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue