Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_MMAP_Memory_Pool Class Reference

Make a memory pool that is based on <mmap(2)>. This implementation allows memory to be shared between processes. More...

#include <Memory_Pool.h>

Inheritance diagram for ACE_MMAP_Memory_Pool:

Inheritance graph
[legend]
Collaboration diagram for ACE_MMAP_Memory_Pool:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_MMAP_Memory_Pool_Options OPTIONS

Public Methods

 ACE_MMAP_Memory_Pool (const ACE_TCHAR *backing_store_name=0, const OPTIONS *options=0)
 Initialize the pool. More...

virtual ~ACE_MMAP_Memory_Pool (void)
 Destructor. More...

virtual void * init_acquire (size_t nbytes, size_t &rounded_bytes, int &first_time)
 Ask system for initial chunk of shared memory. More...

virtual void * acquire (size_t nbytes, size_t &rounded_bytes)
virtual int release (int destroy=1)
 Instruct the memory pool to release all of its resources. More...

virtual int sync (ssize_t len=-1, int flags=MS_SYNC)
 Sync the memory region to the backing store starting at <this->base_addr_>. More...

virtual int sync (void *addr, size_t len, int flags=MS_SYNC)
 Sync the memory region to the backing store starting at <addr_>. More...

virtual int protect (ssize_t len=-1, int prot=PROT_RDWR)
virtual int protect (void *addr, size_t len, int prot=PROT_RDWR)
 Change the protection of the pages of the mapped region to <prot> starting at <addr> up to <len> bytes. More...

virtual int seh_selector (void *)
virtual int remap (void *addr)
virtual void * base_addr (void) const
 Return the base address of this memory pool. More...

virtual void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Methods

virtual size_t round_up (size_t nbytes)
 Implement the algorithm for rounding up the request to an appropriate chunksize. More...

virtual int commit_backing_store_name (size_t rounded_bytes, off_t &map_size)
 Compute the new <map_size> of the backing store and commit the memory. More...

virtual int map_file (off_t map_size)
 Memory map the file up to <map_size> bytes. More...

virtual int handle_signal (int signum, siginfo_t *, ucontext_t *)
 Handle SIGSEGV and SIGBUS signals to remap shared memory properly. More...


Protected Attributes

ACE_Sig_Handler signal_handler_
 Handles SIGSEGV. More...

ACE_Mem_Map mmap_
 Memory-mapping object. More...

void * base_addr_
int use_fixed_addr_
 Must we use the <base_addr_> or can we let mmap(2) select it? More...

int flags_
 Flags passed into <ACE_OS::mmap>. More...

int write_each_page_
 Should we write a byte to each page to forceably allocate memory for this backing store? More...

off_t minimum_bytes_
 What the minimum bytes of the initial segment should be. More...

ACE_TCHAR backing_store_name_ [MAXPATHLEN+1]
 Name of the backing store where the shared memory pool is kept. More...

int guess_on_fault_
LPSECURITY_ATTRIBUTES sa_
 Security attributes object, only used on NT. More...

mode_t file_mode_
 Protection mode for mmaped file. More...


Detailed Description

Make a memory pool that is based on <mmap(2)>. This implementation allows memory to be shared between processes.

Definition at line 478 of file Memory_Pool.h.


Member Typedef Documentation

typedef ACE_MMAP_Memory_Pool_Options ACE_MMAP_Memory_Pool::OPTIONS
 

Definition at line 481 of file Memory_Pool.h.

Referenced by ACE_Configuration_Heap::open.


Constructor & Destructor Documentation

ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool const ACE_TCHAR   backing_store_name = 0,
const OPTIONS   options = 0
 

Initialize the pool.

Definition at line 157 of file Memory_Pool.cpp.

