From ef99a9576fc6beeae0c584a05e1f90d37b9bf18f Mon Sep 17 00:00:00 2001 From: mav Date: Sat, 8 Nov 2008 06:25:57 +0000 Subject: Don't use curthread to resolve file descriptor. Request may be queued, so thread will be different. Instead require sender to send process ID together with file descriptor. --- sys/netgraph/ng_tty.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sys/netgraph/ng_tty.c') diff --git a/sys/netgraph/ng_tty.c b/sys/netgraph/ng_tty.c index 5cab971..c504b84 100644 --- a/sys/netgraph/ng_tty.c +++ b/sys/netgraph/ng_tty.c @@ -73,6 +73,7 @@ #include #include #include +#include #include #include @@ -250,7 +251,8 @@ ngt_shutdown(node_p node) static int ngt_rcvmsg(node_p node, item_p item, hook_p lasthook) { - struct thread *td = curthread; /* XXX */ + struct proc *p; + struct thread *td; const sc_p sc = NG_NODE_PRIVATE(node); struct ng_mesg *msg, *resp = NULL; int error = 0; @@ -262,8 +264,14 @@ ngt_rcvmsg(node_p node, item_p item, hook_p lasthook) case NGM_TTY_SET_TTY: if (sc->tp != NULL) return (EBUSY); - error = ttyhook_register(&sc->tp, td, *(int *)msg->data, + + p = pfind(((int *)msg->data)[0]); + if (p == NULL) + return (ESRCH); + td = FIRST_THREAD_IN_PROC(p); + error = ttyhook_register(&sc->tp, td, ((int *)msg->data)[1], &ngt_hook, sc); + PROC_UNLOCK(p); if (error != 0) return (error); break; -- cgit v1.1