patch-2.3.11 linux/fs/proc/fd.c

Next file: linux/fs/proc/root.c
Previous file: linux/fs/proc/array.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.10/linux/fs/proc/fd.c linux/fs/proc/fd.c
@@ -133,7 +133,7 @@
 static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir)
 {
 	struct inode *inode = filp->f_dentry->d_inode;
-	struct task_struct * p, **tarrayp;
+	struct task_struct *p, *tmp;
 	unsigned int fd, pid, ino;
 	int retval;
 	char buf[NUMBUF];
@@ -157,7 +157,6 @@
 	p = find_task_by_pid(pid);
 	if (!p)
 		goto out_unlock;
-	tarrayp = p->tarray_ptr;
 
 	for (fd -= 2 ; p->files && fd < p->files->max_fds; fd++, filp->f_pos++)
 	{
@@ -182,8 +181,13 @@
 			goto out;
 
 		read_lock(&tasklist_lock);
-		/* filldir() might have slept, so we must re-validate "p" */
-		if (p != *tarrayp || p->pid != pid)
+		/*
+		 * filldir() might have slept, so we must
+		 * re-validate "p". This is fast enough due
+		 * to the pidhash
+		 */
+		tmp = find_task_by_pid(pid);
+		if (p != tmp)
 			break;
 	}
 out_unlock:

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)