From: Brandon L Black <blblack@gmail.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Ulrich Drepper <drepper@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] Add MSG_WAITFORONE flag to recvmmsg
Date: Fri, 26 Mar 2010 17:35:30 -0500 [thread overview]
Message-ID: <20100326223530.GA11817@xpc.home> (raw)
From: Brandon L Black <blblack@gmail.com>
Add new flag MSG_WAITFORONE for the recvmmsg() syscall.
When this flag is specified for a blocking socket, recvmmsg()
will only block until at least 1 packet is available. The
default behavior is to block until all vlen packets are
available. This flag has no effect on non-blocking sockets
or when used in combination with MSG_DONTWAIT.
Signed-off-by: Brandon L Black <blblack@gmail.com>
---
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 7b3aae2..354cc56 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -255,6 +255,7 @@ struct ucred {
#define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */
#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */
#define MSG_MORE 0x8000 /* Sender will send more */
+#define MSG_WAITFORONE 0x10000 /* recvmmsg(): block until 1+ packets avail */
#define MSG_EOF MSG_FIN
diff --git a/net/socket.c b/net/socket.c
index 769c386..33304d1 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2133,7 +2133,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
if (err)
break;
- ++datagrams;
+
+ /* MSG_WAITFORONE turns on MSG_DONTWAIT after one packet */
+ if (!datagrams++ && (flags & MSG_WAITFORONE))
+ flags |= MSG_DONTWAIT;
if (timeout) {
ktime_get_ts(timeout);
next reply other threads:[~2010-03-26 22:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-26 22:35 Brandon L Black [this message]
2010-03-26 22:44 ` [PATCH] Add MSG_WAITFORONE flag to recvmmsg Eric Dumazet
2010-03-26 22:55 ` Brandon Black
2010-03-27 2:07 ` Ulrich Drepper
2010-03-27 2:18 ` [PATCH v2] " Brandon L Black
2010-03-27 3:54 ` David Miller
2010-03-27 14:07 ` Arnaldo Carvalho de Melo
2010-03-27 15:29 ` David Miller
2010-03-27 4:58 ` Ulrich Drepper
2010-03-27 6:00 ` Eric Dumazet
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=20100326223530.GA11817@xpc.home \
--to=blblack@gmail.com \
--cc=acme@redhat.com \
--cc=davem@davemloft.net \
--cc=drepper@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.