Changes have been pushed for the repository "fawkesrobotics/fawkes".

Clone:  https://github.com/fawkesrobotics/fawkes.git
Gitweb: https://github.com/fawkesrobotics/fawkes

The branch, thofmann/cx-avoid-double-mutex-requests has been created
        at  aee7aa3584df2ac17f15d01f7a30368d0a2d3d42 (commit)

https://github.com/fawkesrobotics/fawkes/tree/thofmann/cx-avoid-double-mutex-requests

- *Log* ---------------------------------------------------------------
commit f683e50874516e06166001743999ae3267f7532b
Author:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
AuthorDate: Sun Nov 8 14:04:50 2020 +0100
Commit:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
CommitDate: Sun Nov 8 14:12:53 2020 +0100

    cx: fast-fail a lock action if the mutex is already locked
    
    We should never call mutex-try-lock-async if the mutex is already
    locked. Similarly, if there is already a pending request, we should not
    send another request. Instead, let the action directly fail.

https://github.com/fawkesrobotics/fawkes/commit/f683e5087

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit ae88f4164034a716294321d54166b76183c557f8
Author:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
AuthorDate: Sun Nov 8 14:13:31 2020 +0100
Commit:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
CommitDate: Sun Nov 8 14:13:31 2020 +0100

    cx: if a mutex is locked without a request, release it again
    
    We may receive a mutex update that a mutex has been locked by us, but we
    do not have a pending request. In this case, release the mutex again.
    
    This should usually not occur, but if it does, it may be fatal, as we
    hold a mutex that we are not aware of.

https://github.com/fawkesrobotics/fawkes/commit/ae88f4164

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit f8cb4a45c2ae8ced1db2c702d7a8a64e043f82d1
Author:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
AuthorDate: Sun Nov 8 14:55:39 2020 +0100
Commit:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
CommitDate: Sun Nov 8 14:55:39 2020 +0100

    cx: refactor mutex trigger processing function
    
    Simplify the response handling by restructuring the conditionals. Also
    move up the response handling so we have the state of the mutex before
    we processed the update. This way, we can distinguish whether the mutex
    was locked before or has just been locked.

https://github.com/fawkesrobotics/fawkes/commit/f8cb4a45c

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit aee7aa3584df2ac17f15d01f7a30368d0a2d3d42
Author:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
AuthorDate: Sun Nov 8 14:59:24 2020 +0100
Commit:     Till Hofmann <hofm...@kbsg.rwth-aachen.de>
CommitDate: Sun Nov 8 14:59:24 2020 +0100

    cx: consistently print all robmem updates to debug
    
    This silences the updates from the wm sync while adding coordination log
    messages to the debug channel.

https://github.com/fawkesrobotics/fawkes/commit/aee7aa358

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


- *Summary* -----------------------------------------------------------
 .../clips-executive/clips/coordination-mutex.clp   | 36 +++++++++++++---------
 .../clips-executive/clips/wm-robmem-sync.clp       |  2 +-
 2 files changed, 23 insertions(+), 15 deletions(-)


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

- *commit* f683e50874516e06166001743999ae3267f7532b - - - - - - - - - -
Author:  Till Hofmann <hofm...@kbsg.rwth-aachen.de>
Date:    Sun Nov 8 14:04:50 2020 +0100
Subject: cx: fast-fail a lock action if the mutex is already locked

 src/plugins/clips-executive/clips/lock-actions.clp | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/clips-executive/clips/lock-actions.clp 
b/src/plugins/clips-executive/clips/lock-actions.clp
index 14d8af57f..f863de1a3 100644
--- a/src/plugins/clips-executive/clips/lock-actions.clp
+++ b/src/plugins/clips-executive/clips/lock-actions.clp
@@ -55,11 +55,16 @@
                            (param-values $?param-values))
        =>
        (bind ?lock-name (plan-action-arg name ?param-names ?param-values))
-       ; The following performs a synchronous/blocking call
-       ;(bind ?rv (robmem-mutex-try-lock (str-cat ?lock-name)))
-       ;(modify ?pa (state (if ?rv then EXECUTION-SUCCEEDED else 
EXECUTION-FAILED)))
-       (mutex-try-lock-async ?lock-name)
-       (modify ?pa (state RUNNING))
+       (if (any-factp ((?mutex mutex))
+                      (and (eq ?mutex:name ?lock-name)
+                           (or (neq ?mutex:request NONE)
+                               (eq ?mutex:state LOCKED))))
+        then
+               (modify ?pa (state EXECUTION-FAILED))
+       else
+               (mutex-try-lock-async ?lock-name)
+               (modify ?pa (state RUNNING))
+       )
 )
 
 (defrule lock-actions-lock-acquired

- *commit* ae88f4164034a716294321d54166b76183c557f8 - - - - - - - - - -
Author:  Till Hofmann <hofm...@kbsg.rwth-aachen.de>
Date:    Sun Nov 8 14:13:31 2020 +0100
Subject: cx: if a mutex is locked without a request, release it again

 src/plugins/clips-executive/clips/coordination-mutex.clp | 7 +++++++
 1 file changed, 7 insertions(+)

_Diff for modified files_:
diff --git a/src/plugins/clips-executive/clips/coordination-mutex.clp 
b/src/plugins/clips-executive/clips/coordination-mutex.clp
index 94ae6ccf9..4052dd6ba 100644
--- a/src/plugins/clips-executive/clips/coordination-mutex.clp
+++ b/src/plugins/clips-executive/clips/coordination-mutex.clp
@@ -460,6 +460,13 @@
         (if (and (or (eq ?m:request LOCK) (eq ?m:request RENEW-LOCK)) ?locked)
         then
           (modify ?m (response ACQUIRED))
+        else
+          (if (eq ?m:locked-by (cx-identity))
+           then
+            (printout error "Acquired a mutex without a request,"
+                            " releasing the mutex again!" crlf)
+            (mutex-unlock-async ?id)
+          )
         )
                  )
          )

