patch-2.1.117 linux/kernel/signal.c

Next file: linux/kernel/sysctl.c
Previous file: linux/kernel/sched.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.116/linux/kernel/signal.c linux/kernel/signal.c
@@ -35,6 +35,9 @@
 
 static kmem_cache_t *signal_queue_cachep;
 
+static int nr_queued_signals;
+static int max_queued_signals = 1024;
+
 void
 signals_init(void)
 {
@@ -64,6 +67,7 @@
 	while (q) {
 		n = q->next;
 		kmem_cache_free(signal_queue_cachep, q);
+		nr_queued_signals--;
 		q = n;
 	}
 }
@@ -160,7 +164,8 @@
 					current->sigqueue_tail = pp;
 				*info = q->info;
 				kmem_cache_free(signal_queue_cachep,q);
-
+				nr_queued_signals--;
+				
 				/* then see if this signal is still pending. */
 				q = *pp;
 				while (q) {
@@ -300,9 +305,14 @@
 		   make sure at least one signal gets delivered and don't
 		   pass on the info struct.  */
 
-		struct signal_queue *q = (struct signal_queue *)
-			kmem_cache_alloc(signal_queue_cachep, GFP_KERNEL);
+		struct signal_queue *q = 0;
 
+		if (nr_queued_signals < max_queued_signals) {
+			q = (struct signal_queue *)
+			    kmem_cache_alloc(signal_queue_cachep, GFP_KERNEL);
+			nr_queued_signals++;
+		}
+		
 		if (q) {
 			q->next = NULL;
 			*t->sigqueue_tail = q;
@@ -825,6 +835,7 @@
 					else {
 						*pp = q->next;
 						kmem_cache_free(signal_queue_cachep, q);
+						nr_queued_signals--;
 					}
 					q = *pp;
 				}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov