[haiku-commits] r41676 - in haiku/branches/developer/bonefish/signals: headers/private/kernel src/system/kernel

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 23 May 2011 14:30:55 +0200 (CEST)

Author: bonefish
Date: 2011-05-23 14:30:55 +0200 (Mon, 23 May 2011)
New Revision: 41676
Changeset: https://dev.haiku-os.org/changeset/41676

Modified:
   
haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h
   haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp
Log:
Refactoring: Moved the code from orphaned_process_group_check() that determines
whether the group is orphaned to new method ProcessGroup::IsOrphaned().


Modified: 
haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h
===================================================================
--- 
haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h 
    2011-05-23 11:37:48 UTC (rev 41675)
+++ 
haiku/branches/developer/bonefish/signals/headers/private/kernel/thread_types.h 
    2011-05-23 12:30:55 UTC (rev 41676)
@@ -581,6 +581,8 @@
                        void                            Publish(ProcessSession* 
session);
                        void                            
PublishLocked(ProcessSession* session);
 
+                       bool                            IsOrphaned() const;
+
                        void                            ScheduleOrphanedCheck();
                        void                            UnsetOrphanedCheck();
 

Modified: haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp
===================================================================
--- haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp        
2011-05-23 11:37:48 UTC (rev 41675)
+++ haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp        
2011-05-23 12:30:55 UTC (rev 41676)
@@ -866,6 +866,37 @@
 }
 
 
+/*!    Checks whether the process group is orphaned.
+       The caller must hold the group's lock.
+       \return \c true, if the group is orphaned, \c false otherwise.
+*/
+bool
+ProcessGroup::IsOrphaned() const
+{
+       // Orphaned Process Group: "A process group in which the parent of every
+       // member is either itself a member of the group or is not a member of 
the
+       // group's session." (Open Group Base Specs Issue 7)
+       bool orphaned = true;
+
+       Team* team = teams;
+       while (orphaned && team != NULL) {
+               team->LockTeamAndParent(false);
+
+               Team* parent = team->parent;
+               if (parent != NULL && parent->group_id != id
+                       && parent->session_id == fSession->id) {
+                       orphaned = false;
+               }
+
+               team->UnlockTeamAndParent();
+
+               team = team->group_next;
+       }
+
+       return orphaned;
+}
+
+
 void
 ProcessGroup::ScheduleOrphanedCheck()
 {
@@ -2396,10 +2427,6 @@
 static void
 orphaned_process_group_check()
 {
-       // Orphaned Process Group: "A process group in which the parent of every
-       // member is either itself a member of the group or is not a member of 
the
-       // group's session." (Open Group Base Specs Issue 7)
-
        // process as long as there are groups in the list
        while (true) {
                // remove the head from the list
@@ -2414,29 +2441,11 @@
 
                orphanedCheckLocker.Unlock();
 
-               // determine whether the process group is orphaned
                AutoLocker<ProcessGroup> groupLocker(group);
 
-               bool orphaned = true;
-
-               Team* team = group->teams;
-               while (orphaned && team != NULL) {
-                       team->LockTeamAndParent(false);
-
-                       Team* parent = team->parent;
-                       if (parent != NULL && parent->group_id != group->id
-                               && parent->session_id == group->Session()->id) {
-                               orphaned = false;
-                       }
-
-                       team->UnlockTeamAndParent();
-
-                       team = team->group_next;
-               }
-
                // If the group is orphaned and contains stopped processes, 
we're
                // supposed to send SIGHUP + SIGCONT.
-               if (orphaned && process_group_has_stopped_processes(group)) {
+               if (group->IsOrphaned() && 
process_group_has_stopped_processes(group)) {
                        Thread* currentThread = thread_get_current_thread();
 
                        Signal signal(SIGHUP, SI_USER, B_OK, 
currentThread->team->id);


Other related posts:

  • » [haiku-commits] r41676 - in haiku/branches/developer/bonefish/signals: headers/private/kernel src/system/kernel - ingo_weinhold