svn commit: r294952 - head/sys/dev/filemon
Bryan Drewery
bdrewery at FreeBSD.org
Wed Jan 27 21:14:11 UTC 2016
Author: bdrewery
Date: Wed Jan 27 21:14:09 2016
New Revision: 294952
URL: https://svnweb.freebsd.org/changeset/base/294952
Log:
filemon_ioctl: Lock the associated filemon handle before writing to it.
Reported by: mjg
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
Modified:
head/sys/dev/filemon/filemon.c
head/sys/dev/filemon/filemon_wrapper.c
Modified: head/sys/dev/filemon/filemon.c
==============================================================================
--- head/sys/dev/filemon/filemon.c Wed Jan 27 21:12:47 2016 (r294951)
+++ head/sys/dev/filemon/filemon.c Wed Jan 27 21:14:09 2016 (r294952)
@@ -146,6 +146,8 @@ filemon_ioctl(struct cdev *dev, u_long c
if ((error = devfs_get_cdevpriv((void **) &filemon)) != 0)
return (error);
+ filemon_filemon_lock(filemon);
+
switch (cmd) {
/* Set the output file descriptor. */
case FILEMON_SET_FD:
@@ -177,6 +179,7 @@ filemon_ioctl(struct cdev *dev, u_long c
break;
}
+ filemon_filemon_unlock(filemon);
return (error);
}
Modified: head/sys/dev/filemon/filemon_wrapper.c
==============================================================================
--- head/sys/dev/filemon/filemon_wrapper.c Wed Jan 27 21:12:47 2016 (r294951)
+++ head/sys/dev/filemon/filemon_wrapper.c Wed Jan 27 21:14:09 2016 (r294952)
@@ -115,21 +115,14 @@ filemon_comment(struct filemon *filemon)
int len;
struct timeval now;
- /* Load timestamp before locking. Less accurate but less contention. */
getmicrotime(&now);
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
len = snprintf(filemon->msgbufr, sizeof(filemon->msgbufr),
"# filemon version %d\n# Target pid %d\n# Start %ju.%06ju\nV %d\n",
FILEMON_VERSION, curproc->p_pid, (uintmax_t)now.tv_sec,
(uintmax_t)now.tv_usec, FILEMON_VERSION);
filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
}
static int
More information about the svn-src-head
mailing list