[Konsole-devel] konsole and configuration sync

Robert Knight robertknight at gmail.com
Fri Jun 5 17:47:08 UTC 2009


Hi Mike,

> shouldn't SessionManager::saveShortcuts()
> call shortcutGroup.sync() after it finishes writing the new entries?

KConfig calls sync() in its destructor if there are unsaved changes.
In the case of the global config accessed via KGlobal::config() this
will happen when the application exits.  Whether or not sync() is
called explicitly should make a difference - assuming that the config
file is actually getting destroyed on exit.  However - as a debugging
step to find out the cause of the problem, I'd suggest that adding an
explicit sync in SessionManager::saveShortcuts() would be a good idea
to narrow down the search space.

Diversion:

The discussion you linked to at
http://markmail.org/message/ow3xxvabgrebvnmi is referring to something
slightly different by 'syncing', which is making sure that the updated
.ini file has been flushed to the hard disk.  When KConfig writes to a
file (either as a result of KConfig::sync() or when it is destroyed),
or when any application writes to a file, the operating system will
not actually write the changes to disk immediately but will keep the
changes in memory for a while before flushing them to disk at some
convenient point.  This is not always desirable so Linux provides a
system call fsync() which forces the kernel to write the file to disk.
 This is an expensive and slow operation.  If done too often, it can
shorten the lifespan of a hard disk drive.  Hence there was a
discussion about whether KConfig should use fsync() or not to make
sure that contents were 'synced' to the HDD or whether it should rely
on the kernel to decide to do it at a sensible time.  The disadvantage
of not doing it is that if the system crashes after the file has been
written by the application but before the kernel has flushed the
changes to disk then those changes will be lost when the system is
restarted.  The new Ext4 file system recently introduced in Fedora and
Ubuntu did not flush changes to disk under the same circumstances that
the previous Ext3 system did - which ended up with people losing data
unexpectedly and there were lots of discussions amongst application
developers about whether or not they should pay the price of fsync().
In the end Ext4 had changes made to it to resolve the problems.

Regards,
Robert.

2009/6/5 Michael Blakeley <mike+konsole at blakeley.com>:
> I'm new to the list, so I apologize in advance for any breaches of
> etiquette. This will seem like a bug report at first, but I'm really
> asking a question about the SessionManager code.
>
> For some time I've noticed that konsole in my environment would not
> remember any shortcuts assigned to profiles (most recently with
> 4:4.2.85-0ubuntu1~jaunty1~ppa8, but also with earlier KDE4 builds). I
> can assign a shortcut via Settings > Manage Profiles, and it works for
> the duration of my session. But the next time I start a konsole session,
> the shortcut is gone. I don't have any problems with Settings >
> Configure Shortcuts, though.
> http://kubuntuforums.net/forums/index.php?topic=3104300.0 may also be
> related.
>
> Before reporting a bug, I wanted to characterize this issue more
> precisely. This led me to SessionManager::saveShortcuts() - I was trying
> to figure out where the changes should be written, so I could inspect
> the appropriate filesystem location. I'm less than expert in the KDE and
> Qt APIs, but the implementation I see at
> http://websvn.kde.org/trunk/KDE/kdebase/apps/konsole/src/SessionManager.cpp?view=markup
> leads me to ask this question: shouldn't SessionManager::saveShortcuts()
> call shortcutGroup.sync() after it finishes writing the new entries?
>
> The discussion at http://markmail.org/message/ow3xxvabgrebvnmi suggests
> that changes via writeEntry() will be lost unless sync() is also called.
> In fact I can't find a call to sync() anywhere in the konsole code
> (http://lxr.kde.org/search?filestring=apps%2Fkonsole&string=sync). That
> probably means I don't understand how the config APIs work, or perhaps
> I'm looking at the wrong code. Can anyone on the list offer some insight?
>
> thanks,
> -- Mike
> _______________________________________________
> konsole-devel mailing list
> konsole-devel at kde.org
> https://mail.kde.org/mailman/listinfo/konsole-devel
>



More information about the konsole-devel mailing list