- *commit* f8cb4a45c2ae8ced1db2c702d7a8a64e043f82d1 - - - - - - - - - -
Author:  Till Hofmann <hofm...@kbsg.rwth-aachen.de>
Date:    Sun Nov 8 14:55:39 2020 +0100
Subject: cx: refactor mutex trigger processing function

 .../clips-executive/clips/coordination-mutex.clp   | 41 +++++++++++-----------
 1 file changed, 21 insertions(+), 20 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/clips-executive/clips/coordination-mutex.clp 
b/src/plugins/clips-executive/clips/coordination-mutex.clp
index 4052dd6ba..ae32508b6 100644
--- a/src/plugins/clips-executive/clips/coordination-mutex.clp
+++ b/src/plugins/clips-executive/clips/coordination-mutex.clp
@@ -440,6 +440,27 @@
                        (bind ?lock-time (bson-get-time ?doc "lock-time"))
                )
 
+               (do-for-fact ((?m mutex)) (eq ?m:name ?id)
+      (if ?locked then
+        (if (eq ?locked-by (cx-identity)) then
+          (if (or (eq ?m:request LOCK) (eq ?m:request RENEW-LOCK)) then
+            ; Mutex is locked by us and we requested it, all good.
+            (modify ?m (response ACQUIRED))
+           else
+             (if (eq ?m:state OPEN) then
+               ; Mutex is newly locked by us but we never requested it.
+               (printout error "Acquired a mutex without a request,"
+                               " releasing the mutex again!" crlf)
+               (mutex-unlock-async ?id)
+             )
+          )
+        )
+       else ; Mutex is unlocked.
+        (if (eq ?m:request UNLOCK) then
+          (modify ?m (response UNLOCKED))
+        )
+      )
+    )
                (if (any-factp ((?m mutex)) (eq ?m:name ?id))
                then
                        (do-for-fact ((?m mutex)) (eq ?m:name ?id)
@@ -450,26 +471,6 @@
                        (assert (mutex (name ?id) (state (if ?locked then 
LOCKED else OPEN))
                                       (locked-by ?locked-by) (lock-time 
?lock-time)))
                )
-               (do-for-fact ((?m mutex)) (eq ?m:name ?id)
-      (if (or (eq ?m:state OPEN) (eq ?m:locked-by (cx-identity)))
-      then
-        (if (and (eq ?m:request UNLOCK) (not ?locked))
-        then
-          (modify ?m (response UNLOCKED))
-        )
-        (if (and (or (eq ?m:request LOCK) (eq ?m:request RENEW-LOCK)) ?locked)
-        then
-          (modify ?m (response ACQUIRED))
-        else
-          (if (eq ?m:locked-by (cx-identity))
-           then
-            (printout error "Acquired a mutex without a request,"
-                            " releasing the mutex again!" crlf)
-            (mutex-unlock-async ?id)
-          )
-        )
-                 )
-         )
        )
 )
 

- *commit* aee7aa3584df2ac17f15d01f7a30368d0a2d3d42 - - - - - - - - - -
Author:  Till Hofmann <hofm...@kbsg.rwth-aachen.de>
Date:    Sun Nov 8 14:59:24 2020 +0100
Subject: cx: consistently print all robmem updates to debug

 src/plugins/clips-executive/clips/coordination-mutex.clp | 2 +-
 src/plugins/clips-executive/clips/wm-robmem-sync.clp     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/clips-executive/clips/coordination-mutex.clp 
b/src/plugins/clips-executive/clips/coordination-mutex.clp
index ae32508b6..8437ae5a2 100644
--- a/src/plugins/clips-executive/clips/coordination-mutex.clp
+++ b/src/plugins/clips-executive/clips/coordination-mutex.clp
@@ -490,7 +490,7 @@
        =>
        (bind ?op (sym-cat (bson-get ?obj "operationType")))
 
-       ;(printout warn "Trigger: " (bson-tostring ?obj) crlf)
+       (printout debug "Trigger: " (bson-tostring ?obj) crlf)
        (switch ?op
                (case insert then (mutex-trigger-update ?obj))
                (case update then (mutex-trigger-update ?obj))
diff --git a/src/plugins/clips-executive/clips/wm-robmem-sync.clp 
b/src/plugins/clips-executive/clips/wm-robmem-sync.clp
index f9263004f..913c4bf45 100644
--- a/src/plugins/clips-executive/clips/wm-robmem-sync.clp
+++ b/src/plugins/clips-executive/clips/wm-robmem-sync.clp
@@ -388,7 +388,7 @@
        =>
        (bind ?op (sym-cat (bson-get ?obj "operationType")))
 
-       (printout warn "Trigger: " (bson-tostring ?obj) crlf)
+       (printout debug "Trigger: " (bson-tostring ?obj) crlf)
        (if (eq ?op delete)
         then
                ; We cannot check the source because it is not set for deletions



_______________________________________________
fawkes-commits mailing list
fawkes-commits@lists.kbsg.rwth-aachen.de
https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits

Reply via email to