References ACE_DEFAULT_FILE_PERMS, ACE_ERROR, ACE_LIB_TEXT, ACE_SET_BITS, ACE_TCHAR, ACE_TRACE, ACE_MMAP_Memory_Pool_Options::ALWAYS_FIXED, backing_store_name_, base_addr_, file_mode_, flags_, ACE_Lib_Find::get_temp_dir, guess_on_fault_, LM_ERROR, MAP_FIXED, MAP_SHARED, MAXPATHLEN, minimum_bytes_, ACE_Sig_Handler::register_handler, sa_, signal_handler_, SIGSEGV, ACE_OS_String::strcat, ACE_OS_String::strcpy, ACE_OS_String::strsncpy, use_fixed_addr_, and write_each_page_.

00159   : base_addr_ (0),
00160     use_fixed_addr_(0),
00161     flags_ (MAP_SHARED),
00162     write_each_page_ (0),
00163     minimum_bytes_ (0),
00164     sa_ (0),
00165     file_mode_ (ACE_DEFAULT_FILE_PERMS)
00166 {
00167   ACE_TRACE ("ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool");
00168 
00169 #if (defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)) || defined (ACE_WIN32)
00170       // For plaforms that give the faulting address.
00171       guess_on_fault_ = 0;
00172 #else
00173       // For plaforms that do NOT give the faulting address, let the
00174       // options decide whether to guess or not.
00175       if (options)
00176         guess_on_fault_ = options->guess_on_fault_;
00177       else
00178         // If no options are specified, default to true.
00179         guess_on_fault_ = 1;
00180 #endif /* (defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)) || defined (ACE_WIN32) */
00181 
00182   // Only change the defaults if <options> != 0.
00183   if (options)
00184     {
00185       if (options->flags_ != 0)
00186         this->flags_ = options->flags_;
00187       use_fixed_addr_ = options->use_fixed_addr_;
00188 
00189       if (use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::ALWAYS_FIXED)
00190         {
00191           this->base_addr_ = ACE_const_cast (void *, options->base_addr_);
00192           ACE_SET_BITS (flags_, MAP_FIXED);
00193         }
00194       this->write_each_page_ = options->write_each_page_;
00195       this->minimum_bytes_ = options->minimum_bytes_;
00196       if (options->sa_ != 0)
00197         this->sa_ = options->sa_;
00198       this->file_mode_ = options->file_mode_;
00199     }
00200 
00201   if (backing_store_name == 0)
00202     {
00203       // Only create a new unique filename for the backing store file
00204       // if the user didn't supply one...
00205 #if defined (ACE_DEFAULT_BACKING_STORE)
00206       // Create a temporary file.
00207       ACE_OS::strcpy (this->backing_store_name_,
00208                       ACE_DEFAULT_BACKING_STORE);
00209 #else /* ACE_DEFAULT_BACKING_STORE */
00210       if (ACE_Lib_Find::get_temp_dir (this->backing_store_name_,
00211                                       MAXPATHLEN - 17) == -1)
00212         // -17 for ace-malloc-XXXXXX
00213         {
00214           ACE_ERROR ((LM_ERROR,
00215                       ACE_LIB_TEXT ("Temporary path too long, ")
00216                       ACE_LIB_TEXT ("defaulting to current directory\n")));
00217           this->backing_store_name_[0] = 0;
00218         }
00219 
00220       // Add the filename to the end
00221       ACE_OS::strcat (this->backing_store_name_,
00222                       ACE_LIB_TEXT ("ace-malloc-XXXXXX"));
00223 
00224 #endif /* ACE_DEFAULT_BACKING_STORE */
00225     }
00226   else
00227     ACE_OS::strsncpy (this->backing_store_name_,
00228                       backing_store_name,
00229                       (sizeof this->backing_store_name_ / sizeof (ACE_TCHAR)));
00230 
00231 #if !defined (ACE_WIN32) && !defined (CHORUS)
00232   if (this->signal_handler_.register_handler (SIGSEGV, this) == -1)
00233     ACE_ERROR ((LM_ERROR,
00234                 "%p\n", this->backing_store_name_));
00235 #endif /* ACE_WIN32 */
00236 }

ACE_INLINE ACE_MMAP_Memory_Pool::~ACE_MMAP_Memory_Pool void    [virtual]
 

Destructor.

Definition at line 46 of file Memory_Pool.i.

00047 {
00048 }


