After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 307131 - file locking wrappers for GLib
file locking wrappers for GLib
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: general
2.6.x
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2005-06-10 11:35 UTC by Tor Lillqvist
Modified: 2018-05-24 10:35 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
simple lock API (2.03 KB, text/x-chdr)
2005-08-24 00:05 UTC, Emmanuele Bassi (:ebassi)
Details

Description Tor Lillqvist 2005-06-10 11:35:11 UTC
Wrappers for file locking would fit nicely into GLib. Many of the GNOME
libraries have essentially duplicated code snippets for this, and especially as
they are ported to Win32, it's tiresome to do the same porting several times.

IMHO it would be enough, at least as a start, to just have API to lock the whole
of the file, test if a file is locked, and unlock. The locking API could have
parameters to specify whether to retry the lock, how many times to retry, and
with what interval (possibly random).

One problematic issue would be what behaviour to specify or guarantee in
multiple thread cases. If I unerstand the lockf() spcification correctly, locks
are per-thread. The Win32 LockFile() documentation on the other hand talks only
about processes.
Comment 1 Emmanuele Bassi (:ebassi) 2005-07-03 13:31:02 UTC
File descriptors locked using lockf(2) are not inherited by child processes; for
that, flock(2) should be used - but flock(2) doesn't behave well over
NFS-mounted volumes, so fcntl(2) should be used instead.

Most of the times, lockf(2) is enough on POSIX-compliant systems, though.  If we
want a simple GLib wrapper for file locking, I'd say we should stick to lockf(2)
on *nix.
Comment 2 Emmanuele Bassi (:ebassi) 2005-08-24 00:05:19 UTC
Created attachment 51224 [details]
simple lock API

simple API for file locking.

you create a GLockedFile object, and then lock/unlock it.  freeing a
GLockedFile will result in removing any lock.

locking mechanism: write and read/write will use lockf(); read (if implemented)
should use fcntl().
Comment 3 GNOME Infrastructure Team 2018-05-24 10:35:52 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/33.