From: Krzysztof Benedyczak <golbi@mat.uni.torun.pl>
To: linux-kernel@vger.kernel.org
Cc: Michal Wronski <wrona@mat.uni.torun.pl>,
Manfred Spraul <manfred@colorfullife.com>
Subject: [RFC][PATCH] 4/6 POSIX message queues
Date: Thu, 19 Feb 2004 15:30:01 +0100 (CET) [thread overview]
Message-ID: <Pine.GSO.4.58.0402191529150.18841@Juliusz> (raw)
// $Header$
// Kernel Version:
// VERSION = 2
// PATCHLEVEL = 6
// SUBLEVEL = 2
// EXTRAVERSION =
--- 2.6/ipc/mqueue.c 2004-02-16 23:01:18.000000000 +0100
+++ build-2.6/ipc/mqueue.c 2004-02-16 23:01:05.000000000 +0100
@@ -14,6 +14,7 @@
#include <linux/mqueue.h>
#include <linux/msg.h>
#include <linux/list.h>
+#include <linux/poll.h>
#include <linux/init.h>
#include <linux/pagemap.h>
#include <linux/file.h>
@@ -250,6 +251,24 @@
return 0;
}
+static unsigned int mqueue_poll_file(struct file *filp, struct poll_table_struct *poll_tab)
+{
+ struct mqueue_inode_info *info = MQUEUE_I(filp->f_dentry->d_inode);
+ int retval = 0;
+
+ poll_wait(filp, &info->wait_q, poll_tab);
+
+ spin_lock(&info->lock);
+ if (info->attr.mq_curmsgs)
+ retval = POLLIN | POLLRDNORM;
+
+ if (info->attr.mq_curmsgs < info->attr.mq_maxmsg)
+ retval |= POLLOUT | POLLWRNORM;
+ spin_unlock(&info->lock);
+
+ return retval;
+}
+
/* Adds current to info->e_wait_q[sr] before element with smaller prio */
static void wq_add(struct mqueue_inode_info *info, int sr,
struct ext_wait_queue *ewp)
@@ -374,11 +393,11 @@
&sig_i, info->notify_owner);
} else if (info->notify.sigev_notify == SIGEV_THREAD) {
info->notify_filp->private_data = (void*)NP_WOKENUP;
- wake_up(&info->wait_q);
}
/* after notification unregisters process */
info->notify_owner = 0;
}
+ wake_up(&info->wait_q);
}
static long prepare_timeout(const struct timespec __user *u_arg)
@@ -660,9 +679,11 @@
{
struct ext_wait_queue *sender = wq_get_first_waiter(info, SEND);
- if (!sender)
+ if (!sender) {
+ /* for poll */
+ wake_up_interruptible(&info->wait_q);
return;
-
+ }
msg_insert(sender->msg, info);
list_del(&sender->list);
sender->state = STATE_PENDING;
@@ -974,6 +995,7 @@
static struct file_operations mqueue_file_operations = {
.flush = mqueue_flush_file,
+ .poll = mqueue_poll_file,
};
static struct file_operations mqueue_notify_fops = {
reply other threads:[~2004-02-19 14:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.GSO.4.58.0402191529150.18841@Juliusz \
--to=golbi@mat.uni.torun.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=wrona@mat.uni.torun.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®