[PATCH] 2.3.14: Supply "si_band" in queued SIGIOs

Stephen C. Tweedie (sct@redhat.com)
Thu, 19 Aug 1999 23:32:57 +0100


Hi,

The patch below fills in the "si_band" field of the siginfo_t structure
when we deliver queued sigios on a file descriptor. A couple of people
within Red Hat have been using this for some time now to test a fast
event-driven httpd core on both 2.2 and older 2.3s (see
http://people.redhat.com/zab/phhttpd/) without problems. The rtsigio
stuff we added in 2.2 really is a little incomplete without the si_band
information.

--Stephen

----------------------------------------------------------------
--- arch/sparc64/solaris/timod.c.~1~ Wed Aug 18 12:10:46 1999
+++ arch/sparc64/solaris/timod.c Thu Aug 19 20:01:14 1999
@@ -152,7 +152,7 @@
sock = &current->files->fd[fd]->f_dentry->d_inode->u.socket_i;
wake_up_interruptible(&sock->wait);
if (sock->fasync_list && !(sock->flags & SO_WAITDATA))
- kill_fasync(sock->fasync_list, SIGIO);
+ kill_fasync(sock->fasync_list, SIGIO, POLL_IN);
SOLD("done");
}

--- drivers/char/busmouse.c.~1~ Thu Aug 19 14:22:15 1999
+++ drivers/char/busmouse.c Thu Aug 19 20:01:23 1999
@@ -144,7 +144,7 @@
wake_up(&mse->wait);

if (mse->fasyncptr)
- kill_fasync(mse->fasyncptr, SIGIO);
+ kill_fasync(mse->fasyncptr, SIGIO, POLL_IN);
}
}

--- drivers/char/dn_keyb.c.~1~ Wed Aug 18 12:10:49 1999
+++ drivers/char/dn_keyb.c Thu Aug 19 19:57:39 1999
@@ -469,7 +469,7 @@
if (mouse_dy > 2048)
mouse_dy = 2048;
if (mouse_fasyncptr)
- kill_fasync(mouse_fasyncptr, SIGIO);
+ kill_fasync(mouse_fasyncptr, SIGIO, POLL_IN);
}
mouse_byte_count=0;
/* printk("mouse: %d, %d, %x\n",mouse_x,mouse_y,buttons); */
--- drivers/char/n_hdlc.c.~1~ Wed Jul 14 19:09:17 1999
+++ drivers/char/n_hdlc.c Thu Aug 19 20:01:56 1999
@@ -622,7 +622,7 @@
/* wake up any blocked reads and perform async signalling */
wake_up_interruptible (&n_hdlc->read_wait);
if (n_hdlc->tty->fasync != NULL)
- kill_fasync (n_hdlc->tty->fasync, SIGIO);
+ kill_fasync (n_hdlc->tty->fasync, SIGIO, POLL_IN);

} /* end of n_hdlc_tty_receive() */

--- drivers/char/n_tty.c.~1~ Wed May 26 15:52:33 1999
+++ drivers/char/n_tty.c Thu Aug 19 20:01:47 1999
@@ -604,7 +604,7 @@
tty->canon_head = tty->read_head;
tty->canon_data++;
if (tty->fasync)
- kill_fasync(tty->fasync, SIGIO);
+ kill_fasync(tty->fasync, SIGIO, POLL_IN);
if (waitqueue_active(&tty->read_wait))
wake_up_interruptible(&tty->read_wait);
return;
@@ -706,7 +706,7 @@

if (!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) {
if (tty->fasync)
- kill_fasync(tty->fasync, SIGIO);
+ kill_fasync(tty->fasync, SIGIO, POLL_IN);
if (waitqueue_active(&tty->read_wait))
wake_up_interruptible(&tty->read_wait);
}
--- drivers/char/pc110pad.c.~1~ Wed Jun 23 10:17:11 1999
+++ drivers/char/pc110pad.c Thu Aug 19 19:58:12 1999
@@ -75,7 +75,7 @@
{
wake_up_interruptible(&queue);
if(asyncptr)
- kill_fasync(asyncptr, SIGIO);
+ kill_fasync(asyncptr, SIGIO, POLL_IN);
}


--- drivers/char/pc_keyb.c.~1~ Wed Aug 18 12:10:50 1999
+++ drivers/char/pc_keyb.c Thu Aug 19 20:01:45 1999
@@ -409,7 +409,7 @@
if (head != queue->tail) {
queue->head = head;
if (queue->fasync)
- kill_fasync(queue->fasync, SIGIO);
+ kill_fasync(queue->fasync, SIGIO, POLL_IN);
wake_up_interruptible(&queue->proc_list);
}
}
--- drivers/char/qpmouse.c.~1~ Wed May 26 15:52:33 1999
+++ drivers/char/qpmouse.c Thu Aug 19 19:58:12 1999
@@ -134,7 +134,7 @@
}
queue->head = head;
if (queue->fasync)
- kill_fasync(queue->fasync, SIGIO);
+ kill_fasync(queue->fasync, SIGIO, POLL_IN);
wake_up_interruptible(&queue->proc_list);
}

--- drivers/net/ppp.c.~1~ Thu Aug 19 14:22:16 1999
+++ drivers/net/ppp.c Thu Aug 19 19:58:12 1999
@@ -2368,7 +2368,7 @@

wake_up_interruptible (&ppp->read_wait);
if (ppp->tty->fasync != NULL)
- kill_fasync (ppp->tty->fasync, SIGIO);
+ kill_fasync (ppp->tty->fasync, SIGIO, POLL_IN);

return 1;
}
--- drivers/sbus/char/pcikbd.c.~1~ Wed Jun 23 10:17:23 1999
+++ drivers/sbus/char/pcikbd.c Thu Aug 19 19:58:12 1999
@@ -779,7 +779,7 @@
queue->head = head;
aux_ready = 1;
if (queue->fasync)
- kill_fasync(queue->fasync, SIGIO);
+ kill_fasync(queue->fasync, SIGIO, POLL_IN);
wake_up_interruptible(&queue->proc_list);
}

--- drivers/sbus/char/sunkbd.c.~1~ Wed Aug 18 12:10:55 1999
+++ drivers/sbus/char/sunkbd.c Thu Aug 19 19:58:12 1999
@@ -1273,7 +1273,7 @@
kbd_head = next;
}
if (kb_fasync)
- kill_fasync (kb_fasync, SIGIO);
+ kill_fasync (kb_fasync, SIGIO, POLL_IN);
wake_up_interruptible (&kbd_wait);
}

--- drivers/sbus/char/sunmouse.c.~1~ Wed Aug 18 12:10:55 1999
+++ drivers/sbus/char/sunmouse.c Thu Aug 19 20:02:22 1999
@@ -137,7 +137,7 @@
}
sunmouse.ready = 1;
if (sunmouse.fasync)
- kill_fasync (sunmouse.fasync, SIGIO);
+ kill_fasync (sunmouse.fasync, SIGIO, POLL_IN);
wake_up_interruptible (&sunmouse.proc_list);
}

@@ -318,7 +318,7 @@
*/
sunmouse.ready = 1;
if (sunmouse.fasync)
- kill_fasync (sunmouse.fasync, SIGIO);
+ kill_fasync (sunmouse.fasync, SIGIO, POLL_IN);
wake_up_interruptible(&sunmouse.proc_list);
}
return;
--- drivers/scsi/sg.c.~1~ Wed Jun 23 10:17:25 1999
+++ drivers/scsi/sg.c Thu Aug 19 20:02:11 1999
@@ -798,7 +798,7 @@
/* Now wake up any sg_read() that is waiting for this packet. */
wake_up_interruptible(&sfp->read_wait);
if ((sfp->async_qp) && (! closed))
- kill_fasync(sfp->async_qp, SIGPOLL);
+ kill_fasync(sfp->async_qp, SIGPOLL, POLL_IN);
}

static void sg_debug_all(const Sg_fd * sfp)
--- drivers/sgi/char/shmiq.c.~1~ Wed Aug 18 12:10:35 1999
+++ drivers/sgi/char/shmiq.c Thu Aug 19 19:58:12 1999
@@ -118,7 +118,7 @@
s->tail = tail_next;
shmiqs [device].tail = tail_next;
if (shmiqs [device].fasync)
- kill_fasync (shmiqs [device].fasync, SIGIO);
+ kill_fasync (shmiqs [device].fasync, SIGIO, POLL_IN);
wake_up_interruptible (&shmiqs [device].proc_list);
}

--- drivers/usb/mouse.c.~1~ Thu Aug 19 14:22:17 1999
+++ drivers/usb/mouse.c Thu Aug 19 20:02:29 1999
@@ -88,7 +88,7 @@

wake_up_interruptible(&mouse->wait);
if (mouse->fasync)
- kill_fasync(mouse->fasync, SIGIO);
+ kill_fasync(mouse->fasync, SIGIO, POLL_IN);

return 1;
}
--- fs/fcntl.c.~1~ Wed Aug 18 12:10:40 1999
+++ fs/fcntl.c Thu Aug 19 20:12:31 1999
@@ -255,7 +255,9 @@
}

static void send_sigio_to_task(struct task_struct *p,
- struct fown_struct *fown, struct fasync_struct *fa)
+ struct fown_struct *fown,
+ struct fasync_struct *fa,
+ int band)
{
if ((fown->euid != 0) &&
(fown->euid ^ p->suid) && (fown->euid ^ p->uid) &&
@@ -273,8 +275,7 @@
si.si_signo = fown->signum;
si.si_errno = 0;
si.si_code = SI_SIGIO;
- si.si_pid = fown->pid;
- si.si_uid = fown->uid;
+ si.si_band = band;
si.si_fd = fa->fa_fd;
if (!send_sig_info(fown->signum, &si, p))
break;
@@ -284,14 +285,15 @@
}
}

-static void send_sigio(struct fown_struct *fown, struct fasync_struct *fa)
+static void send_sigio(struct fown_struct *fown, struct fasync_struct *fa,
+ int band)
{
struct task_struct * p;
int pid = fown->pid;

read_lock(&tasklist_lock);
if ( (pid > 0) && (p = find_task_by_pid(pid)) ) {
- send_sigio_to_task(p, fown, fa);
+ send_sigio_to_task(p, fown, fa, band);
goto out;
}
for_each_task(p) {
@@ -300,13 +302,13 @@
match = -p->pgrp;
if (pid != match)
continue;
- send_sigio_to_task(p, fown, fa);
+ send_sigio_to_task(p, fown, fa, band);
}
out:
read_unlock(&tasklist_lock);
}

-void kill_fasync(struct fasync_struct *fa, int sig)
+void kill_fasync(struct fasync_struct *fa, int sig, int band)
{
while (fa) {
struct fown_struct * fown;
@@ -316,8 +318,11 @@
return;
}
fown = &fa->fa_file->f_owner;
- if (fown->pid)
- send_sigio(fown, fa);
+ /* Don't send SIGURG to processes which have not set a
+ queued signum: SIGURG has its own default signalling
+ mechanism. */
+ if (fown->pid && !(sig == SIGURG && fown->signum == 0))
+ send_sigio(fown, fa, band);
fa = fa->fa_next;
}
}
--- include/linux/fs.h.~1~ Thu Aug 19 14:23:51 1999
+++ include/linux/fs.h Thu Aug 19 20:04:29 1999
@@ -720,7 +720,7 @@
#define __getname() ((char *) __get_free_page(GFP_KERNEL))
#define putname(name) free_page((unsigned long)(name))

-extern void kill_fasync(struct fasync_struct *, int);
+extern void kill_fasync(struct fasync_struct *, int, int);
extern int register_blkdev(unsigned int, const char *, struct file_operations *);
extern int unregister_blkdev(unsigned int, const char *);
extern int blkdev_open(struct inode *, struct file *);
--- include/linux/net.h.~1~ Thu Aug 19 14:23:50 1999
+++ include/linux/net.h Thu Aug 19 19:58:12 1999
@@ -127,7 +127,7 @@
};

extern struct net_proto_family *net_families[];
-extern int sock_wake_async(struct socket *sk, int how);
+extern int sock_wake_async(struct socket *sk, int how, int band);
extern int sock_register(struct net_proto_family *fam);
extern int sock_unregister(int family);
extern struct socket *sock_alloc(void);
--- net/core/sock.c.~1~ Thu Aug 19 14:22:17 1999
+++ net/core/sock.c Thu Aug 19 19:58:12 1999
@@ -1002,7 +1002,7 @@
{
if (!sk->dead) {
wake_up_interruptible(sk->sleep);
- sock_wake_async(sk->socket,0);
+ sock_wake_async(sk->socket,0,POLL_ERR);
}
}

@@ -1010,7 +1010,7 @@
{
if(!sk->dead) {
wake_up_interruptible(sk->sleep);
- sock_wake_async(sk->socket,1);
+ sock_wake_async(sk->socket,1,POLL_IN);
}
}

@@ -1025,7 +1025,7 @@

/* Should agree with poll, otherwise some programs break */
if (sock_writeable(sk))
- sock_wake_async(sk->socket, 2);
+ sock_wake_async(sk->socket, 2, POLL_OUT);
}
}

--- net/decnet/dn_nsp_in.c.~1~ Wed Jun 23 10:17:07 1999
+++ net/decnet/dn_nsp_in.c Thu Aug 19 20:07:31 1999
@@ -423,7 +423,7 @@
struct socket *sock = sk->socket;
wake_up_interruptible(sk->sleep);
if (!(sock->flags & SO_WAITDATA) && sock->fasync_list)
- kill_fasync(sock->fasync_list, SIGURG);
+ kill_fasync(sock->fasync_list, SIGURG, POLL_PRI);
}

return 0;
--- net/ipv4/tcp.c.~1~ Wed Jul 14 19:09:35 1999
+++ net/ipv4/tcp.c Thu Aug 19 19:58:12 1999
@@ -617,7 +617,7 @@
wake_up_interruptible(sk->sleep);
if (sock_wspace(sk) >=
tcp_min_write_space(sk))
- sock_wake_async(sk->socket, 2);
+ sock_wake_async(sk->socket, 2, POLL_OUT);
}


--- net/ipv4/tcp_input.c.~1~ Wed Jul 14 19:09:35 1999
+++ net/ipv4/tcp_input.c Thu Aug 19 20:16:30 1999
@@ -1135,7 +1135,7 @@

if (!sk->dead) {
sk->state_change(sk);
- sock_wake_async(sk->socket, 1);
+ sock_wake_async(sk->socket, 1, POLL_HUP);
}

switch(sk->state) {
@@ -1674,6 +1674,7 @@
kill_proc(sk->proc, SIGURG, 1);
else
kill_pg(-sk->proc, SIGURG, 1);
+ sock_wake_async(sk->socket, 3, POLL_PRI);
}

/* We may be adding urgent data when the last byte read was
@@ -2236,7 +2237,7 @@

if(!sk->dead) {
sk->state_change(sk);
- sock_wake_async(sk->socket, 0);
+ sock_wake_async(sk->socket, 0, POLL_IN);
}
} else {
if(th->syn && !th->rst) {
--- net/socket.c.~1~ Wed Jul 14 19:09:36 1999
+++ net/socket.c Thu Aug 19 20:06:23 1999
@@ -549,7 +549,7 @@
return 0;
}

-int sock_wake_async(struct socket *sock, int how)
+int sock_wake_async(struct socket *sock, int how, int band)
{
if (!sock || !sock->fasync_list)
return -1;
@@ -567,8 +567,10 @@
case 0:
call_kill:
if(sock->fasync_list != NULL)
- kill_fasync(sock->fasync_list, SIGIO);
+ kill_fasync(sock->fasync_list, SIGIO, band);
break;
+ case 3:
+ kill_fasync(sock->fasync_list, SIGURG, band);
}
return 0;
}
--- net/unix/af_unix.c.~1~ Wed Jul 14 19:09:36 1999
+++ net/unix/af_unix.c Thu Aug 19 19:58:12 1999
@@ -1536,7 +1536,7 @@
return;
wake_up_interruptible(sk->sleep);
if (sk->sndbuf - (int)atomic_read(&sk->wmem_alloc) >= MIN_WRITE_SPACE)
- sock_wake_async(sk->socket, 2);
+ sock_wake_async(sk->socket, 2, POLL_OUT);
}

#ifdef CONFIG_PROC_FS
--- net/x25/x25_in.c.~1~ Mon Jul 27 07:35:58 1998
+++ net/x25/x25_in.c Thu Aug 19 19:58:12 1999
@@ -278,6 +278,7 @@
kill_proc(sk->proc, SIGURG, 1);
else
kill_pg(-sk->proc, SIGURG, 1);
+ sock_wake_async(sk, 3, POLL_URG);
}
x25_write_internal(sk, X25_INTERRUPT_CONFIRMATION);
break;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/