Closed Bug 1274999 Opened 8 years ago Closed 8 years ago

Stop GetFilesHelper runnable when the operation is canceled.

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed

People

(Reporter: baku, Assigned: baku)

Details

(Whiteboard: btpp-active)

Attachments

(1 file, 1 obsolete file)

Attached patch stop.patch (obsolete) — Splinter Review
      No description provided.
Attachment #8755448 - Flags: review?(bugs)
Comment on attachment 8755448 [details] [diff] [review]
stop.patch

This seems to be some testing patch, at least it contains such stuff too.
So I'm not sure whether you were supposed to add some debug-only code or what.
Could you upload a new patch.
Attachment #8755448 - Flags: review?(bugs)
Sorry, forgot to describe what this patch does:

When a GetFilesHelper is unlinked, we don't check if it's doing something in the IO thread.
With this patch, we try to stop the IO operation at any directory listing, and we don't go back to main-thread if that helper has been canceled.

The test tries (because not always the helper is fast enough) to reproduce this issue and to check that the result is correctly generated.
Attachment #8755448 - Flags: review?(bugs)
Comment on attachment 8755448 [details] [diff] [review]
stop.patch

>     if (!NS_IsMainThread()) {
>       RunIO();
>+
>+      // If this operation has been canceled, we don't have to go back to
>+      // main-thread.
>+      {
>+        MutexAutoLock lock(mMutex);
>+        if (mCanceled) {
>+          return NS_OK;
>+        }
>+      }
>+
>       return NS_DispatchToMainThread(this);
>     }
> 
>+    MOZ_ASSERT(!mCanceled);
You can't assert this. It is possible that someone has canceled this before we're here.
But you should return early if mCanceled.

>   ExploreDirectory(const nsAString& aDOMPath, nsIFile* aFile)
>   {
>     MOZ_ASSERT(!NS_IsMainThread());
>     MOZ_ASSERT(aFile);
> 
>+  nsString ppath; aFile->GetPath(ppath);
>+printf("EXPLORE %s\n", NS_ConvertUTF16toUTF8(ppath).get());
>+    // We check if this operation has to be terminated at each recursion.
>+    {
>+      MutexAutoLock lock(mMutex);
>+      if (mCanceled) {
>+puts("OUT!");
>+        return NS_OK;
>+      }
>+    }
So you still have this debugging code here without any ifdefs or anything.
Attachment #8755448 - Flags: review?(bugs) → review-
Attached patch stop.patchSplinter Review
Attachment #8755448 - Attachment is obsolete: true
Attachment #8755725 - Flags: review?(bugs)
Comment on attachment 8755725 [details] [diff] [review]
stop.patch

I wonder if a helper method to take the mCanceled value safely would have been nice.
Attachment #8755725 - Flags: review?(bugs) → review+
Whiteboard: btpp-active
Pushed by amarchesini@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/0fdbb035fd12
Stop GetFilesHelper runnable when the operation is canceled, r=smaug
https://hg.mozilla.org/mozilla-central/rev/0fdbb035fd12
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: