external/onlineupdate/lo.patch |   13 +++++++++++++
 1 file changed, 13 insertions(+)

New commits:
commit 5bb295c263803fbf39562aa7e95f8d32a77ac854
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Tue Jan 23 14:20:51 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Jan 24 11:33:55 2024 +0100

    MAR update, too big to (not) fail
    
    On Windows, when a MAR update generated by create-partial-info contains very
    many patches (as easily happens with LibreOffice), applying it would fail 
with
    "failed: 7" (aka WRITE_ERROR, see
    
workdir/UnpackedTarball/onlineupdate/onlineupdate/source/update/common/updatererror.h)
    because in
    
workdir/UnpackedTarball/onlineupdate/onlineupdate/source/update/updater/updater.cpp
    PatchFile::mPatchStream holds open one FILE instance per patch from
    PatchFile::Prepare to PatchFile::Execute (and which can't easily be reworked
    because of the Lock/UnlockFile done on the underlying HANDLE "so it can't be
    messed with [in] between"), so calling NS_tfopen in PatchFile::Prepare will
    eventually start to fail with EMFILE.
    
    To avoid that, try to raise the limit to its maximum (but don't fail 
immediately
    if that fails, in case the given MAR update wouldn't run into the issue of 
too
    many patches, anyway), and keep fingers crossed.  (See
    
<https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio?view=msvc-170>
    "_setmaxstdio" for details:  "By default, up to 512 files can be open
    simultaneously at the stream I/O level.  This level includes files opened 
and
    accessed using the fopen, fgetc, and fputc family of functions.  The limit 
of
    512 open files at the stream I/O level can be increased to a maximum of 
8,192 by
    use of the _setmaxstdio function.")
    
    Change-Id: I6b3499f0f6c2060628418a15f5e36021bfe7dd18
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162442
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>
    (cherry picked from commit 4582da4ad473e256975c86054033eb7d238d464e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162455
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    (cherry picked from commit dec29bf4c7844d6cc3231b93ca1bb56243caabfe)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162459
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/external/onlineupdate/lo.patch b/external/onlineupdate/lo.patch
index 870857b7ba46..14b2a9a2dec3 100644
--- a/external/onlineupdate/lo.patch
+++ b/external/onlineupdate/lo.patch
@@ -223,6 +223,19 @@
        LOG_WARN(("Install directory updater could not be determined."));
        result = FALSE;
      }
+--- onlineupdate/source/update/updater/updater.cpp
++++ onlineupdate/source/update/updater/updater.cpp
+@@ -4174,6 +4174,10 @@
+         NS_tmkdir(gDeleteDirPath, 0755);
+       }
+     }
++
++    if (_setmaxstdio(8192) == -1) {
++        LOG(("_setmaxstdio failed"));
++    }
+ #endif /* XP_WIN */
+ 
+     // Run update process on a background thread. ShowProgressUI may return
 --- tools/update-packaging/common.sh
 +++ tools/update-packaging/common.sh
 @@ -76,6 +76,15 @@

Reply via email to