Remove write-only nchildren member from struct tcb
authorDenys Vlasenko <dvlasenk@redhat.com>
Tue, 21 Jun 2011 14:06:28 +0000 (16:06 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Tue, 21 Jun 2011 14:06:28 +0000 (16:06 +0200)
* defs.h: Remove nchildren member from struct tcb.
* process.c (handle_new_child): Remove inc/decrements of tcp->nchildren.
  (internal_fork): Likewise.
* strace.c (startup_attach): Likewise.
  (droptcb): Likewise.
  (alloc_tcb): Remove initialization of tcp->nchildren.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
defs.h
process.c
strace.c

diff --git a/defs.h b/defs.h
index d340cbd59b315b254d48d3fa7032d8568a35b291..ab24f7cfeb2598763565263b4c0ab0a2e0e1d826 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -368,9 +368,8 @@ struct tcb {
        struct timeval etime;   /* Syscall entry time */
                                /* Support for tracing forked processes */
        struct tcb *parent;     /* Parent of this process */
-       int nchildren;          /* # of traced children */
 #ifdef LINUX
-       int nclone_threads;     /* # of nchildren with CLONE_THREAD */
+       int nclone_threads;     /* # of children with CLONE_THREAD */
 #endif
                                /* (1st arg of wait4()) */
        long baddr;             /* `Breakpoint' address */
index 0584f54773f3e2c63b2234965738c6dfc35f14ab..2447452dc6ddf06f73ae4babfdd110c015174206 100644 (file)
--- a/process.c
+++ b/process.c
@@ -836,7 +836,6 @@ handle_new_child(struct tcb *tcp, int pid, int bpt)
                        sizeof tcpchild->inst);
        }
        tcpchild->parent = tcp;
-       tcp->nchildren++;
        if (tcpchild->flags & TCB_SUSPENDED) {
                /* The child was born suspended, due to our having
                   forced CLONE_PTRACE.  */
@@ -877,10 +876,8 @@ Process %u resumed (parent %d ready)\n",
                           new thread, there will never be a
                           TCB_CLONE_THREAD process that has
                           children.  */
-                       --tcp->nchildren;
                        tcp = tcp->parent;
                        tcpchild->parent = tcp;
-                       ++tcp->nchildren;
                }
                if (call_flags & CLONE_THREAD) {
                        tcpchild->flags |= TCB_CLONE_THREAD;
@@ -888,12 +885,10 @@ Process %u resumed (parent %d ready)\n",
                }
                if ((call_flags & CLONE_PARENT) &&
                    !(call_flags & CLONE_THREAD)) {
-                       --tcp->nchildren;
                        tcpchild->parent = NULL;
                        if (tcp->parent != NULL) {
                                tcp = tcp->parent;
                                tcpchild->parent = tcp;
-                               ++tcp->nchildren;
                        }
                }
        }
@@ -1023,7 +1018,6 @@ internal_fork(struct tcb *tcp)
                                sizeof tcpchild->inst);
                }
                tcpchild->parent = tcp;
-               tcp->nchildren++;
                if (!qflag)
                        fprintf(stderr, "Process %d attached\n", pid);
        }
index 6fb6fd6eb610d35e1e28ac65e471e0760a7a5549..94559a5ca507ac3b4466a17a004d81e78f41eb9d 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -514,7 +514,6 @@ startup_attach(void)
                                        else if (tid != tcbtab[tcbi]->pid) {
                                                tcp = alloctcb(tid);
                                                tcp->flags |= TCB_ATTACHED|TCB_CLONE_THREAD|TCB_FOLLOWFORK;
-                                               tcbtab[tcbi]->nchildren++;
                                                tcbtab[tcbi]->nclone_threads++;
                                                tcp->parent = tcbtab[tcbi];
                                        }
@@ -1284,7 +1283,6 @@ alloc_tcb(int pid, int command_options_parsed)
                if ((tcp->flags & TCB_INUSE) == 0) {
                        tcp->pid = pid;
                        tcp->parent = NULL;
-                       tcp->nchildren = 0;
 #ifdef TCB_CLONE_THREAD
                        tcp->nclone_threads = 0;
 #endif
@@ -1662,15 +1660,14 @@ droptcb(struct tcb *tcp)
        tcp->pid = 0;
 
        if (tcp->parent != NULL) {
-               tcp->parent->nchildren--;
 #ifdef TCB_CLONE_THREAD
                if (tcp->flags & TCB_CLONE_THREAD)
                        tcp->parent->nclone_threads--;
 #endif
 #ifdef LINUX
-               /* Update `tcp->parent->parent->nchildren' and the other fields
-                  like NCLONE_DETACHED, only for zombie group leader that has
-                  already reported and been short-circuited at the top of this
+               /* Update fields like NCLONE_DETACHED, only
+                  for zombie group leader that has already reported
+                  and been short-circuited at the top of this
                   function.  The same condition as at the top of DETACH.  */
                if ((tcp->flags & TCB_CLONE_THREAD) &&
                    tcp->parent->nclone_threads == 0 &&