Module: xenomai-3
Branch: master
Commit: fe7ccb36fe2b1a0b148829ce4d1b0aaac5b0eb80
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fe7ccb36fe2b1a0b148829ce4d1b0aaac5b0eb80

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Mar 22 16:47:46 2015 +0100

copperplate/regd: drop references to stale threads in sysgroup

---

 include/copperplate/heapobj.h    |    4 ++--
 lib/copperplate/regd/fs-common.c |   12 +++++++-----
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h
index 495d72c..c92e581 100644
--- a/include/copperplate/heapobj.h
+++ b/include/copperplate/heapobj.h
@@ -272,8 +272,8 @@ static inline void sysgroup_unlock(void)
 #define sysgroup_count(__group)        \
        (__main_sysgroup->__group ## _count)
 
-#define for_each_sysgroup(__obj, __group)      \
-       list_for_each_entry(__obj, &(__main_sysgroup->__group ## _list), next)
+#define for_each_sysgroup(__obj, __tmp, __group)       \
+       list_for_each_entry_safe(__obj, __tmp, &(__main_sysgroup->__group ## 
_list), next)
 
 int heapobj_pkg_init_shared(void);
 
diff --git a/lib/copperplate/regd/fs-common.c b/lib/copperplate/regd/fs-common.c
index 5f8b439..ab73d5c 100644
--- a/lib/copperplate/regd/fs-common.c
+++ b/lib/copperplate/regd/fs-common.c
@@ -70,9 +70,9 @@ static char *format_time(ticks_t value, char *buf, size_t 
bufsz)
 int open_threads(struct fsobj *fsobj, void *priv)
 {
        struct thread_data *thread_data, *p;
+       struct sysgroup_memspec *obj, *tmp;
        char sbuf[64], pbuf[16], tbuf[64];
        struct threadobj_stat statbuf;
-       struct sysgroup_memspec *obj;
        struct fsobstack *o = priv;
        struct threadobj *thobj;
        const char *sched_class;
@@ -105,13 +105,15 @@ int open_threads(struct fsobj *fsobj, void *priv)
 
        sysgroup_lock();
 
-       for_each_sysgroup(obj, thread) {
+       for_each_sysgroup(obj, tmp, thread) {
                if (p - thread_data >= count)
                        break;
                thobj = container_of(obj, struct threadobj, memspec);
                ret = threadobj_lock(thobj);
-               if (ret)
+               if (ret) {
+                       sysgroup_remove(thread, obj);
                        continue;
+               }
                namecpy(p->name, thobj->name);
                p->name[sizeof(p->name) - 1] = '\0';
                p->pid = thobj->pid;
@@ -198,8 +200,8 @@ struct heap_data {
 
 int open_heaps(struct fsobj *fsobj, void *priv)
 {
+       struct sysgroup_memspec *obj, *tmp;
        struct heap_data *heap_data, *p;
-       struct sysgroup_memspec *obj;
        struct fsobstack *o = priv;
        struct shared_heap *heap;
        int ret, count, len = 0;
@@ -230,7 +232,7 @@ int open_heaps(struct fsobj *fsobj, void *priv)
         * the group lock, so there is no point in acquiring each heap
         * lock individually for reading the slot.
         */
-       for_each_sysgroup(obj, heap) {
+       for_each_sysgroup(obj, tmp, heap) {
                if (p - heap_data >= count)
                        break;
                heap = container_of(obj, struct shared_heap, memspec);


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to