diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-12-20 22:53:49 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-12-20 22:53:49 +0000 |
commit | a2c044ea9363f445053317de8913887d1db05a14 (patch) | |
tree | 0de1d87f1db0ac7411f93ef8a71172bd0e019c93 | |
parent | dcf6bb9e58ba7a98dc54484e2dfe51961f7d8db4 (diff) | |
download | ATCD-a2c044ea9363f445053317de8913887d1db05a14.tar.gz |
*** empty log message ***
-rw-r--r-- | ChangeLog-98a | 27 | ||||
-rw-r--r-- | ace/Malloc.cpp | 4 | ||||
-rw-r--r-- | ace/Malloc.h | 16 | ||||
-rw-r--r-- | ace/Malloc.i | 4 | ||||
-rw-r--r-- | ace/Malloc_T.cpp | 20 | ||||
-rw-r--r-- | ace/Malloc_T.h | 8 | ||||
-rw-r--r-- | ace/Memory_Pool.cpp | 24 | ||||
-rw-r--r-- | ace/README | 1 | ||||
-rw-r--r-- | examples/Shared_Malloc/test_malloc.cpp | 2 | ||||
-rw-r--r-- | examples/Shared_Malloc/test_multiple_mallocs.cpp | 4 | ||||
-rw-r--r-- | include/makeinclude/platform_sunos5_g++.GNU | 4 |
11 files changed, 75 insertions, 39 deletions
diff --git a/ChangeLog-98a b/ChangeLog-98a index eac8abb6264..56c715b2577 100644 --- a/ChangeLog-98a +++ b/ChangeLog-98a @@ -1,8 +1,3 @@ -Sat Dec 20 15:39:00 1997 Nanbor Wang <nw1@merengue.cs.wustl.edu> - - * tests/IOStream_Test.cpp (spawn): Changed ACE_LACKS_EXEC to - ACE_LACKS_FORK. - Sat Dec 20 11:05:45 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> * tests/test_config.h (ACE_INIT_LOG): Added (%P|%t) to an @@ -11,6 +6,28 @@ Sat Dec 20 11:05:45 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> * tests/IOStream_Test.cpp (spawn): Revised the test so that it prints data correctly to the child processes. + * examples/Shared_Malloc/test_multiple_mallocs.cpp (main): Moved + the final print statement inside one of the if blocks so that it + appears only every second invocation to remind people to rerun + the program to remove the leaks. Thanks to Tom Arbuckle + <arbuckle@uran.informatik.uni-bonn.de> for suggesting this. + + * ace/Malloc*: Changed ACE_MALLOC_STATS to ACE_HAS_MALLOC_STATS + since this is more consistent with ACE conventions. Also, + added ACE_HAS_MALLOC_STATS to the ace/README file. Thanks + to Tom Arbuckle <arbuckle@uran.informatik.uni-bonn.de> for + suggesting this. + + * ace/Memory_Pool.cpp (ACE_Shared_Memory_Pool): Fixed the logic + for naming the backing store if the sscanf() call fails. Thanks + to Tom Arbuckle <arbuckle@uran.informatik.uni-bonn.de> for + suggesting this. + +Sat Dec 20 15:39:00 1997 Nanbor Wang <nw1@merengue.cs.wustl.edu> + + * tests/IOStream_Test.cpp (spawn): Changed ACE_LACKS_EXEC to + ACE_LACKS_FORK. + Sat Dec 20 09:42:06 1997 David L. Levine <levine@cs.wustl.edu> * ace/OS.h: changed ACE_SEH_FINALLY to be if (1) on Unix, not diff --git a/ace/Malloc.cpp b/ace/Malloc.cpp index 47560815f54..4e9e78e552e 100644 --- a/ace/Malloc.cpp +++ b/ace/Malloc.cpp @@ -119,7 +119,7 @@ ACE_Allocator::~ACE_Allocator (void) ACE_TRACE ("ACE_Allocator::~ACE_Allocator"); } -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) ACE_Malloc_Stats::ACE_Malloc_Stats (void) : nblocks_ (0), nchunks_ (0), @@ -152,5 +152,5 @@ template class ACE_Atomic_Op<ACE_PROCESS_MUTEX, int>; #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ #endif /* ACE_MALLOC_C */ diff --git a/ace/Malloc.h b/ace/Malloc.h index 624a3020f5c..23f10c6e68d 100644 --- a/ace/Malloc.h +++ b/ace/Malloc.h @@ -110,10 +110,10 @@ public: // Change the protection of the pages of the mapped region to <prot> // starting at <addr> up to <len> bytes. -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) virtual void print_stats (void) const = 0; // Dump statistics of how malloc is behaving. -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ virtual void dump (void) const = 0; // Dump the state of the object. @@ -126,7 +126,7 @@ private: // Must delete the <allocator_> if non-0. }; -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) #include "ace/Synch_T.h" #if defined (ACE_HAS_THREADS) #define ACE_PROCESS_MUTEX ACE_Process_Mutex @@ -156,7 +156,7 @@ struct ACE_Export ACE_Malloc_Stats #define AMS(X) X #else #define AMS(X) -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ // ACE_MALLOC_ALIGN allows you to insure that allocated regions are at least // <ACE_MALLOC_ALIGN> bytes long. It is especially useful when you want @@ -234,7 +234,7 @@ public: char lock_name_[MAXNAMELEN]; // Name of lock thats ensures mutual exclusion. -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) // Keep statistics about ACE_Malloc state and performance. ACE_Malloc_Stats malloc_stats_; #define ACE_CONTROL_BLOCK_SIZE ((int)(sizeof (ACE_Name_Node *) \ @@ -245,7 +245,7 @@ public: #define ACE_CONTROL_BLOCK_SIZE ((int)(sizeof(ACE_Name_Node *) \ + sizeof (ACE_Malloc_Header *) \ + MAXNAMELEN)) -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ // Notice the casting to int for sizeof() otherwise unsigned int // arithmetic is used and some awful things may happen. @@ -291,9 +291,9 @@ public: virtual int sync (void *addr, size_t len, int flags = MS_SYNC); virtual int protect (ssize_t len = -1, int prot = PROT_RDWR); virtual int protect (void *addr, size_t len, int prot = PROT_RDWR); -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) virtual void print_stats (void) const; -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ virtual void dump (void) const; }; diff --git a/ace/Malloc.i b/ace/Malloc.i index ba4b34d51b7..2b342124313 100644 --- a/ace/Malloc.i +++ b/ace/Malloc.i @@ -97,12 +97,12 @@ ACE_New_Allocator::protect (void *, size_t, int) return -1; } -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) ACE_INLINE void ACE_New_Allocator::print_stats (void) const { } -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ ACE_INLINE void ACE_New_Allocator::dump (void) const diff --git a/ace/Malloc_T.cpp b/ace/Malloc_T.cpp index 837d6347e29..2ebcd4fc868 100644 --- a/ace/Malloc_T.cpp +++ b/ace/Malloc_T.cpp @@ -47,14 +47,14 @@ ACE_Allocator_Adapter<MALLOC>::~ACE_Allocator_Adapter (void) ACE_TRACE ("ACE_Allocator_Adapter<MALLOC>::~ACE_Allocator_Adapter"); } -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) template <class MALLOC> void ACE_Allocator_Adapter<MALLOC>::print_stats (void) const { ACE_TRACE ("ACE_Malloc<MALLOC>::print_stats"); this->allocator_.print_stats (); } -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ template <class MALLOC> void ACE_Allocator_Adapter<MALLOC>::dump (void) const @@ -72,13 +72,13 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::dump (void) const this->memory_pool_.dump (); ACE_DEBUG ((LM_DEBUG, "cb_ptr_ = %x", this->cb_ptr_)); ACE_DEBUG ((LM_DEBUG, "\n")); -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) this->cp_ptr_->malloc_stats_.dump (); -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) template <ACE_MEM_POOL_1, class ACE_LOCK> void ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::print_stats (void) const @@ -101,7 +101,7 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::print_stats (void) const break; } } -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ // Put block AP in the free list (locked version). @@ -140,11 +140,11 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::open (void) { // ACE_DEBUG ((LM_DEBUG, "(%P|%t) first time in, control block = %u\n", this->cb_ptr_)); -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) // Call the constructor on the ACE_LOCK, using the placement // operator! new ((void *) &this->cb_ptr_->malloc_stats_) ACE_Malloc_Stats; -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ // Initialize the freelist pointer to point to the dummy // ACE_Malloc_Header. @@ -230,9 +230,9 @@ ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::remove (void) // ACE_DEBUG ((LM_DEBUG, "(%P|%t) destroying ACE_Malloc\n")); int result = 0; -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) this->print_stats (); -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ // Remove the ACE_LOCK. this->lock_.remove (); diff --git a/ace/Malloc_T.h b/ace/Malloc_T.h index 1f0926741b2..65203da9df3 100644 --- a/ace/Malloc_T.h +++ b/ace/Malloc_T.h @@ -187,10 +187,10 @@ public: ALLOCATOR &alloc (void); // Returns the underlying allocator. -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) virtual void print_stats (void) const; // Dump statistics of how malloc is behaving. -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ virtual void dump (void) const; // Dump the state of the object. @@ -335,10 +335,10 @@ public: // @return function returns the number of chunks of the given size // that would fit in the currently allocated memory. -#if defined (ACE_MALLOC_STATS) +#if defined (ACE_HAS_MALLOC_STATS) void print_stats (void) const; // Dump statistics of how malloc is behaving. -#endif /* ACE_MALLOC_STATS */ +#endif /* ACE_HAS_MALLOC_STATS */ void dump (void) const; // Dump the state of an object. diff --git a/ace/Memory_Pool.cpp b/ace/Memory_Pool.cpp index 63f38892969..721be55956e 100644 --- a/ace/Memory_Pool.cpp +++ b/ace/Memory_Pool.cpp @@ -615,10 +615,26 @@ ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool (LPCTSTR backing_store_name, this->minimum_bytes_ = options->minimum_bytes_; } - if (backing_store_name) - // Convert the string into a number that is used as the segment key. - ::sscanf (backing_store_name, "%d", &this->base_shm_key_); - else + if (backing_store_name) + { + // Convert the string into a number that is used as the segment + // key. + + int result = ::sscanf (backing_store_name, + "%d", + &this->base_shm_key_); + + if (result == 0 || result == EOF) + // The conversion to a number failed so hash with crc32 + // ACE::crc32 is also used in <SV_Semaphore_Simple>. + this->base_shm_key_ = (key_t) ACE::crc32 (backing_store_name); + + if (this->base_shm_key_ == IPC_PRIVATE) + // Make sure that the segment can be shared between unrelated + // processes. + this->base_shm_key_ = ACE_DEFAULT_SHM_KEY; + } + else this->base_shm_key_ = ACE_DEFAULT_SHM_KEY; if (this->signal_handler_.register_handler (SIGSEGV, this) == -1) diff --git a/ace/README b/ace/README index 29b0d18409a..38636245825 100644 --- a/ace/README +++ b/ace/README @@ -85,6 +85,7 @@ ACE_HAS_LIMITED_RUSAGE_T The rusage_t structure has only two fields. ACE_HAS_LONGLONG_T Compiler/platform supports the "long long" datatype. ACE_HAS_LONG_FDMASK Compiler/platform has typedef u_long fdmask (e.g., Linux). ACE_HAS_LONG_MAP_FAILED Platform defines MAP_FAILED as a long constant. +ACE_HAS_MALLOC_STATS Enabled malloc statistics collection. ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION Avoid #including ace/streams.h in OS.h. Users must include ace/streams.h, <iostream>, or <iostream.h> explicitly in their code. Some platforms, such as g++/VxWorks, have trouble compiling templates and iostreams header because of static variables in the stream headers. This flag will also avoid extra compilation and runtime overheads on some platforms. ACE_HAS_MFC Platform supports Microsoft Foundation Classes ACE_HAS_MSG Platform supports recvmsg and sendmsg diff --git a/examples/Shared_Malloc/test_malloc.cpp b/examples/Shared_Malloc/test_malloc.cpp index 845f168ad5e..db5afd283d8 100644 --- a/examples/Shared_Malloc/test_malloc.cpp +++ b/examples/Shared_Malloc/test_malloc.cpp @@ -29,6 +29,8 @@ malloc_recurse (int count) if (count <= 0) { if (Options::instance ()->debug ()) + // Note that you'll need to #define ACE_HAS_MALLOC_STATS in + // the main ACE config.h file and remake ACE to enable this. AMS (Malloc::instance ()->print_stats ()); } else diff --git a/examples/Shared_Malloc/test_multiple_mallocs.cpp b/examples/Shared_Malloc/test_multiple_mallocs.cpp index abfc5193135..0c8daeeaf2c 100644 --- a/examples/Shared_Malloc/test_multiple_mallocs.cpp +++ b/examples/Shared_Malloc/test_multiple_mallocs.cpp @@ -59,9 +59,9 @@ main (int, char *[]) data = shmem_response->malloc (ACE_OS::strlen (RESPONSE_STRING) + 1); ACE_OS::strcpy ((char *) data, RESPONSE_STRING); shmem_response->bind ("foo", data); - } - ACE_OS::printf ("Run again to see results and release resources.\n"); + ACE_OS::printf ("Run again to see results and release resources.\n"); + } return 0; } diff --git a/include/makeinclude/platform_sunos5_g++.GNU b/include/makeinclude/platform_sunos5_g++.GNU index 456bc054d26..bb08fa70b22 100644 --- a/include/makeinclude/platform_sunos5_g++.GNU +++ b/include/makeinclude/platform_sunos5_g++.GNU @@ -5,8 +5,8 @@ debug = 1 optimize = 1 -CC = gcc -CXX = g++ +CC = gcc +CXX = g++ CFLAGS += -Wall -Wpointer-arith -pipe #### -Winline CCFLAGS += $(CFLAGS) -fno-implicit-templates DCFLAGS += -g |