Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Nov 2008 06:25:57 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r184762 - head/sys/netgraph
Message-ID:  <200811080625.mA86Pvhw003486@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Nov  8 06:25:57 2008
New Revision: 184762
URL: http://svn.freebsd.org/changeset/base/184762

Log:
  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.

Modified:
  head/sys/netgraph/ng_tty.c

Modified: head/sys/netgraph/ng_tty.c
==============================================================================
--- head/sys/netgraph/ng_tty.c	Sat Nov  8 04:43:24 2008	(r184761)
+++ head/sys/netgraph/ng_tty.c	Sat Nov  8 06:25:57 2008	(r184762)
@@ -73,6 +73,7 @@
 #include <sys/syslog.h>
 #include <sys/tty.h>
 #include <sys/ttycom.h>
+#include <sys/proc.h>
 
 #include <net/if.h>
 #include <net/if_var.h>
@@ -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, hoo
 		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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811080625.mA86Pvhw003486>