Bug 1470355 - BufferWriter should stop reading data when the wanted amount has been reached, r=michal a=lizzard
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 02 Jul 2018 02:00:00 +0300
changeset 477842 14485670c0795d5ee019aa4a23b69927d5e946eb
parent 477841 e00ac12fb0dad0c257ae278f1feb0c1386c0279d
child 477843 db0c2c7b36318f970b417373d611ad9971c9bf98
push id9444
push userarchaeopteryx@coole-files.de
push dateSat, 07 Jul 2018 21:01:06 +0000
treeherdermozilla-beta@3c8ab5a011e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal, lizzard
bugs1470355
milestone62.0
Bug 1470355 - BufferWriter should stop reading data when the wanted amount has been reached, r=michal a=lizzard
netwerk/base/nsNetUtil.cpp
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -1669,16 +1669,21 @@ private:
             }
 
             // If we succeeded, let's try to read again.
             if (NS_SUCCEEDED(rv)) {
                 mWrittenData += writtenData;
                 if (mCount != -1) {
                     MOZ_ASSERT(mCount >= writtenData);
                     mCount -= writtenData;
+
+                    // Is this the end of the reading?
+                    if (mCount == 0) {
+                        return NS_OK;
+                    }
                 }
 
                 continue;
             }
 
             // Async wait...
             if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
                 rv = MaybeCreateTaskQueue();