Member Function Documentation

void * ACE_MMAP_Memory_Pool::acquire size_t    nbytes,
size_t &    rounded_bytes
[virtual]
 

Acquire at least <nbytes> from the memory pool. <rounded_bytes> is the actual number of bytes allocated. Also acquires an internal semaphore that ensures proper serialization of <ACE_MMAP_Memory_Pool> initialization across processes.

Definition at line 342 of file Memory_Pool.cpp.

References ACE_TRACE, ACE_Mem_Map::addr, commit_backing_store_name, map_file, mmap_, round_up, and ACE_Mem_Map::size.

Referenced by init_acquire.

00344 {
00345   ACE_TRACE ("ACE_MMAP_Memory_Pool::acquire");
00346   rounded_bytes = this->round_up (nbytes);
00347 
00348   // ACE_DEBUG ((LM_DEBUG, "(%P|%t) acquiring more chunks, nbytes =
00349   // %d, rounded_bytes = %d\n", nbytes, rounded_bytes));
00350 
00351   off_t map_size;
00352 
00353   if (this->commit_backing_store_name (rounded_bytes,
00354                                        map_size) == -1)
00355     return 0;
00356   else if (this->map_file (map_size) == -1)
00357     return 0;
00358 
00359   // ACE_DEBUG ((LM_DEBUG, "(%P|%t) acquired more chunks, nbytes = %d,
00360   // rounded_bytes = %d, map_size = %d\n", nbytes, rounded_bytes,
00361   // map_size));
00362 
00363   return (void *) ((char *) this->mmap_.addr () + (this->mmap_.size () - rounded_bytes));
00364 }

ACE_INLINE void * ACE_MMAP_Memory_Pool::base_addr void    const [virtual]
 

Return the base address of this memory pool.

Definition at line 63 of file Memory_Pool.i.

References ACE_TRACE, and base_addr_.

00064 {
00065   ACE_TRACE ("ACE_MMAP_Memory_Pool::base_addr");
00066   return this->base_addr_;
00067 }

int ACE_MMAP_Memory_Pool::commit_backing_store_name size_t    rounded_bytes,
off_t &    map_size
[protected, virtual]
 

Compute the new <map_size> of the backing store and commit the memory.

Definition at line 241 of file Memory_Pool.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, ACE_OS::lseek, round_up, ACE_OS::write, and write_each_page_.

Referenced by acquire.

00243 {
00244   ACE_TRACE ("ACE_MMAP_Memory_Pool::commit_backing_store_name");
00245 
00246 #if defined (CHORUS)
00247   map_size = rounded_bytes;
00248 #else
00249   size_t seek_len;
00250 
00251   if (this->write_each_page_)
00252     // Write to the end of every block to ensure that we have enough
00253     // space in the backing store.
00254     seek_len = this->round_up (1); // round_up(1) is one page.
00255   else
00256     // We're willing to risk it all in the name of efficiency...
00257     seek_len = rounded_bytes;
00258 
00259   // The following loop will execute multiple times (if
00260   // this->write_each_page == 1) or just once (if
00261   // this->write_each_page == 0).
00262 
00263   for (size_t cur_block = 0;
00264        cur_block < rounded_bytes;
00265        cur_block += seek_len)
00266     {
00267       map_size = ACE_OS::lseek (this->mmap_.handle (),
00268                                 ACE_static_cast (off_t, seek_len - 1),
00269                                 SEEK_END);
00270 
00271       if (map_size == -1
00272           || ACE_OS::write (this->mmap_.handle (),
00273                             "",
00274                             1) == -1)
00275         ACE_ERROR_RETURN ((LM_ERROR,
00276                            ACE_LIB_TEXT ("(%P|%t) %p\n"),
00277                            this->backing_store_name_),
00278                           -1);
00279     }
00280 
00281   // Increment by one to put us at the beginning of the next chunk...
00282   map_size++;
00283 #endif /* CHORUS */
00284   return 0;
00285 }

void ACE_MMAP_Memory_Pool::dump void    const [virtual]
 

Dump the state of an object.

