summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2004-09-21 20:33:16 +0000
committerbala <balanatarajan@users.noreply.github.com>2004-09-21 20:33:16 +0000
commit150a728d458794b6f4db45bbaaf13af7ad32d704 (patch)
tree88871f1fea6ecf07cf728447f87c05f3540014b1
parent1d9b58f2f209e7a09cb299500dde3797ca375722 (diff)
downloadATCD-150a728d458794b6f4db45bbaaf13af7ad32d704.tar.gz
ChangeLogTag:Tue Sep 21 20:31:43 2004 Balachandran Natarajan <bala@dre.vanderbilt.edu>
-rw-r--r--TAO/ChangeLog9
-rw-r--r--TAO/orbsvcs/orbsvcs/Log/LogRecordStore_persist.cpp32
-rw-r--r--TAO/orbsvcs/orbsvcs/Log/LogRecordStore_persist.h11
-rw-r--r--TAO/orbsvcs/orbsvcs/Log/PersistStore.cpp27
4 files changed, 47 insertions, 32 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 209972c9b6a..2240c447d23 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,12 @@
+Tue Sep 21 20:31:43 2004 Balachandran Natarajan <bala@dre.vanderbilt.edu>
+
+ * orbsvcs/orbsvcs/Log/LogRecordStore_persist.cpp:
+ * orbsvcs/orbsvcs/Log/LogRecordStore_persist.h:
+ * orbsvcs/orbsvcs/Log/PersistStore.cpp:
+
+ Applied patches to Logging service provided by
+ Thomas Girard <thomas dot g dot girard at free.fr>.
+
Tue Sep 21 07:19:29 2004 J.T. Conklin <jtc@acorntoolworks.com>
* tao/Makefile.am:
diff --git a/TAO/orbsvcs/orbsvcs/Log/LogRecordStore_persist.cpp b/TAO/orbsvcs/orbsvcs/Log/LogRecordStore_persist.cpp
index 1b109770505..b986270cb33 100644
--- a/TAO/orbsvcs/orbsvcs/Log/LogRecordStore_persist.cpp
+++ b/TAO/orbsvcs/orbsvcs/Log/LogRecordStore_persist.cpp
@@ -1,8 +1,9 @@
-#include "orbsvcs/Log/LogRecordStore_persist.h"
+#include "orbsvcs/orbsvcs/Log/LogRecordStore_persist.h"
-#include "orbsvcs/Time_Utilities.h"
-#include "orbsvcs/Log/Log_Constraint_Interpreter.h"
-#include "orbsvcs/Log/Log_Constraint_Visitors.h"
+#include "orbsvcs/orbsvcs/Time_Utilities.h"
+#include "orbsvcs/orbsvcs/Log/Log_Constraint_Interpreter.h"
+#include "orbsvcs/orbsvcs/Log/Log_Constraint_Visitors.h"
+#include "ace/OS_NS_sys_time.h"
ACE_RCSID (Log,
LogRecordStore_persist,
@@ -30,7 +31,7 @@ TAO_LogRecordStore::~TAO_LogRecordStore (void)
int
TAO_LogRecordStore::open (void)
-{
+{
// Open the persistent store supplying a filename.
sprintf (this->file_name_, "%s.%d", PERSISTENT_LOG_FILE_NAME, logid_);
@@ -159,7 +160,7 @@ TAO_LogRecordStore::remove (DsLogAdmin::RecordId id)
int
TAO_LogRecordStore::purge_old_records (void)
{
- CORBA::ULongLong num_records_to_purge = (this->num_records_) * ( (CORBA::ULongLong) 5 / (CORBA::ULongLong)100 );
+ CORBA::ULongLong num_records_to_purge = this->num_records_ * 5U / 100U;
if (num_records_to_purge < 1)
num_records_to_purge = 1;
@@ -169,24 +170,23 @@ TAO_LogRecordStore::purge_old_records (void)
CORBA::ULong count = 0; // count of matches found.
if (num_records_to_purge > 0 )
- {
- for (CORBA::ULong i = 0; i < num_records_to_purge; ++i)
{
- if (iter.next (hash_entry) == -1 || iter.advance () == -1)
+ for (CORBA::ULongLong i = 0; i < num_records_to_purge; ++i)
{
- break;
- }
+ if (iter.next (hash_entry) == -1 || iter.advance () == -1)
+ break;
- if (this->remove (hash_entry->int_id_.id) == 0)
- count++;
+ if (this->remove (hash_entry->int_id_.id) == 0)
+ count++;
+ }
}
- }
+
return count;
}
-TAO_LogRecordStore::LOG_RECORD_STORE&
+TAO_LogRecordStore::LOG_RECORD_STORE &
TAO_LogRecordStore::get_storage (void)
{
return rec_hash_;
@@ -206,7 +206,6 @@ template class ACE_Hash_Map_Iterator_Base_Ex<DsLogAdmin::RecordId, DsLogAdmin::L
template class ACE_Hash_Map_Reverse_Iterator<DsLogAdmin::RecordId,DsLogAdmin::LogRecord,ACE_Null_Mutex>;
template class ACE_Hash_Map_Reverse_Iterator_Ex<DsLogAdmin::RecordId, DsLogAdmin::LogRecord, ACE_Hash<DsLogAdmin::RecordId>,
ACE_Equal_To<DsLogAdmin::RecordId>, ACE_Null_Mutex>;
-template class ACE_Equal_To<DsLogAdmin::RecordId>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
@@ -222,6 +221,5 @@ ACE_Equal_To<DsLogAdmin::RecordId>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Reverse_Iterator<DsLogAdmin::RecordId,DsLogAdmin::LogRecord,ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<DsLogAdmin::RecordId, DsLogAdmin::LogRecord, ACE_Hash<DsLogAdmin::RecordId>,
ACE_Equal_To<DsLogAdmin::RecordId>, ACE_Null_Mutex>
-#pragma instantiate ACE_Equal_To<DsLogAdmin::RecordId>
#endif /* ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA */
diff --git a/TAO/orbsvcs/orbsvcs/Log/LogRecordStore_persist.h b/TAO/orbsvcs/orbsvcs/Log/LogRecordStore_persist.h
index 0cac5583e9d..b9c6239025c 100644
--- a/TAO/orbsvcs/orbsvcs/Log/LogRecordStore_persist.h
+++ b/TAO/orbsvcs/orbsvcs/Log/LogRecordStore_persist.h
@@ -30,6 +30,7 @@
#include "orbsvcs/DsLogAdminC.h"
#include "ace/Containers.h"
#include "ace/Hash_Map_Manager.h"
+#include "ace/Null_Mutex.h"
#include "log_serv_export.h"
#include "PersistStore.h"
@@ -60,7 +61,7 @@ class TAO_Log_Serv_Export TAO_LogRecordStore
= LOG_DEFAULT_MAX_REC_LIST_LEN);
/// Destructor.
- ~LogRecordStore (void);
+ ~TAO_LogRecordStore (void);
/// Initialization.
int open (void);
@@ -92,7 +93,7 @@ class TAO_Log_Serv_Export TAO_LogRecordStore
/// id. Returns 0 on success, -1 on failure.
int retrieve (DsLogAdmin::RecordId id, DsLogAdmin::LogRecord &rec);
- /// update into storage. Returns 0 on success -1 on failure.
+ /// Update into storage. Returns 0 on success -1 on failure.
int update (DsLogAdmin::LogRecord &rec);
/// Remove the record with id <id> from the LogRecordStore. Returns 0 on
@@ -117,7 +118,7 @@ class TAO_Log_Serv_Export TAO_LogRecordStore
/// Get the underlying storage.
/// @@ return a const ref? we don't want anyone to modify the storage.
- LogRecordStore::LOG_RECORD_STORE& get_storage (void);
+ TAO_LogRecordStore::LOG_RECORD_STORE& get_storage (void);
protected:
@@ -142,10 +143,10 @@ class TAO_Log_Serv_Export TAO_LogRecordStore
CORBA::ULong max_rec_list_len_;
/// The persistence storage.
- PersistStore persist_store_;
+ TAO_PersistStore persist_store_;
/// The hash of LogRecord ids to LogRecord 's.
- LogRecordStore::LOG_RECORD_HASH_MAP rec_hash_;
+ TAO_LogRecordStore::LOG_RECORD_HASH_MAP rec_hash_;
/// Persistent log file name.
char file_name_[256];
diff --git a/TAO/orbsvcs/orbsvcs/Log/PersistStore.cpp b/TAO/orbsvcs/orbsvcs/Log/PersistStore.cpp
index 89e7127cfa0..9f86c6da948 100644
--- a/TAO/orbsvcs/orbsvcs/Log/PersistStore.cpp
+++ b/TAO/orbsvcs/orbsvcs/Log/PersistStore.cpp
@@ -40,11 +40,11 @@ TAO_PersistStore::open (const char * file_name)
return -1;
}
- // Open the persistnet log file for reading.
+ // Open the persistent log file for reading.
this->read_persistent_file_ = ACE_OS::open (file_name,
O_RDONLY);
- if (this->write_persistent_file_ == ACE_INVALID_HANDLE) {
+ if (this->read_persistent_file_ == ACE_INVALID_HANDLE) {
perror ("open:read");
return -1;
}
@@ -93,7 +93,7 @@ TAO_PersistStore::log (DsLogAdmin::LogRecord &rec)
CORBA::TypeCode_ptr tc;
ACE_Message_Block *mb;
struct PersistentData data;
- char *rd_ptr;
+ char *rd_ptr = NULL;
// Check if we are allowed to write...
if (max_size_ !=0 && current_size_ >= max_size_)
@@ -114,11 +114,16 @@ TAO_PersistStore::log (DsLogAdmin::LogRecord &rec)
mb = rec.info._tao_get_cdr (); // TAO extension
data.byte_order = rec.info._tao_byte_order ();
- // Get a pointer to the actual data in the ACE_Message_Block.
- rd_ptr = mb->rd_ptr ();
+ if (mb != NULL) {
+ // Get a pointer to the actual data in the ACE_Message_Block.
+ rd_ptr = mb->rd_ptr ();
- // Get the size of the actual data in the ACE_Message_Block.
- data.mb_size = mb->length ();
+ // Get the size of the actual data in the ACE_Message_Block.
+ data.mb_size = mb->length ();
+ } else {
+ ACE_DEBUG((LM_INFO, "Skipped empty Any\n"));
+ data.mb_size = 0;
+ }
// Store the first chunk of persistent data.
// Get the kind of the CORBA::Any stored in the record.
@@ -134,9 +139,11 @@ TAO_PersistStore::log (DsLogAdmin::LogRecord &rec)
ACE_OS::write (this->write_persistent_file_, (void*) tc, sizeof (CORBA::TypeCode));
this->current_size_ += sizeof (CORBA::TypeCode);
- // Write the actual message block data to the file.
- ACE_OS::write (this->write_persistent_file_, (void*) rd_ptr, data.mb_size);
- this->current_size_ += data.mb_size;
+ if (rd_ptr != NULL) {
+ // Write the actual message block data to the file.
+ ACE_OS::write (this->write_persistent_file_, (void*) rd_ptr, data.mb_size);
+ this->current_size_ += data.mb_size;
+ }
// Unlock the mutex
write_lock_.release();