[openoffice.org/f13/master] Resolves: rhbz#601621 avoid using mmap for copying files
Caolan McNamara
caolanm at fedoraproject.org
Mon Aug 9 08:26:26 UTC 2010
commit 11495ddeb6c9393137064a0d778e5d341ab1cd18
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Aug 9 09:26:18 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 3ae5d45..e751550 100644
--- a/openoffice.org.spec
+++ b/openoffice.org.spec
@@ -1,6 +1,6 @@
%define oootag OOO320
%define ooomilestone 12
-%define rh_rpm_release 28
+%define rh_rpm_release 29
# rhbz#465664 jar-repacking breaks help by reordering META-INF/MANIFEST.MF
%define __jar_repack %{nil}
@@ -169,6 +169,7 @@ Patch98: openoffice.org-3.3.0.ooo113117.extensions.broken.scanner.shutdown.patch
Patch99: workspace.findbar01.patch
Patch100: workspace.cmcfixes77.patch
Patch101: openoffice.org-3.2.0.ooo113400.canvas.fix-scaling.patch
+Patch102: 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}
@@ -1768,6 +1769,7 @@ cp -p %{SOURCE5} external/unowinreg/unowinreg.dll
%patch99 -p1 -b .workspace.findbar01.patch
%patch100 -p1 -b .workspace.cmcfixes77.patch
%patch101 -p1 -b .ooo113400.canvas.fix-scaling.patch
+%patch102 -p0 -b .ooo106591.sal.tradcopy.patch
%build
echo build start time is `date`, diskspace: `df -h . | tail -n 1`
@@ -4253,6 +4255,9 @@ fi
%endif
%changelog
+* Mon Aug 09 2010 Caolán McNamara <caolanm at redhat.com> - 1:3.2.0-12.29
+- Resolves: rhbz#601621 avoid using mmap for copying files
+
* Sun Aug 08 2010 Caolán McNamara <caolanm at redhat.com> - 1:3.2.0-12.28
- 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