Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » FileStream locking issues
FileStream locking issues [message #35589] Fri, 02 March 2012 14:04 Go to next message
mirek is currently offline  mirek
Messages: 13428
Registered: November 2005
Ultimate Member
While working on problem with ide configuration file curruption (still unresolved), I have noticed that if two instances of same application do SaveFile at the same time, file can get corrupted.

Means there should be some sort of locking so that if some file is open with FileOut or FileAppend, next opening of the same file fails.

There already were some sharing flags, but they worked only in Win32 and IMO were never used.

Resolving situation: FileStream now supports NOWRITESHARE flag in Linux too (using flock system call), other sharing flags are deprecated (I think that for more complex situation, you cannot use FileStream anyway).

FileOut and FileAppend now specify NOWRITESHARE flag. Means second concurent try to FileOut the same file is gonna fail (file does not open).

Mirek
Re: FileStream locking issues [message #35926 is a reply to message #35589] Wed, 04 April 2012 21:59 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Great! Very handy indeed. Thanks.
Re: FileStream locking issues [message #35935 is a reply to message #35589] Thu, 05 April 2012 09:52 Go to previous message
zsolt is currently offline  zsolt
Messages: 629
Registered: December 2005
Location: Budapest, Hungary
Contributor
In one of my previous projects, I had multiple processes writing into the same logfile (appending). It worked well with line buffered writes. I think, the OS resolves this.
Previous Topic: svn mirror moved - and moved back
Next Topic: Stream public interface cleanup
Goto Forum:
  


Current Time: Mon Sep 27 00:01:48 CEST 2021

Total time taken to generate the page: 0.01134 seconds