mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frederic Rossi <frederic.rossi@ericsson.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] AEM v0.5.1, linux-2.6.0-test9
Date: Tue, 25 Nov 2003 16:49:09 -0500	[thread overview]
Message-ID: <16323.52821.540686.388083@localhost.localdomain> (raw)



AEM is an extension providing a native support for asynchronous events 
in the Linux kernel. Below a patch for the previous v0.5 fixes 
some issues when event handlers are forked.

Package: mod_aem-2.6
Version: v0.5.1

Modules+patches at: 
http://sourceforge.net/projects/aem

Changelog:
 * Fix the forked events termination procedure


Frederic





Index: aem/module/2.6.0-test9/aem-core/src/kernel/events.c
diff -u aem/module/2.6.0-test9/aem-core/src/kernel/events.c:1.1 aem/module/2.6.0-test9/aem-core/src/kernel/events.c:1.4
--- aem/module/2.6.0-test9/aem-core/src/kernel/events.c:1.1	Tue Nov 18 08:10:40 2003
+++ aem/module/2.6.0-test9/aem-core/src/kernel/events.c	Mon Nov 24 07:54:03 2003
@@ -366,13 +377,12 @@
 	REMOVE_LINKS (task);
 	task->parent = task->real_parent = adopter;
 	SET_LINKS (task);
-
+	
+	/* Post SIGCHLD */
 	spin_lock (&adopter->sighand->siglock);
 	sigaddset (&adopter->pending.signal, SIGCHLD);
 	recalc_sigpending_tsk (adopter);
 	spin_unlock (&adopter->sighand->siglock);
-
-	wake_up_process (adopter);
 }
 
 void forget_child (struct task_struct *task)
@@ -420,46 +430,61 @@
 		 * it is destroyed here.
 		 */
 		unsigned long jflags;
-		struct event_struct *evc = task->cloner;
+		struct event_struct *evc;
 		struct task_struct *root;
 
-		root = evc->root;
+		if (task->parent->pid == 1)
+			/* The parent has exited */
+			goto cleanup_events;
+		
+		/* This is the event cloner... */
+		evc = task->cloner;
+
+		/* If the process is present, the event is still present too */
+		root = task->parent;
+		if (evc->root != root)
+			/* Sanity check */
+			goto cleanup_events;
 
 		if (get_task (root)) {
-			local_bh_disable ();
-		spin_lock (&evc->lock);
+			unsigned long flags;
 
-		jflags = (evc->jargs)? evc->jargs->flags: 0;
+			local_irq_save (flags);
+			spin_lock (&evc->lock);
 
-		if (jflags && ((jflags & EVF_FORK) || (jflags & EVF_CAPSULE))) {
+			jflags = (evc->jargs)? evc->jargs->flags: 0;
+
+			if (jflags && ((jflags & EVF_FORK) || (jflags & EVF_CAPSULE))) {
 				struct job_struct *job = job_lookup (evc->jid);
 			
-				local_bh_enable ();
-			__event_dtor (evc);
-				local_bh_disable ();
+				/* Called with irq disabled -- will be changed */
+				__event_dtor (evc);
 			
-			if (jflags & EVF_NOCLDWAIT)
-				__forget_child (task);
+				if (jflags & EVF_NOCLDWAIT) {
+					__forget_child (task);
+					wake_up_process (capm);
+				}
 			
-			if (jflags & EVF_ONESHOT || (job && job->shutdown == JOB_SHUTDOWN)) {
-				__events_remove (evc, job);
-				kfree (evc);
-				goto cont;
+				if (jflags & EVF_ONESHOT || (job && job->shutdown == JOB_SHUTDOWN)) {
+					__events_remove (evc, job);
+					kfree (evc);
+					goto cont;
+				}
+			}
+			else {
+				/* The event has probably been removed by the user */
+				__forget_child (task);
+				wake_up_process (capm);
 			}
-		}
-		else {
-                        /* The event has probably been removed by the user */
-			__forget_child (task);
-		}
 
-		spin_unlock (&evc->lock);
-        cont:
-		put_task (root);
-			local_bh_enable ();
+			spin_unlock (&evc->lock);
+		cont:
+			local_irq_restore (flags);
+			put_task (root);
 		}
 	}
 
-again:
+cleanup_events:
 	spin_lock_irq (&task->evlock);
 	list_for_each (curr, &task->events) {
 		
@@ -481,7 +506,7 @@
 		job = job_hash_find (ev->jid);
 		__events_remove (ev, job);
 		kfree (ev);
-		goto again;
+		goto cleanup_events;
 	}
 
 	list_del_init (&task->events);

                 reply	other threads:[~2003-11-25 21:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16323.52821.540686.388083@localhost.localdomain \
    --to=frederic.rossi@ericsson.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®