Bug #2429 [ was DMD 1.037 and 2.020 releases]
Denis Koroskin
2korden at gmail.com
Wed Dec 10 14:06:08 PST 2008
On Wed, 10 Dec 2008 14:12:13 +0300, Lars Ivar Igesund <larsivar at igesund.net> wrote:
> Spacen Jasset wrote:
>
>> Fawzi Mohamed wrote:
>>> On 2008-12-08 19:06:42 +0100, Kagamin <spam at here.lot> said:
>>>
>>>> torhu Wrote:
>>>>
>>>>> Tango also opens files for writing with shared reading disabled by
>>>>> default. I'm not sure why, but maybe someone can remember the reason
>>>>> for it.
>>>>
>>>> they just forgot? :)
>>>
>>> consistency with windows as far as I know, so the program behaves the
>>> same on windows and unix.
>>>
>>> Fawzi
>>>
>> Its not consistent with any other libraries of any other compilers I
>> know of. The Linux implementation is in my opinion certainly incorrect.
>
> On Windows, the "default" is not shared in the sense that that is what
> you get if you pass no specific sharing parameters (0). I'm not windows
> expert, but if I read the CreateFile docs correctly, having some form of
> sharing as default can be wrong (causing errors) in some cases?
>
> On Posix, the situation is quite different in that sharing is default.
> In fact non-sharing is not enforced by the system such that it is up to
> the application to figure out whether it should stay away or not.
>
> I believe there is room for improvement, but I'm not sure the default
> should be different?
>
First of all, behaviour should be consistent across all platforms.
Second, FILE_SHARE_READ is completely safe. There won't be any problems if you write sequentially, i.e. rarely seek back and rewrite what you already wrote (and this covers more than 90% of use cases). I wont cause any problems in the latter case, too (application won't crash, handle gets invalidated or anything, but reading application should take additional care to re-read file entirely sometimes to stay up to date).
More information about the Digitalmars-d-announce
mailing list