Ticket #1656: 0001-dev.laptop.org-9924-remove-O_SYNC-on-log-file-open.patch

File 0001-dev.laptop.org-9924-remove-O_SYNC-on-log-file-open.patch, 1.6 KB (added by quozl, 14 years ago)

alternate proposed implementation using gconf

  • src/sugar/activity/activityfactory.py

    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 
    2525
    2626import dbus
    2727import gobject
     28import gconf
    2829
    2930from sugar.presence import presenceservice
    3031from sugar.activity.activityhandle import ActivityHandle
    def get_command(activity, activity_id=None, object_id=None, uri=None): 
    148149
    149150
    150151def 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
    151156    i = 1
    152157    while True:
    153158        path = env.get_logs_path('%s-%s.log' % (activity.get_bundle_id(), i))
    154159        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)
    157161            f = os.fdopen(fd, 'w', 0)
    158162            return (path, f)
    159163        except OSError, e: