Date: Wed, 27 Jan 2016 21:14:09 +0000 (UTC) From: Bryan Drewery <bdrewery@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294952 - head/sys/dev/filemon Message-ID: <201601272114.u0RLE919098688@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601272114.u0RLE919098688>