Commit 34b98f22 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] posix message queues: send notifications via netlink

From: Manfred Spraul <manfred@colorfullife.com>

SIGEV_THREAD means that a given callback should be called in the context on a
new thread.  This must be done by the C library.  The kernel must deliver a
notice of the event to the C library when the callback should be called.

This patch switches to a new, simpler interface: User space creates a socket
with socket(PF_NETLINK, SOCK_RAW,0) and passes the fd to the mq_notify call
together with a cookie.  When the mq_notify() condition is satisfied, the
kernel "writes" the cookie to the socket.  User space then reads the cookie
and calls the appropriate callback.
parent ed6dcf4a
...@@ -30,8 +30,24 @@ struct mq_attr { ...@@ -30,8 +30,24 @@ struct mq_attr {
long __reserved[4]; /* ignored for input, zeroed for output */ long __reserved[4]; /* ignored for input, zeroed for output */
}; };
/*
* SIGEV_THREAD implementation:
* SIGEV_THREAD must be implemented in user space. If SIGEV_THREAD is passed
* to mq_notify, then
* - sigev_signo must be the file descriptor of an AF_NETLINK socket. It's not
* necessary that the socket is bound.
* - sigev_value.sival_ptr must point to a cookie that is NOTIFY_COOKIE_LEN
* bytes long.
* If the notification is triggered, then the cookie is sent to the netlink
* socket. The last byte of the cookie is replaced with the NOTIFY_?? codes:
* NOTIFY_WOKENUP if the notification got triggered, NOTIFY_REMOVED if it was
* removed, either due to a close() on the message queue fd or due to a
* mq_notify() that removed the notification.
*/
#define NOTIFY_NONE 0 #define NOTIFY_NONE 0
#define NOTIFY_WOKENUP 1 #define NOTIFY_WOKENUP 1
#define NOTIFY_REMOVED 2 #define NOTIFY_REMOVED 2
#define NOTIFY_COOKIE_LEN 32
#endif #endif
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment