Changes have been pushed for the repository "fawkes.git".
(Fawkes Robotics Software Framework)

Clone:  g...@git.fawkesrobotics.org:fawkes.git
Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, thofmann/robot-memory-lock-thread-safety has been created
        at  de94b71d5d66187eb91e3b0a4362e494423f5f74 (commit)

http://git.fawkesrobotics.org/fawkes.git/thofmann/robot-memory-lock-thread-safety

- *Log* ---------------------------------------------------------------
commit de94b71d5d66187eb91e3b0a4362e494423f5f74
Author:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
AuthorDate: Mon Jun 18 01:05:07 2018 -0400
Commit:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
CommitDate: Mon Jun 18 01:05:07 2018 -0400

    robot memory: guard all lock queries with the robot memory mutex
    
    The mongo-cxx-driver is not thread-safe. Therefore, add mutexes to all
    mongo queries to ensure that we never query in multiple threads at once.

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

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


- *Summary* -----------------------------------------------------------


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

- *commit* de94b71d5d66187eb91e3b0a4362e494423f5f74 - - - - - - - - - -
Author:  Till Hofmann <hofm...@kbsg.rwth-aachen.de>
Date:    Mon Jun 18 01:05:07 2018 -0400
Subject: robot memory: guard all lock queries with the robot memory mutex

 src/plugins/robot-memory/robot_memory.cpp |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/robot-memory/robot_memory.cpp 
b/src/plugins/robot-memory/robot_memory.cpp
index e9592ac..d73a883 100644
--- a/src/plugins/robot-memory/robot_memory.cpp
+++ b/src/plugins/robot-memory/robot_memory.cpp
@@ -866,6 +866,7 @@ RobotMemory::mutex_try_lock(const std::string& name,
        update_doc.append("$set", update_set.obj());
 
        try {
+               MutexLocker locker(mutex_);
                BSONObj new_doc =
                        client->findAndModify(cfg_coord_mutex_collection_,
                                              filter_doc.obj(), 
update_doc.obj(),
@@ -883,6 +884,7 @@ RobotMemory::mutex_try_lock(const std::string& name,
       check_doc.append("_id", name);
       check_doc.append("locked", true);
       check_doc.append("locked-by", identity);
+      MutexLocker locker(mutex_);
       BSONObj res_doc  =
         client->findOne(cfg_coord_mutex_collection_, check_doc.obj());
       logger_->log_info(name_, "Checking whether mutex was acquired 
succeeded");
@@ -946,6 +948,7 @@ RobotMemory::mutex_unlock(const std::string& name,
                                                        "lock-time" << true))};
 
        try {
+               MutexLocker locker(mutex_);
                BSONObj new_doc =
                        client->findAndModify(cfg_coord_mutex_collection_,
                                              filter_doc, update_doc,
@@ -996,6 +999,7 @@ RobotMemory::mutex_renew_lock(const std::string& name,
        update_doc.append("$set", update_set.obj());
 
        try {
+               MutexLocker locker(mutex_);
                BSONObj new_doc =
                        client->findAndModify(cfg_coord_mutex_collection_,
                                              filter_doc, update_doc.obj(),
@@ -1077,6 +1081,7 @@ RobotMemory::mutex_expire_locks(float max_age_sec)
        update_doc.append("$set", update_set.obj());
 
        try {
+               MutexLocker locker(mutex_);
                client->update(cfg_coord_mutex_collection_, filter_doc, 
update_doc.obj(),
                               /* upsert */ false, /* multi */ true,
                               &mongo::WriteConcern::majority);




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org
_______________________________________________
fawkes-commits mailing list
fawkes-commits@lists.kbsg.rwth-aachen.de
https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits

Reply via email to