Module: xenomai-3
Branch: stable-3.0.x
Commit: 7fffb2630c8358ed7b1654aaf4a200ea28981e93
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7fffb2630c8358ed7b1654aaf4a200ea28981e93

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Apr 18 20:10:31 2018 +0200

copperplate/threadobj: do not leak the periodic timer

---

 lib/copperplate/threadobj.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index d9e9267..a1a805a 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -1631,6 +1631,14 @@ int threadobj_set_periodic(struct threadobj *thobj,
        __threadobj_check_locked(thobj);
 
        timer = thobj->periodic_timer;
+       if (!timespec_scalar(idate) && !timespec_scalar(period)) {
+               if (timer) {
+                       thobj->periodic_timer = NULL;
+                       __RT(timer_delete(timer));
+               }
+               return 0;
+       }
+       
        if (timer == NULL) {
                memset(&sev, 0, sizeof(sev));
                sev.sigev_signo = SIGPERIOD;
@@ -1640,8 +1648,7 @@ int threadobj_set_periodic(struct threadobj *thobj,
                if (ret)
                        return __bt(-errno);
                thobj->periodic_timer = timer;
-       } else if (!timespec_scalar(idate) && !timespec_scalar(period))
-               thobj->periodic_timer = NULL;
+       }
 
        its.it_value = *idate;
        its.it_interval = *period;


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

Reply via email to