diff options
author | jtc <jtc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-11-05 01:52:44 +0000 |
---|---|---|
committer | jtc <jtc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-11-05 01:52:44 +0000 |
commit | 38878eba63008d97ac32bf5aa017d870feecedce (patch) | |
tree | 42bfeae0bce5df0e7b9572502916d732ca8eb14d | |
parent | 5f8a3437ed90b451b706c6831781820018fa1f2f (diff) | |
download | ATCD-38878eba63008d97ac32bf5aa017d870feecedce.tar.gz |
ChangeLogTag: Thu Nov 4 17:42:07 2004 J.T. Conklin <jtc@acorntoolworks.com>
-rw-r--r-- | TAO/ChangeLog | 9 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Log/PersistStore.cpp | 51 |
2 files changed, 37 insertions, 23 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 4ed275c5b3b..51424b1034b 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,12 @@ +Thu Nov 4 17:42:07 2004 J.T. Conklin <jtc@acorntoolworks.com> + + * orbsvcs/orbsvcs/Log/PersistStore.cpp: + + Changed retrieve method to seek past records with non-matching + id's. This avoids memory leaks and is more efficient than the + code it replaced. Thanks to Gary Maxy <gary.maxey@hp.com> for + reporting the problem. + Thu Nov 4 13:51:24 2004 J.T. Conklin <jtc@acorntoolworks.com> * orbsvcs/orbsvcs/Makefile.am: diff --git a/TAO/orbsvcs/orbsvcs/Log/PersistStore.cpp b/TAO/orbsvcs/orbsvcs/Log/PersistStore.cpp index 9f86c6da948..a43bad6b60c 100644 --- a/TAO/orbsvcs/orbsvcs/Log/PersistStore.cpp +++ b/TAO/orbsvcs/orbsvcs/Log/PersistStore.cpp @@ -161,8 +161,6 @@ TAO_PersistStore::log (DsLogAdmin::LogRecord &rec) int TAO_PersistStore::retrieve (DsLogAdmin::RecordId id, DsLogAdmin::LogRecord &rec) { - CORBA::TypeCode_var tc; - char *mb_data = NULL; int retval = -1; struct PersistentData data; @@ -173,40 +171,47 @@ TAO_PersistStore::retrieve (DsLogAdmin::RecordId id, DsLogAdmin::LogRecord &rec) (void*) &data, sizeof (PersistentData)) > 0) { - tc = new CORBA::TypeCode (data.kind); + // Check to see if this id matches. + if (id != data.id) + { + // Skip record + ACE_OS::lseek(this->write_persistent_file_, + sizeof (CORBA::TypeCode) + data.mb_size, + SEEK_CUR); + continue; + } + + CORBA::TypeCode_var tc = new CORBA::TypeCode (data.kind); ACE_OS::read (this->write_persistent_file_, (void*) tc.in (), sizeof (CORBA::TypeCode)); - mb_data = new char[data.mb_size]; + char *mb_data = new char[data.mb_size]; + ACE_OS::read (this->write_persistent_file_, (void*) mb_data, data.mb_size); - // Check to see if this id matches. - if (id == data.id) - { - // Create the message block. - ACE_Message_Block mb2 (mb_data, data.mb_size); + // Create the message block. + ACE_Message_Block mb2 (mb_data, data.mb_size); - // Set the write pointer - mb2.wr_ptr (data.mb_size); + // Set the write pointer + mb2.wr_ptr (data.mb_size); - rec.id = id; - rec.time = data.time; + rec.id = id; + rec.time = data.time; - TAO::Unknown_IDL_Type *unk = 0; - ACE_NEW_RETURN (unk, - TAO::Unknown_IDL_Type (tc.in (), - &mb2, - data.byte_order), - -1); - rec.info.replace (unk); + TAO::Unknown_IDL_Type *unk = 0; + ACE_NEW_RETURN (unk, + TAO::Unknown_IDL_Type (tc.in (), + &mb2, + data.byte_order), + -1); + rec.info.replace (unk); - retval = 1; - break; - } + retval = 1; + break; } return retval; |