From 2b81258b2bf80e4819904028c3ac5fddcec2a8e9 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 25 Jan 2011 11:26:01 +0100 Subject: Make dirmngr more battery friendly. Similar to gpg-agent, dirmngr's wait timeouts are now synced to the full second. Increased ldap helper thread timeout to 2 seconds. Nuked some white spaces. --- dirmngr/ldap-wrapper.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'dirmngr/ldap-wrapper.c') diff --git a/dirmngr/ldap-wrapper.c b/dirmngr/ldap-wrapper.c index 25ec15513..fa5bf3c6b 100644 --- a/dirmngr/ldap-wrapper.c +++ b/dirmngr/ldap-wrapper.c @@ -269,8 +269,17 @@ ldap_wrapper_thread (void *dummy) { pth_event_t timeout_ev; int any_action = 0; + pth_time_t nexttick; - timeout_ev = pth_event (PTH_EVENT_TIME, pth_timeout (1, 0)); + /* We timeout the pth_wait every 2 seconds. To help with power + saving we syncronize the timeouts to the next full second. */ + nexttick = pth_timeout (2, 0); + if (nexttick.tv_usec > 10) /* Use a 10 usec threshhold. */ + { + nexttick.tv_sec++; + nexttick.tv_usec = 0; + } + timeout_ev = pth_event (PTH_EVENT_TIME, nexttick); if (! timeout_ev) { log_error (_("pth_event failed: %s\n"), strerror (errno)); -- cgit v1.2.3