projects
/
apt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* Implement EDSP in libapt-pkg so that all front-ends which
[apt.git]
/
apt-pkg
/
contrib
/
mmap.cc
diff --git
a/apt-pkg/contrib/mmap.cc
b/apt-pkg/contrib/mmap.cc
index aa184b13022cb3f9ddd654ac8fbe1c565eb1bc3a..19381ae4719ea7005ac338463bdbe7e4a5e3cd95 100644
(file)
--- a/
apt-pkg/contrib/mmap.cc
+++ b/
apt-pkg/contrib/mmap.cc
@@
-106,7
+106,7
@@
bool MMap::Map(FileFd &Fd)
/* */
bool MMap::Close(bool DoSync)
{
/* */
bool MMap::Close(bool DoSync)
{
- if ((Flags & UnMapped) == UnMapped ||
Base == 0
|| iSize == 0)
+ if ((Flags & UnMapped) == UnMapped ||
validData() == false
|| iSize == 0)
return true;
if (DoSync == true)
return true;
if (DoSync == true)
@@
-237,11
+237,19
@@
DynamicMMap::DynamicMMap(unsigned long Flags,unsigned long const &WorkSpace,
if ((this->Flags & Fallback) != Fallback) {
// Set the permissions.
int Prot = PROT_READ;
if ((this->Flags & Fallback) != Fallback) {
// Set the permissions.
int Prot = PROT_READ;
+#ifdef MAP_ANONYMOUS
int Map = MAP_PRIVATE | MAP_ANONYMOUS;
int Map = MAP_PRIVATE | MAP_ANONYMOUS;
+#else
+ int Map = MAP_PRIVATE | MAP_ANON;
+#endif
if ((this->Flags & ReadOnly) != ReadOnly)
Prot |= PROT_WRITE;
if ((this->Flags & Public) == Public)
if ((this->Flags & ReadOnly) != ReadOnly)
Prot |= PROT_WRITE;
if ((this->Flags & Public) == Public)
+#ifdef MAP_ANONYMOUS
Map = MAP_SHARED | MAP_ANONYMOUS;
Map = MAP_SHARED | MAP_ANONYMOUS;
+#else
+ Map = MAP_SHARED | MAP_ANON;
+#endif
// use anonymous mmap() to get the memory
Base = (unsigned char*) mmap(0, WorkSpace, Prot, Map, -1, 0);
// use anonymous mmap() to get the memory
Base = (unsigned char*) mmap(0, WorkSpace, Prot, Map, -1, 0);
@@
-266,6
+274,8
@@
DynamicMMap::~DynamicMMap()
{
if (Fd == 0)
{
{
if (Fd == 0)
{
+ if (validData() == false)
+ return;
#ifdef _POSIX_MAPPED_FILES
munmap(Base, WorkSpace);
#else
#ifdef _POSIX_MAPPED_FILES
munmap(Base, WorkSpace);
#else
@@
-398,6
+408,8
@@
bool DynamicMMap::Grow() {
if (Limit != 0 && WorkSpace >= Limit)
return _error->Error(_("Unable to increase the size of the MMap as the "
"limit of %lu bytes is already reached."), Limit);
if (Limit != 0 && WorkSpace >= Limit)
return _error->Error(_("Unable to increase the size of the MMap as the "
"limit of %lu bytes is already reached."), Limit);
+ if (GrowFactor <= 0)
+ return _error->Error(_("Unable to increase size of the MMap as automatic growing is disabled by user."));
unsigned long const newSize = WorkSpace + GrowFactor;
unsigned long const newSize = WorkSpace + GrowFactor;