Closed Bug 263127 Opened 21 years ago Closed 18 years ago

nsDownloader keeps tempfile open too long

Categories

(Core :: Networking, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Assigned: jwkbugzilla)

References

Details

Attachments

(3 files, 4 obsolete files)

When I give nsDownloader a temp file to download to, I run into two problems: 1. onDownloadComplete sometimes happens before the file is fully written. So when the program tries to open the file, it sees an empty (?) file. 2. Firefox usually keeps the file open too long, so I can't delete the file manually. Also, some programs get a sharing violation when they try to open the file, perhaps because they open the file read/write instead of read. These two problems might have the same root cause. That is, it might be that whatever keeps the file open too long also prevents it from being flushed when it should be.
This testcase requires chrome privs. One way to test it is to install http://ted.mielczarek.org/code/mozilla/extensiondev/ and paste this testcase into a chrome Real-Time HTML Editor.
clarifying summary, the object keeps the file open, not its init function. onstopr should probably call mSink->Flush() and then release it (in the case where it wrote to the file itself)
Summary: nsDownloader::init(observer, tempfile) keeps tempfile open too long → nsDownloader keeps tempfile open too long
Assignee: darin → nobody
QA Contact: benc → networking
Version: 1.7 Branch → Trunk
Appears as problem for TomTom, can't delete temp files. We need to either fix it or stop using the class.
Attached patch possible solution v0 (obsolete) — Splinter Review
Null out the sink in |OnStopRequest| if we have one.
Attached patch patch v1 (obsolete) — Splinter Review
Also works if we only have a sink but |status| did not indicate success, and flus()es first.
Attachment #268288 - Attachment is obsolete: true
biesi says: instead of Flush(), do Close() and the null out.
Attached patch Patch v1.1Splinter Review
Replaced Flush() by Close(), made destructor do the same as OnStopRequest() and adjusted style slightly.
Attachment #268419 - Attachment is obsolete: true
Attachment #268487 - Flags: superreview?
Attachment #268487 - Flags: review?
Attachment #268487 - Flags: superreview?(darin.moz)
Attachment #268487 - Flags: superreview?
Attachment #268487 - Flags: review?(cbiesinger)
Attachment #268487 - Flags: review?
Comment on attachment 268487 [details] [diff] [review] Patch v1.1 please write a unit test before checking this in
Attachment #268487 - Flags: review?(cbiesinger) → review+
Attached patch xpcshell testcase (obsolete) — Splinter Review
Assignee: nobody → trev.moz
Status: NEW → ASSIGNED
Attachment #268804 - Flags: superreview?(darin.moz)
Attachment #268804 - Flags: review?(cbiesinger)
Attached patch xpcshell testcase (obsolete) — Splinter Review
Sorry, used wrong bug number in the testcase.
Attachment #268804 - Attachment is obsolete: true
Attachment #268805 - Flags: superreview?(darin.moz)
Attachment #268805 - Flags: review?(cbiesinger)
Attachment #268804 - Flags: superreview?(darin.moz)
Attachment #268804 - Flags: review?(cbiesinger)
Comment on attachment 268805 [details] [diff] [review] xpcshell testcase I'd have used an existing path instead of writing a new request handler, but sure... also, you have to stop the server in onDownloadComplete, or you'll get xpconnect assertions
Attachment #268805 - Flags: review?(cbiesinger) → review+
Attachment #268805 - Attachment is obsolete: true
Attachment #268913 - Flags: superreview?(darin.moz)
Attachment #268913 - Flags: review+
Attachment #268805 - Flags: superreview?(darin.moz)
Attachment #268913 - Attachment description: Testcase with biesi → Testcase with biesi's corrections
I need this for bug 352762 for 1.9
Flags: blocking1.9?
Blocks: 352762
Flags: blocking1.9? → blocking1.9+
Attachment #268487 - Flags: superreview?(darin.moz) → superreview+
Attachment #268913 - Flags: superreview?(darin.moz) → superreview+
Keywords: checkin-needed
Checking in netwerk/base/src/nsDownloader.cpp; /cvsroot/mozilla/netwerk/base/src/nsDownloader.cpp,v <-- nsDownloader.cpp new revision: 1.19; previous revision: 1.18 done RCS file: /cvsroot/mozilla/netwerk/test/unit/test_bug263127.js,v done Checking in netwerk/test/unit/test_bug263127.js; /cvsroot/mozilla/netwerk/test/unit/test_bug263127.js,v <-- test_bug263127.js initial revision: 1.1 done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Blocks: tomtom
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: