[Fawkes Git] branch/timn/clips-protobuf-cleanup: created (0.5.0-3369-gae6f9ea)

Tim Niemueller niemueller at kbsg.rwth-aachen.de
Tue Oct 11 16:56:41 CEST 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, timn/clips-protobuf-cleanup has been created
        at  ae6f9ea96ce59d35a9f9a601df34121e0b45b65c (commit)

http://git.fawkesrobotics.org/fawkes.git/timn/clips-protobuf-cleanup

- *Log* ---------------------------------------------------------------
commit c8b8b0a2c37477a4af802e2907b87b23c6be44a5
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Tue Oct 11 16:52:52 2016 +0200
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Tue Oct 11 16:52:52 2016 +0200

    clips-protobuf: destroy messages on cleanup
    
    Messages were not properly destroyed when no longer used resulting in a
    memory leak. The protobuf-msg facts were retrated, but the related
    pointer was not destroyed. Thanks to Frederik Zwilling for catching
    this!
    
    There used to be automatic cleanup code in the very first iteration of
    this code. It registered to the periodic signal and used a map of
    asserted facts for each message. If a fact was retracted (and thus no
    longer referenced by anyone else) the message could be deleted. The code
    had not been updated when moving this code into its own library already
    back in the llsf-refbox (in fact, the handle_periodic_signals() is still
    there in the refbox).

http://git.fawkesrobotics.org/fawkes.git/commit/c8b8b0a
http://trac.fawkesrobotics.org/changeset/c8b8b0a

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit ae6f9ea96ce59d35a9f9a601df34121e0b45b65c
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Tue Oct 11 16:55:32 2016 +0200
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Tue Oct 11 16:55:32 2016 +0200

    protobuf_clips: remove unused map of message facts
    
    The map was used for automatic cleanup in the old days, but the code to
    do the actual cleanup was not ported. Since this can be handled with
    less code, fewer callbacks, and more obvious on the CLIPS side we do it
    there.

http://git.fawkesrobotics.org/fawkes.git/commit/ae6f9ea
http://trac.fawkesrobotics.org/changeset/ae6f9ea

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/libs/protobuf_clips/communicator.cpp |    6 ++----
 src/libs/protobuf_clips/communicator.h   |    3 ---
 2 files changed, 2 insertions(+), 7 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* c8b8b0a2c37477a4af802e2907b87b23c6be44a5 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Tue Oct 11 16:52:52 2016 +0200
Subject: clips-protobuf: destroy messages on cleanup

 src/plugins/clips-protobuf/clips/protobuf.clp |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/clips-protobuf/clips/protobuf.clp b/src/plugins/clips-protobuf/clips/protobuf.clp
index bc3131e..fbb42ba 100644
--- a/src/plugins/clips-protobuf/clips/protobuf.clp
+++ b/src/plugins/clips-protobuf/clips/protobuf.clp
@@ -61,8 +61,9 @@
 
 (defrule protobuf-cleanup-message
   (declare (salience -4000))
-  ?pf <- (protobuf-msg)
+  ?pf <- (protobuf-msg (ptr ?p))
   =>
+	(pb-destroy ?p)
   (retract ?pf)
 )
 

- *commit* ae6f9ea96ce59d35a9f9a601df34121e0b45b65c - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Tue Oct 11 16:55:32 2016 +0200
Subject: protobuf_clips: remove unused map of message facts

 src/libs/protobuf_clips/communicator.cpp |    6 ++----
 src/libs/protobuf_clips/communicator.h   |    3 ---
 2 files changed, 2 insertions(+), 7 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/protobuf_clips/communicator.cpp b/src/libs/protobuf_clips/communicator.cpp
index f3a3171..6872d92 100644
--- a/src/libs/protobuf_clips/communicator.cpp
+++ b/src/libs/protobuf_clips/communicator.cpp
@@ -972,11 +972,9 @@ ClipsProtobufCommunicator::clips_assert_message(std::pair<std::string, unsigned
     fact->set_slot("ptr", CLIPS::Value(ptr));
     CLIPS::Fact::pointer new_fact = clips_->assert_fact(fact);
 
-    if (new_fact) {
-      msg_facts_[new_fact->index()] = new_fact;
-    } else {
+    if (! new_fact) {
       if (logger_) {
-	logger_->log_warn("CLIPS-Protobuf", "Asserting protobuf-msg fact failed");
+	      logger_->log_warn("CLIPS-Protobuf", "Asserting protobuf-msg fact failed");
       }
       delete static_cast<std::shared_ptr<google::protobuf::Message> *>(ptr);
     }
diff --git a/src/libs/protobuf_clips/communicator.h b/src/libs/protobuf_clips/communicator.h
index e549826..780b4b9 100644
--- a/src/libs/protobuf_clips/communicator.h
+++ b/src/libs/protobuf_clips/communicator.h
@@ -209,9 +209,6 @@ class ClipsProtobufCommunicator
 
   std::map<long int, std::pair<std::string, unsigned short>> client_endpoints_;
 
-  std::map<long int, CLIPS::Fact::pointer>  msg_facts_;
-
-
   std::list<std::string>  functions_;
   CLIPS::Fact::pointer    avail_fact_;
 };




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list