summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2005-11-30 05:12:03 +0000
committerdavidxu <davidxu@FreeBSD.org>2005-11-30 05:12:03 +0000
commit5d50adf57dd3eb3f8996480fa4dd26e4756e268e (patch)
treedd58fac4b1e67b3b84318bcdf4611733ffd150f0 /sys/kern/kern_descrip.c
parent06d803185574a0ba37434b1e98b322e54cc32a4e (diff)
downloadFreeBSD-src-5d50adf57dd3eb3f8996480fa4dd26e4756e268e.zip
FreeBSD-src-5d50adf57dd3eb3f8996480fa4dd26e4756e268e.tar.gz
Last step to make mq_notify conform to POSIX standard, If the process
has successfully attached a notification request to the message queue via a queue descriptor, file closing should remove the attachment.
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r--sys/kern/kern_descrip.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index b6704ba..28922d3 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mount.h>
+#include <sys/mqueue.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/proc.h>
@@ -134,6 +135,7 @@ struct filelist filehead; /* head of list of open files */
int openfiles; /* actual number of open files */
struct sx filelist_lock; /* sx to protect filelist */
struct mtx sigio_lock; /* mtx to protect pointers to sigio */
+void (*mq_fdclose)(struct thread *td, int fd, struct file *fp);
/* A mutex to protect the association between a proc and filedesc. */
static struct mtx fdesc_mtx;
@@ -713,6 +715,8 @@ do_dup(struct thread *td, enum dup_type type, int old, int new, register_t *retv
*/
if (delfp != NULL) {
knote_fdclose(td, new);
+ if (delfp->f_type == DTYPE_MQUEUE)
+ mq_fdclose(td, new, delfp);
FILEDESC_UNLOCK(fdp);
(void) closef(delfp, td);
if (holdleaders) {
@@ -1002,6 +1006,8 @@ close(td, uap)
* for the new fd.
*/
knote_fdclose(td, fd);
+ if (fp->f_type == DTYPE_MQUEUE)
+ mq_fdclose(td, fd, fp);
FILEDESC_UNLOCK(fdp);
error = closef(fp, td);
@@ -1766,7 +1772,8 @@ fdcloseexec(struct thread *td)
*/
for (i = 0; i <= fdp->fd_lastfile; i++) {
if (fdp->fd_ofiles[i] != NULL &&
- (fdp->fd_ofileflags[i] & UF_EXCLOSE)) {
+ (fdp->fd_ofiles[i]->f_type == DTYPE_MQUEUE ||
+ (fdp->fd_ofileflags[i] & UF_EXCLOSE))) {
struct file *fp;
knote_fdclose(td, i);
@@ -1778,6 +1785,8 @@ fdcloseexec(struct thread *td)
fdp->fd_ofiles[i] = NULL;
fdp->fd_ofileflags[i] = 0;
fdunused(fdp, i);
+ if (fp->f_type == DTYPE_MQUEUE)
+ mq_fdclose(td, i, fp);
FILEDESC_UNLOCK(fdp);
(void) closef(fp, td);
FILEDESC_LOCK(fdp);
OpenPOWER on IntegriCloud