From 458110113ca43a023e9a3c0c59c16d90f96022ca Mon Sep 17 00:00:00 2001
From: James Cameron <quozl@laptop.org>
Date: Wed, 23 Dec 2009 15:35:32 +1100
Subject: [PATCH] dev.laptop.org #9924: remove O_SYNC on log file open
Removes the use of O_SYNC unless a gconf boolean setting is present.
With O_SYNC on open of log files, on systems with slow filesystem random
write performance, there is random activity startup time.
---
src/sugar/activity/activityfactory.py | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/sugar/activity/activityfactory.py b/src/sugar/activity/activityfactory.py
index ee0fd92..57c5a2b 100644
a
|
b
|
import logging |
25 | 25 | |
26 | 26 | import dbus |
27 | 27 | import gobject |
| 28 | import gconf |
28 | 29 | |
29 | 30 | from sugar.presence import presenceservice |
30 | 31 | from sugar.activity.activityhandle import ActivityHandle |
… |
… |
def get_command(activity, activity_id=None, object_id=None, uri=None): |
148 | 149 | |
149 | 150 | |
150 | 151 | def open_log_file(activity): |
| 152 | client = gconf.client_get_default() |
| 153 | flags = os.O_EXCL | os.O_CREAT | os.O_WRONLY |
| 154 | if client.get_bool('/desktop/sugar/logging/synchronous') |
| 155 | flags = flags | os.O_SYNC |
151 | 156 | i = 1 |
152 | 157 | while True: |
153 | 158 | path = env.get_logs_path('%s-%s.log' % (activity.get_bundle_id(), i)) |
154 | 159 | try: |
155 | | fd = os.open(path, os.O_EXCL | os.O_CREAT \ |
156 | | | os.O_SYNC | os.O_WRONLY, 0644) |
| 160 | fd = os.open(path, flags, 0644) |
157 | 161 | f = os.fdopen(fd, 'w', 0) |
158 | 162 | return (path, f) |
159 | 163 | except OSError, e: |