Bug 1409768 - Don't call fsync repeatedly when printing; r?bobowen draft
authorAlex Gaynor <agaynor@mozilla.com>
Wed, 25 Oct 2017 14:16:12 -0400 (2017-10-25)
changeset 686316 44c2df32bb2c91d33029686789fe5aa5ec69b7db
parent 686074 dfb54d604158f5605fb07f41751e36bfef641a2f
child 737351 74549819abb5902a68901be9b0e5b55ccba92511
push id86154
push userbmo:agaynor@mozilla.com
push dateWed, 25 Oct 2017 18:16:30 +0000 (2017-10-25)
reviewersbobowen
bugs1409768
milestone58.0a1
Bug 1409768 - Don't call fsync repeatedly when printing; r?bobowen Usage of sync was a mistake when porting from the previous std::ostream code. MozReview-Commit-ID: HwbFVlZMu6t
layout/printing/DrawEventRecorder.h
--- a/layout/printing/DrawEventRecorder.h
+++ b/layout/printing/DrawEventRecorder.h
@@ -28,29 +28,27 @@ public:
     mFd = nullptr;
   }
 
   bool IsOpen() {
     return mFd != nullptr;
   }
 
   void Flush() {
-    // We need to be API compatible with std::ostream, and so we silently handle
-    // flushes on a closed FD.
-    if (IsOpen()) {
-      PR_Sync(mFd);
-    }
+    // For std::ostream this flushes any internal buffers. PRFileDesc's IO isn't
+    // buffered, so nothing to do here.
   }
 
   void Seek(PRInt32 aOffset, PRSeekWhence aWhence) {
     PR_Seek(mFd, aOffset, aWhence);
   }
 
   void write(const char* aData, size_t aSize) {
-    // See comment in Flush().
+    // We need to be API compatible with std::ostream, and so we silently handle
+    // writes on a closed FD.
     if (IsOpen()) {
       PR_Write(mFd, static_cast<const void*>(aData), aSize);
     }
   }
 
   void read(char* aOut, size_t aSize) {
     PRInt32 res = PR_Read(mFd, static_cast<void*>(aOut), aSize);
     mGood = res >= 0 && ((size_t)res == aSize);