Definition at line 90 of file Memory_Pool.cpp.

References ACE_TRACE.

00091 {
00092   ACE_TRACE ("ACE_MMAP_Memory_Pool::dump");
00093 }

int ACE_MMAP_Memory_Pool::handle_signal int    signum,
siginfo_t  ,
ucontext_t  
[protected, virtual]
 

Handle SIGSEGV and SIGBUS signals to remap shared memory properly.

Reimplemented from ACE_Event_Handler.

Definition at line 494 of file Memory_Pool.cpp.

References ACE_OS::filesize, map_file, mmap_, remap, ACE_Sig_Handler::remove_handler, signal_handler_, SIGSEGV, ACE_Mem_Map::size, and ucontext_t.

00495 {
00496   if (signum != SIGSEGV)
00497     return -1;
00498   else
00499     ; // ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%P|%t) received %S\n"), signum));
00500 
00501   // ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%P|%t) new mapping address = %u\n"), (char *) this->base_addr_ + current_map_size));
00502 
00503 #if defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)
00504   // Make sure that the pointer causing the problem is within the
00505   // range of the backing store.
00506 
00507   if (siginfo != 0)
00508     {
00509       // ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%P|%t) si_signo = %d, si_code = %d, addr = %u\n"), siginfo->si_signo, siginfo->si_code, siginfo->si_addr));
00510       if (this->remap ((void *) siginfo->si_addr) == -1)
00511         return -1;
00512       // ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) address %u out of range\n",
00513       // siginfo->si_addr), -1);
00514       return 0;
00515     }
00516 #else
00517   ACE_UNUSED_ARG(siginfo);
00518 #endif /* ACE_HAS_SIGINFO_T && !defined ACE_LACKS_SI_ADDR */
00519   // If guess_on_fault_ is true, then we want to try to remap without
00520   // knowing the faulting address.  guess_on_fault_ can only be true
00521   // on platforms that do not provide the faulting address through
00522   // signals or exceptions.  We check to see if the mapping is up to
00523   // date. If it is, then this fault isn't due to this mapping and we
00524   // pass it on.
00525   if (guess_on_fault_)
00526     {
00527       // Check if the current mapping is up to date.
00528       off_t current_map_size = ACE_OS::filesize (this->mmap_.handle ());
00529 
00530       if (ACE_static_cast (size_t, current_map_size) == this->mmap_.size ())
00531         {
00532           // The mapping is up to date so this really is a bad
00533           // address.  Thus, remove current signal handler so process
00534           // will fail with default action and core file will be
00535           // written.
00536           this->signal_handler_.remove_handler (SIGSEGV);
00537           return 0;
00538         }
00539 
00540       // Extend the mapping to cover the size of the backing store.
00541       return this->map_file (current_map_size);
00542     }
00543   else
00544     return -1;
00545 }

void * ACE_MMAP_Memory_Pool::init_acquire size_t    nbytes,
size_t &    rounded_bytes,
int &    first_time
[virtual]
 

Ask system for initial chunk of shared memory.

Definition at line 369 of file Memory_Pool.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, acquire, ACE_Mem_Map::addr, LM_ERROR, ACE_Mem_Map::map, minimum_bytes_, mmap_, ACE_Mem_Map::open, and PROT_RDWR.

