[openoffice.org/f14/master] Resolves: rhbz#601621 avoid using mmap for copying files
Caolan McNamara
caolanm at fedoraproject.org
Mon Aug 9 08:28:30 UTC 2010
commit 1379b6e6fdfd86d162bbe3ee8c6b0bab06ed6cd8
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Aug 9 09:28:25 2010 +0100
Resolves: rhbz#601621 avoid using mmap for copying files
openoffice.org-3.3.0.ooo106591.sal.tradcopy.patch | 83 +++++++++++++++++++++
openoffice.org.spec | 7 ++-
2 files changed, 89 insertions(+), 1 deletions(-)
---
diff --git a/openoffice.org-3.3.0.ooo106591.sal.tradcopy.patch b/openoffice.org-3.3.0.ooo106591.sal.tradcopy.patch
new file mode 100644
index 0000000..6e85962
--- /dev/null
+++ b/openoffice.org-3.3.0.ooo106591.sal.tradcopy.patch
@@ -0,0 +1,83 @@
+diff -ru sal.orig/osl/unx/file_misc.cxx sal/osl/unx/file_misc.cxx
+--- sal.orig/osl/unx/file_misc.cxx 2010-08-09 09:13:30.000000000 +0100
++++ sal/osl/unx/file_misc.cxx 2010-08-09 09:21:21.000000000 +0100
+@@ -1022,66 +1022,29 @@
+ return nRet;
+ }
+
+- /* HACK: because memory mapping fails on various
+- platforms if the size of the source file is 0 byte */
+- if (0 == nSourceSize)
+- {
+- close(SourceFileFD);
+- close(DestFileFD);
+- return 0;
+- }
+-
+- // read and lseek are used to check the possibility to access the data
+- // not a nice solution, but it allows to avoid a crash in case it is an opened samba file
+- // generally, reading of one byte should not affect the performance
+- char nCh;
+- if ( 1 != read( SourceFileFD, &nCh, 1 )
+- || -1 == lseek( SourceFileFD, 0, SEEK_SET ) )
+- {
+- nRet = errno;
+- close( SourceFileFD );
+- close( DestFileFD );
+- return nRet;
+- }
+-
+ size_t nWritten = 0;
+ size_t nRemains = nSourceSize;
+
+- /* mmap file -- open dest file -- write -- fsync it at the end */
+- void* pSourceFile = mmap( 0, nSourceSize, PROT_READ, MAP_SHARED, SourceFileFD, 0 );
+- if ( pSourceFile != MAP_FAILED )
+- {
+- nWritten = write( DestFileFD, pSourceFile, nSourceSize );
+- nRemains -= nWritten;
+- munmap( (char*)pSourceFile, nSourceSize );
+- }
+-
+ if ( nRemains )
+ {
+ /* mmap has problems, try the direct streaming */
+- char pBuffer[32000];
++ char pBuffer[0x7FFF];
+ size_t nRead = 0;
+
+- nRemains = nSourceSize;
+-
+- if ( -1 != lseek( SourceFileFD, 0, SEEK_SET )
+- && -1 != lseek( DestFileFD, 0, SEEK_SET ) )
++ do
+ {
+- do
+- {
+- nRead = 0;
+- nWritten = 0;
+-
+- size_t nToRead = std::min( (size_t)32000, nRemains );
+- nRead = read( SourceFileFD, pBuffer, nToRead );
+- if ( (size_t)-1 != nRead )
+- nWritten = write( DestFileFD, pBuffer, nRead );
+-
+- if ( (size_t)-1 != nWritten )
+- nRemains -= nWritten;
+- }
+- while( nRemains && (size_t)-1 != nRead && nRead == nWritten );
++ nRead = 0;
++ nWritten = 0;
++
++ size_t nToRead = std::min( sizeof(pBuffer), nRemains );
++ nRead = read( SourceFileFD, pBuffer, nToRead );
++ if ( (size_t)-1 != nRead )
++ nWritten = write( DestFileFD, pBuffer, nRead );
++
++ if ( (size_t)-1 != nWritten )
++ nRemains -= nWritten;
+ }
++ while( nRemains && (size_t)-1 != nRead && nRead == nWritten );
+ }
+
+ if ( nRemains )
diff --git a/openoffice.org.spec b/openoffice.org.spec
index ad7cbd3..20cf2ba 100644
--- a/openoffice.org.spec
+++ b/openoffice.org.spec
@@ -1,6 +1,6 @@
%define oootag OOO330
%define ooomilestone 3
-%define rh_rpm_release 1
+%define rh_rpm_release 2
# rhbz#465664 jar-repacking breaks help by reordering META-INF/MANIFEST.MF
%define __jar_repack %{nil}
@@ -112,6 +112,7 @@ Patch35: workspace.sb126.patch
Patch36: workspace.vcl114.patch
Patch37: openoffice.org-3.3.0.ooo113273.desktop.resolvelinks.patch
Patch38: openoffice.org-gccXXXXX.idlc.patch
+Patch39: openoffice.org-3.3.0.ooo106591.sal.tradcopy.patch
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%define instdir %{_libdir}
@@ -1638,6 +1639,7 @@ cp -p %{SOURCE5} external/unowinreg/unowinreg.dll
%patch36 -p0 -b .workspace.vcl114.patch
%patch37 -p0 -b .ooo113273.desktop.resolvelinks.patch
%patch38 -p1 -b .gccXXXXX.idlc.patch
+%patch39 -p0 -b .ooo106591.sal.tradcopy.patch
%build
echo build start time is `date`, diskspace: `df -h . | tail -n 1`
@@ -3779,6 +3781,9 @@ unopkg remove --shared org.openoffice.legacy.ScriptProviderForPython.zip > /dev/
%endif
%changelog
+* Mon Aug 09 2010 Caolán McNamara <caolanm at redhat.com> - 1:3.3.0-3.2
+- Resolves: rhbz#601621 avoid using mmap for copying files
+
* Sat Aug 07 2010 Caolán McNamara <caolanm at redhat.com> - 1:3.3.0-3.1
- Resolves: rhbz#621248 32bit events in forms on 64bit
- Resolves: rhbz#618047 Brackets incorrectly render in presentations
More information about the scm-commits
mailing list