SHARE_DELETE is enabled even when nsIFileInputStream::SHARE_DELETE not specified on Linux

RESOLVED INVALID

Status

()

RESOLVED INVALID
3 years ago
a year ago

People

(Reporter: jwwang, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [necko-backlog])

(Reporter)

Updated

3 years ago
Flags: needinfo?(jduell.mcbugs)
(Reporter)

Comment 1

3 years ago
Also see bug 1068596 comment 37.

Comment 2

3 years ago
So my understanding (both from reading nsIFileStream.idl and looking at the code) is that setting SHARE_DELETE on Linux/OSX/etc (anything but windows) has absolutely no effect: the only code that checks it to do anything is windows-only:

  https://dxr.mozilla.org/mozilla-central/source/netwerk/base/nsFileStreams.cpp#344
  
So bug 1068596 comment 27: "On Linux: nsIFileInputStream::SHARE_DELETE not specified -> file opened with SHARE_DELETE" is wrong in that whether or not SHARE_DELETE is set, we always call  OpenNSPRFileDesc() (and never OpenNSPRFileDescShareDelete()).

So I don't think there's anything to do here.  Reopen if I'm wrong.
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Flags: needinfo?(jduell.mcbugs)
Resolution: --- → INVALID
(Reporter)

Comment 3

3 years ago
OK, let me put it this way.

On Windows, NS_NewLocalFileInputStream(i, f, -1, -1, -0) opens a file which can't be deleted before closing it.
On Linux, NS_NewLocalFileInputStream(i, f, -1, -1, -0) opens a file which can be deleted before closing it.

This is the inconsistency.
Flags: needinfo?(jduell.mcbugs)
(Reporter)

Comment 4

2 years ago
Per comment 3.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Is there anything we can do when operating systems does not provide an ability to make the behavior consistent?
Flags: needinfo?(jwwang)
(Reporter)

Comment 6

2 years ago
I don't think the ability is not provided by the system (Linux). It is just that we didn't implement it.
Flags: needinfo?(jwwang)
Whiteboard: [necko-backlog]
(In reply to JW Wang [:jwwang] [:jw_wang] from comment #6)
> I don't think the ability is not provided by the system (Linux). It is just
> that we didn't implement it.

What ability concretely? Linux only supports advisory lock AFAIK.
The behavior is also documented in the .idl and expected:

https://dxr.mozilla.org/mozilla-central/rev/3cedab21a7e65e6a1c4c2294ecfb5502575a46e3/netwerk/base/nsIFileStreams.idl#84-90
>    /**
>     * This flag has no effect and is totally ignored on any platform except
>     * Windows since this is the default behavior on POSIX systems. On Windows
>     * if this flag is set then the stream is opened in a special mode that
>     * allows the OS to delete the file from disk just like POSIX.
>     */
>    const long SHARE_DELETE = 1<<5;

This is not implementable on POSIX systems due to the difference of lock semantics.
Status: REOPENED → RESOLVED
Last Resolved: 3 years ago2 years ago
Resolution: --- → INVALID

Updated

a year ago
Flags: needinfo?(jduell.mcbugs)
You need to log in before you can comment on or make changes to this bug.