00372 {
00373   ACE_TRACE ("ACE_MMAP_Memory_Pool::init_acquire");
00374 
00375   first_time = 0;
00376 
00377   if (nbytes < (size_t) this->minimum_bytes_)
00378     nbytes = this->minimum_bytes_;
00379 
00380   if (this->mmap_.open (this->backing_store_name_,
00381                         O_RDWR | O_CREAT | O_TRUNC | O_EXCL,
00382                         this->file_mode_, this->sa_) != -1)
00383     {
00384       // First time in, so need to acquire memory.
00385       first_time = 1;
00386       return this->acquire (nbytes, rounded_bytes);
00387     }
00388   else if (errno == EEXIST)
00389     {
00390       errno = 0;
00391       // Reopen file *without* using O_EXCL...
00392       if (this->mmap_.map (this->backing_store_name_,
00393 #if defined (CHORUS)
00394                            nbytes,
00395 #else
00396                            -1,
00397 #endif /* CHORUS */
00398                            O_RDWR,
00399                            this->file_mode_,
00400                            PROT_RDWR,
00401                            this->flags_,
00402                            this->base_addr_,
00403                            0,
00404                            this->sa_) == -1)
00405         ACE_ERROR_RETURN ((LM_ERROR,
00406                            ACE_LIB_TEXT ("%p\n"),
00407                            ACE_LIB_TEXT ("open")),
00408                           0);
00409 
00410       return this->mmap_.addr ();
00411     }
00412   else
00413     ACE_ERROR_RETURN ((LM_ERROR,
00414                        ACE_LIB_TEXT ("%p\n"),
00415                        ACE_LIB_TEXT ("open")),
00416                       0);
00417 }

int ACE_MMAP_Memory_Pool::map_file off_t    map_size [protected, virtual]
 

Memory map the file up to <map_size> bytes.

Definition at line 290 of file Memory_Pool.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, ACE_Mem_Map::addr, backing_store_name_, base_addr_, ACE_Singleton::instance, LM_ERROR, ACE_Mem_Map::map, mmap_, ACE_MMAP_Memory_Pool_Options::NEVER_FIXED, PROT_RDWR, ACE_Mem_Map::unmap, and use_fixed_addr_.

Referenced by acquire, handle_signal, and remap.

00291 {
00292   ACE_TRACE ("ACE_MMAP_Memory_Pool::map_file");
00293 
00294   // Unmap the existing mapping.
00295   this->mmap_.unmap ();
00296 
00297 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00298   if(use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::NEVER_FIXED)
00299     this->base_addr_ = 0;
00300 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
00301 
00302   // Remap the file.
00303   if (this->mmap_.map (map_size,
00304                        PROT_RDWR,
00305                        this->flags_,
00306                        this->base_addr_,
00307                        0,
00308                        this->sa_) == -1
00309       || this->base_addr_ != 0
00310 #ifdef ACE_HAS_WINCE
00311       && this->mmap_.addr () == 0)  // WinCE does not allow users to specify alloc addr.
00312 #else
00313       && this->mmap_.addr () != this->base_addr_)
00314 #endif  // ACE_HAS_WINCE
00315     {
00316 #if 0
00317       ACE_ERROR ((LM_ERROR,
00318                   ACE_LIB_TEXT ("(%P|%t) addr = %u, base_addr = %u, map_size = %u, %p\n"),
00319                   this->mmap_.addr (),
00320                   this->base_addr_,
00321                   map_size,
00322                   this->backing_store_name_));
00323 #endif /* 0 */
00324       return -1;
00325     }
00326   else
00327     {
00328 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00329       this->base_addr_ = this->mmap_.addr ();
00330       ACE_BASED_POINTER_REPOSITORY::instance ()->bind (this->base_addr_,
00331                                                        map_size);
00332 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
00333       return 0;
00334     }
00335 }

int ACE_MMAP_Memory_Pool::protect void *    addr,
size_t    len,
int    prot = PROT_RDWR
[virtual]
 

Change the protection of the pages of the mapped region to <prot> starting at <addr> up to <len> bytes.

Definition at line 151 of file Memory_Pool.cpp.

References ACE_TRACE, and ACE_OS::mprotect.

00152 {
00153   ACE_TRACE ("ACE_MMAP_Memory_Pool::protect");
00154   return ACE_OS::mprotect (addr, len, prot);
00155 }

int ACE_MMAP_Memory_Pool::protect ssize_t    len = -1,
int    prot = PROT_RDWR
[virtual]
 

Change the protection of the pages of the mapped region to <prot> starting at <this->base_addr_> up to <len> bytes. If <len> == -1 then change protection of all pages in the mapped region.

Definition at line 137 of file Memory_Pool.cpp.

References ACE_TRACE, ACE_OS::lseek, mmap_, ACE_Mem_Map::protect, and ssize_t.

