lkml.org 
[lkml]   [2006]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] simplify/fix first_tid()
From
Date
Oleg Nesterov <oleg@tv-sign.ru> writes:

> first_tid:
>
> /* If nr exceeds the number of threads there is nothing todo */
> if (nr) {
> if (nr >= get_nr_threads(leader))
> goto done;
> }
>
> This is not reliable: sub-threads can exit after this check, so the
> 'for' loop below can overlap and proc_task_readdir() can return an
> already filldir'ed dirents.
>
> for (; pos && pid_alive(pos); pos = next_thread(pos)) {
> if (--nr > 0)
> continue;
>
> Off-by-one error, will return 'leader' when nr == 1.
>
> This patch tries to fix these problems and simplify the code.

This is better however if I read this code correctly. It modifies
the code so the last time user space goes trough this loop
with nr > nr_threads. Then we will walk the entire threads
list to achieve nothing.

So we really still need the nr_threads test in there so we don't
traverse the list twice everytime through readdir.

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

\
 
 \ /
  Last update: 2006-03-20 19:04    [W:0.187 / U:0.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site