Module Name: src Committed By: pgoyette Date: Sat Mar 27 13:23:18 UTC 2010
Modified Files: src/sys/dev/sysmon: sysmon_envsys.c sysmonvar.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.35 -r1.36 src/sys/dev/sysmon/sysmonvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.101 src/sys/dev/sysmon/sysmon_envsys.c:1.102 --- src/sys/dev/sysmon/sysmon_envsys.c:1.101 Fri Mar 26 21:06:25 2010 +++ src/sys/dev/sysmon/sysmon_envsys.c Sat Mar 27 13:23:18 2010 @@ -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); } Index: src/sys/dev/sysmon/sysmonvar.h diff -u src/sys/dev/sysmon/sysmonvar.h:1.35 src/sys/dev/sysmon/sysmonvar.h:1.36 --- src/sys/dev/sysmon/sysmonvar.h:1.35 Fri Mar 26 20:31:06 2010 +++ src/sys/dev/sysmon/sysmonvar.h Sat Mar 27 13:23:18 2010 @@ -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);