00138 {
00139   ACE_TRACE ("ACE_MMAP_Memory_Pool::protect");
00140 
00141   if (len < 0)
00142     len = ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END);
00143 
00144   return this->mmap_.protect (len, prot);
00145 }

int ACE_MMAP_Memory_Pool::release int    destroy = 1 [virtual]
 

Instruct the memory pool to release all of its resources.

Definition at line 96 of file Memory_Pool.cpp.

References ACE_TRACE, ACE_Mem_Map::close, ACE_Singleton::instance, mmap_, and ACE_Mem_Map::remove.

00097 {
00098   ACE_TRACE ("ACE_MMAP_Memory_Pool::release");
00099 
00100 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00101   ACE_BASED_POINTER_REPOSITORY::instance ()->unbind (this->mmap_.addr ());
00102 #endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1 */
00103 
00104   if (destroy)
00105   this->mmap_.remove ();
00106   else
00107     this->mmap_.close ();
00108   return 0;
00109 }

int ACE_MMAP_Memory_Pool::remap void *    addr [virtual]
 

Try to extend the virtual address space so that <addr> is now covered by the address mapping. The method succeeds and returns 0 if the backing store has adequate memory to cover this address. Otherwise, it returns -1. This method is typically called by a UNIX signal handler for SIGSEGV or a Win32 structured exception when another process has grown the backing store (and its mapping) and our process now incurs a fault because our mapping isn't in range (yet).

Definition at line 439 of file Memory_Pool.cpp.

References ACE_TRACE, ACE_Mem_Map::addr, ACE_OS::filesize, map_file, and mmap_.

Referenced by handle_signal, and seh_selector.

00440 {
00441   ACE_TRACE ("ACE_MMAP_Memory_Pool::remap");
00442   //  ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("Remapping with fault address at: %X\n"), addr));
00443   off_t current_map_size = ACE_OS::filesize (this->mmap_.handle ());
00444   // ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END);
00445 
00446   if (!(addr < (void *) ((char *) this->mmap_.addr () + current_map_size)
00447         && addr >= this->mmap_.addr ()))
00448     return -1;
00449 
00450   // Extend the mapping to cover the size of the backing store.
00451   return this->map_file (current_map_size);
00452 }

ACE_INLINE size_t ACE_MMAP_Memory_Pool::round_up size_t    nbytes [protected, virtual]
 

Implement the algorithm for rounding up the request to an appropriate chunksize.

Definition at line 56 of file Memory_Pool.i.

References ACE_TRACE, and ACE::round_to_pagesize.

Referenced by acquire, and commit_backing_store_name.

00057 {
00058   ACE_TRACE ("ACE_MMAP_Memory_Pool::round_up");
00059   return ACE::round_to_pagesize (ACE_static_cast (off_t, nbytes));
00060 }

int ACE_MMAP_Memory_Pool::seh_selector void *    [virtual]
 

Win32 Structural exception selector. The return value decides how to handle memory pool related structural exceptions. Returns 1, 0, or , -1.

Definition at line 421 of file Memory_Pool.cpp.

References remap.

00422 {
00423   DWORD ecode = ((EXCEPTION_POINTERS *) ep)->ExceptionRecord->ExceptionCode;
00424 
00425   if (ecode == EXCEPTION_ACCESS_VIOLATION)
00426     {
00427       void * fault_addr = (void *)
00428         ((EXCEPTION_POINTERS *) ep)->ExceptionRecord->ExceptionInformation[1];
00429 
00430       if (this->remap (fault_addr) == 0)
00431         return 1;
00432     }
00433 
00434   return 0;
00435 }

int ACE_MMAP_Memory_Pool::sync void *    addr,
size_t    len,
int    flags = MS_SYNC
[virtual]
 

Sync the memory region to the backing store starting at <addr_>.

Reimplemented in ACE_Lite_MMAP_Memory_Pool.

Definition at line 126 of file Memory_Pool.cpp.

References ACE_TRACE, and ACE_OS::msync.

