Closed Bug 290371 Opened 20 years ago Closed 20 years ago

OnDataAvailable called again after returning an error

Categories

(Core :: Networking, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.8beta2

People

(Reporter: tommi.komulainen, Assigned: Biesinger)

Details

Attachments

(1 file, 1 obsolete file)

Originally reported to GNOME bugzilla as
http://bugzilla.gnome.org/show_bug.cgi?id=300591

Galeon code was written based on the guarantee (hi biesi) that OnDataAvailable()
will not be called again if we return an error code from there once.  But
apparently it is.

What we have is roughly as follows (complete code can be found at
http://cvs.gnome.org/viewcvs/galeon/mozilla/mozilla-embed-persist.cpp?view=markup
 , look for GStreamListener::OnDataAvailable)

channel = ioService->NewChannel ("http://www.publisite.com/favicon.ico");
listener = new MyListener(...);
channel->AsyncOpen(listener, nsnull);

MyListener::OnDataAvailable(...)
{
  rv = aInputStream->ReadSegments (MyReaderFunc, ...);
  NS_ENSURE_SUCCESS(rv, rv);
  return NS_ERROR_FAILURE;
}

MyReaderFunc()
{
  return NS_ERROR_FAILURE;
}
Severity: normal → major
Attached patch patch (obsolete) — Splinter Review
- don't call OnDataAvailable again if the first ODA or OnStartRequest failed
- ensure that we always call OnStartRequest
Assignee: darin → cbiesinger
Status: NEW → ASSIGNED
Attachment #180889 - Flags: review?(darin)
OS: Linux → All
Priority: -- → P1
Hardware: PC → All
Target Milestone: --- → mozilla1.8beta2
Version: 1.7 Branch → Trunk
Comment on attachment 180889 [details] [diff] [review]
patch

hmm... shouldn't the nsUnknownDecoder's OnDataAvailable check for errors
returned by FireListenerNotifications?	If it is failing, then calling
OnDataAvailable on the real listener seems like a bad idea to me.
isn't that exactly what the first part of this patch does...?
Comment on attachment 180889 [details] [diff] [review]
patch

>Index: netwerk/streamconv/converters/nsUnknownDecoder.cpp

>+  // Must not fire ODA again if it failed once
>+  if (aCount && NS_SUCCEEDED(rv)) {

yup... that's what i was looking for and yet i missed it somehow :-/


>+  if (NS_FAILED(rv)) {
>+    request->Cancel(rv);
>+    mNextListener->OnStartRequest(request, aCtxt);
>     return rv;
>+  }

so, the explicit call to Cancel is needed so that the status of the
request is set appropriately when mNextListener checks it.  please
document this.	It took me a few moments to realize that that was
what was going on.


> 
>   // Fire the OnStartRequest(...)
>   rv = mNextListener->OnStartRequest(request, aCtxt);
> 
>+  if (!mBuffer) return NS_ERROR_OUT_OF_MEMORY;

what is the concern here?  it seems to me that we check mBuffer in
OnDataAvailable before calling FireListenerNotifications, so why is
this necessary again?  are you concerned about what mNextListener
might do?
(In reply to comment #4)
> >+  if (!mBuffer) return NS_ERROR_OUT_OF_MEMORY;
> 
> what is the concern here?

I just moved that line. It used to be near the top of this function. The reason
I moved it is that I want to ensure that we always call OnStartRequest, and this
seemed to be the easiest way to do that.
Attachment #180889 - Attachment is obsolete: true
Attachment #181165 - Flags: review?(darin)
Attachment #181165 - Flags: review?(darin) → review+
Attachment #181165 - Flags: superreview?(bzbarsky)
Attachment #181165 - Flags: superreview?(bzbarsky) → superreview+
Comment on attachment 181165 [details] [diff] [review]
patch v2: comment added

this would be good to have... it basically makes sure that a return value is
checked, and that OnStartRequest is called in some error circumstances. it
should be low risk.
Attachment #181165 - Flags: approval1.8b2?
Comment on attachment 181165 [details] [diff] [review]
patch v2: comment added

a=asa
Attachment #181165 - Flags: approval1.8b2? → approval1.8b2+
Checking in netwerk/streamconv/converters/nsUnknownDecoder.cpp;
/cvsroot/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp,v  <-- 
nsUnknownDecoder.cpp
new revision: 1.65; previous revision: 1.64
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: