[rygel] core: Don't spam debug log
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Don't spam debug log
- Date: Fri, 21 Mar 2014 19:42:33 +0000 (UTC)
commit 18548967c30b24c50231455814e2dec08fbd9bcb
Author: Jens Georg <mail jensge org>
Date: Fri Mar 21 20:25:30 2014 +0100
core: Don't spam debug log
Only try to read /etc/machine-info once, not all the time.
Signed-off-by: Jens Georg <mail jensge org>
src/librygel-core/rygel-root-device-factory.vala | 29 +++++++++++++--------
1 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/src/librygel-core/rygel-root-device-factory.vala
b/src/librygel-core/rygel-root-device-factory.vala
index 926d640..40d11d7 100644
--- a/src/librygel-core/rygel-root-device-factory.vala
+++ b/src/librygel-core/rygel-root-device-factory.vala
@@ -33,26 +33,33 @@ public errordomain RootDeviceFactoryError {
}
namespace Rygel {
+ private static string pretty_host_name = null;
+
public string get_pretty_host_name () {
- string machine_info;
- try {
- FileUtils.get_contents ("/etc/machine-info", out machine_info);
+ if (pretty_host_name == null) {
+ try {
+ string machine_info;
- var lines = machine_info.split ("\n");
+ FileUtils.get_contents ("/etc/machine-info", out machine_info);
- foreach (var line in lines) {
- var parts = line.split ("=");
+ var lines = machine_info.split ("\n");
- if (parts[0] == "PRETTY_HOSTNAME") {
- return string.joinv("=", parts[1:parts.length]);
+ foreach (var line in lines) {
+ var parts = line.split ("=");
+
+ if (parts[0] == "PRETTY_HOSTNAME") {
+ pretty_host_name = string.joinv("=", parts[1:parts.length]);
+ }
}
+ } catch (GLib.Error e) {
+ debug("Failed to parse /etc/machine-info: %s", e.message);
}
- } catch (GLib.Error e) {
- debug("Failed to parse /etc/machine-info: %s", e.message);
+
+ pretty_host_name = Environment.get_host_name ();
}
- return Environment.get_host_name ();
+ return pretty_host_name;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]