00127 {
00128   ACE_TRACE ("ACE_MMAP_Memory_Pool::sync");
00129   return ACE_OS::msync (addr, len, flags);
00130 }

int ACE_MMAP_Memory_Pool::sync ssize_t    len = -1,
int    flags = MS_SYNC
[virtual]
 

Sync the memory region to the backing store starting at <this->base_addr_>.

Reimplemented in ACE_Lite_MMAP_Memory_Pool.

Definition at line 112 of file Memory_Pool.cpp.

References ACE_TRACE, ACE_OS::lseek, mmap_, ssize_t, and ACE_Mem_Map::sync.

00113 {
00114   ACE_TRACE ("ACE_MMAP_Memory_Pool::sync");
00115 
00116   if (len < 0)
00117     len = ACE_OS::lseek (this->mmap_.handle (), 0, SEEK_END);
00118 
00119   return this->mmap_.sync (len, flags);
00120 }


Member Data Documentation

ACE_MMAP_Memory_Pool::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 555 of file Memory_Pool.h.

ACE_TCHAR ACE_MMAP_Memory_Pool::backing_store_name_[MAXPATHLEN + 1] [protected]
 

Name of the backing store where the shared memory pool is kept.

Definition at line 601 of file Memory_Pool.h.

Referenced by ACE_MMAP_Memory_Pool, and map_file.

void* ACE_MMAP_Memory_Pool::base_addr_ [protected]
 

Base of mapped region. If this has the value of 0 then the OS is free to select any address to map the file, otherwise this value is what the OS must try to use to mmap the file.

Definition at line 585 of file Memory_Pool.h.

Referenced by ACE_MMAP_Memory_Pool, base_addr, and map_file.

mode_t ACE_MMAP_Memory_Pool::file_mode_ [protected]
 

Protection mode for mmaped file.

Definition at line 614 of file Memory_Pool.h.

Referenced by ACE_MMAP_Memory_Pool.

int ACE_MMAP_Memory_Pool::flags_ [protected]
 

Flags passed into <ACE_OS::mmap>.

Definition at line 591 of file Memory_Pool.h.

Referenced by ACE_MMAP_Memory_Pool.

int ACE_MMAP_Memory_Pool::guess_on_fault_ [protected]
 

Try to remap without knowing the faulting address. This parameter is ignored on platforms that know the faulting address (UNIX with SI_ADDR and Win32).

Definition at line 608 of file Memory_Pool.h.

Referenced by ACE_MMAP_Memory_Pool.

off_t ACE_MMAP_Memory_Pool::minimum_bytes_ [protected]
 

What the minimum bytes of the initial segment should be.

Definition at line 598 of file Memory_Pool.h.

Referenced by ACE_MMAP_Memory_Pool, and init_acquire.

ACE_Mem_Map ACE_MMAP_Memory_Pool::mmap_ [protected]
 

Memory-mapping object.

Definition at line 578 of file Memory_Pool.h.

Referenced by acquire, handle_signal, init_acquire, map_file, protect, release, remap, and sync.

LPSECURITY_ATTRIBUTES ACE_MMAP_Memory_Pool::sa_ [protected]
 

Security attributes object, only used on NT.

Definition at line 611 of file Memory_Pool.h.

Referenced by ACE_MMAP_Memory_Pool.

ACE_Sig_Handler ACE_MMAP_Memory_Pool::signal_handler_ [protected]
 

Handles SIGSEGV.

Definition at line 575 of file Memory_Pool.h.

Referenced by ACE_MMAP_Memory_Pool, and handle_signal.

int ACE_MMAP_Memory_Pool::use_fixed_addr_ [protected]
 

Must we use the <base_addr_> or can we let mmap(2) select it?

Definition at line 588 of file Memory_Pool.h.

Referenced by ACE_MMAP_Memory_Pool, and map_file.

int ACE_MMAP_Memory_Pool::write_each_page_ [protected]
 

Should we write a byte to each page to forceably allocate memory for this backing store?

Definition at line 595 of file Memory_Pool.h.

Referenced by ACE_MMAP_Memory_Pool, and commit_backing_store_name.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:50:40 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002