Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/sysmon Fix the locking protocol in sysmon_envsys_for...



details:   https://anonhg.NetBSD.org/src/rev/0ea7dd358c2e
branches:  trunk
changeset: 753417:0ea7dd358c2e
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sat Mar 27 13:23:18 2010 +0000

description:
Fix the locking protocol in sysmon_envsys_foreach_sensor(), and add an
additional argument to control whether or not the sensors are refreshed
before invoking the callback routine.

diffstat:

 sys/dev/sysmon/sysmon_envsys.c |  17 ++++++++++++-----
 sys/dev/sysmon/sysmonvar.h     |   5 +++--
 2 files changed, 15 insertions(+), 7 deletions(-)

diffs (68 lines):

diff -r 16621d78d443 -r 0ea7dd358c2e sys/dev/sysmon/sysmon_envsys.c
--- a/sys/dev/sysmon/sysmon_envsys.c    Sat Mar 27 10:54:12 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys.c    Sat Mar 27 13:23:18 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysmon_envsys.c,v 1.101 2010/03/26 21:06:25 pgoyette Exp $     */
+/*     $NetBSD: sysmon_envsys.c,v 1.102 2010/03/27 13:23:18 pgoyette Exp $     */
 
 /*-
  * Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.101 2010/03/26 21:06:25 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.102 2010/03/27 13:23:18 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -2011,7 +2011,8 @@
  */
 void   
 sysmon_envsys_foreach_sensor(bool(*func)(struct sysmon_envsys *,
-                            envsys_data_t *, void*), void *arg)
+                                        envsys_data_t *, void*), void *arg,
+                            bool refresh)
 {
        struct sysmon_envsys *sme;
        envsys_data_t *sensor;
@@ -2019,12 +2020,18 @@
        mutex_enter(&sme_global_mtx);
        LIST_FOREACH(sme, &sysmon_envsys_list, sme_list) {
 
-               mutex_enter(&sme->sme_mtx);
+               sysmon_envsys_acquire(sme, false);
                TAILQ_FOREACH(sensor, &sme->sme_sensors_list, sensors_head) {
+                       if (refresh &&
+                           (sme->sme_flags & SME_DISABLE_REFRESH) == 0) {
+                               mutex_enter(&sme->sme_mtx);
+                               (*sme->sme_refresh)(sme, sensor);
+                               mutex_exit(&sme->sme_mtx);
+                       }
                        if (!(*func)(sme, sensor, arg))
                                break;
                }
-               mutex_exit(&sme->sme_mtx);
+               sysmon_envsys_release(sme, false);
        }
        mutex_exit(&sme_global_mtx);
 }
diff -r 16621d78d443 -r 0ea7dd358c2e sys/dev/sysmon/sysmonvar.h
--- a/sys/dev/sysmon/sysmonvar.h        Sat Mar 27 10:54:12 2010 +0000
+++ b/sys/dev/sysmon/sysmonvar.h        Sat Mar 27 13:23:18 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysmonvar.h,v 1.35 2010/03/26 20:31:06 pgoyette Exp $  */
+/*     $NetBSD: sysmonvar.h,v 1.36 2010/03/27 13:23:18 pgoyette Exp $  */
 
 /*-
  * Copyright (c) 2000 Zembu Labs, Inc.
@@ -209,7 +209,8 @@
                                   int);
 
 void   sysmon_envsys_foreach_sensor(bool(*)(struct sysmon_envsys *,
-                                    envsys_data_t *, void*), void *);
+                                            envsys_data_t *, void*), void *,
+                                            bool);
 
 void   sysmon_envsys_init(void);
 



Home | Main Index | Thread Index | Old Index