s3-prefrok: Handle only valid children
authorSimo Sorce <idra@samba.org>
Tue, 16 Aug 2011 15:07:27 +0000 (11:07 -0400)
committerSimo Sorce <idra@samba.org>
Sun, 21 Aug 2011 13:05:05 +0000 (09:05 -0400)
Children that are about to exit shouldn't be counted as a source of
connections, and also makes no sense to chenge their allowances if they are
about to exit.
Also children with negative num_clients are faulty, exclude them as well.

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
source3/lib/server_prefork.c

index 7d675485a045c791c7159bc5b81091a7a5b94e9c..71441c3303bbea0eaef1577ec2e33a675718d1b2 100644 (file)
@@ -292,7 +292,7 @@ int prefork_count_active_children(struct prefork_pool *pfp, int *total)
 
                t++;
 
-               if (pfp->pool[i].num_clients == 0) {
+               if (pfp->pool[i].num_clients <= 0) {
                        continue;
                }
 
@@ -343,7 +343,12 @@ int prefork_count_allowed_connections(struct prefork_pool *pfp)
 
        c = 0;
        for (i = 0; i < pfp->pool_size; i++) {
-               if (pfp->pool[i].status == PF_WORKER_NONE) {
+               if (pfp->pool[i].status == PF_WORKER_NONE ||
+                   pfp->pool[i].status == PF_WORKER_EXITING) {
+                       continue;
+               }
+
+               if (pfp->pool[i].num_clients < 0) {
                        continue;
                }
 
@@ -358,7 +363,12 @@ void prefork_increase_allowed_clients(struct prefork_pool *pfp, int max)
        int i;
 
        for (i = 0; i < pfp->pool_size; i++) {
-               if (pfp->pool[i].status == PF_WORKER_NONE) {
+               if (pfp->pool[i].status == PF_WORKER_NONE ||
+                   pfp->pool[i].status == PF_WORKER_EXITING) {
+                       continue;
+               }
+
+               if (pfp->pool[i].num_clients < 0) {
                        continue;
                }
 
@@ -373,7 +383,12 @@ void prefork_decrease_allowed_clients(struct prefork_pool *pfp)
        int i;
 
        for (i = 0; i < pfp->pool_size; i++) {
-               if (pfp->pool[i].status == PF_WORKER_NONE) {
+               if (pfp->pool[i].status == PF_WORKER_NONE ||
+                   pfp->pool[i].status == PF_WORKER_EXITING) {
+                       continue;
+               }
+
+               if (pfp->pool[i].num_clients < 0) {
                        continue;
                }