summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/mmap.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-08-06 15:53:50 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-08-06 15:53:50 +0200
commit700616ab8792227768cd73aa28eb69b8010ac90a (patch)
tree9630cb40d10e13708d724f49cc14787cc86a9a94 /apt-pkg/contrib/mmap.cc
parentb9c917bd62e7b1eb227d4f3a7321559ddb96e494 (diff)
parent4caf8231804dfce5a1a58a56dfe4df21a31be363 (diff)
merged from david
Diffstat (limited to 'apt-pkg/contrib/mmap.cc')
-rw-r--r--apt-pkg/contrib/mmap.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index 3e6ef3520..a176da636 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -156,11 +156,10 @@ bool MMap::Close(bool DoSync)
/* This is done in syncronous mode - the docs indicate that this will
not return till all IO is complete */
bool MMap::Sync()
-{
+{
if ((Flags & UnMapped) == UnMapped)
return true;
-
-#ifdef _POSIX_SYNCHRONIZED_IO
+
if ((Flags & ReadOnly) != ReadOnly)
{
if (SyncToFd != NULL)
@@ -170,11 +169,12 @@ bool MMap::Sync()
}
else
{
+#ifdef _POSIX_SYNCHRONIZED_IO
if (msync((char *)Base, iSize, MS_SYNC) < 0)
return _error->Errno("msync", _("Unable to synchronize mmap"));
+#endif
}
}
-#endif
return true;
}
/*}}}*/
@@ -185,9 +185,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
{
if ((Flags & UnMapped) == UnMapped)
return true;
-
-#ifdef _POSIX_SYNCHRONIZED_IO
- unsigned long long PSize = sysconf(_SC_PAGESIZE);
+
if ((Flags & ReadOnly) != ReadOnly)
{
if (SyncToFd != 0)
@@ -198,11 +196,13 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
}
else
{
+#ifdef _POSIX_SYNCHRONIZED_IO
+ unsigned long long const PSize = sysconf(_SC_PAGESIZE);
if (msync((char *)Base+(unsigned long long)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0)
return _error->Errno("msync", _("Unable to synchronize mmap"));
+#endif
}
}
-#endif
return true;
}
/*}}}*/