]> git.saurik.com Git - apple/securityd.git/blobdiff - src/child.cpp
securityd-55199.3.tar.gz
[apple/securityd.git] / src / child.cpp
index 2a5db79d6af091412da73d79962e35fb0dfaf9e2..812c6118aa22262023c3276575880571a80e91c6 100644 (file)
@@ -26,6 +26,7 @@
 // child - track a single child process and its belongings
 //
 #include "child.h"
 // child - track a single child process and its belongings
 //
 #include "child.h"
+#include "dtrace.h"
 #include <security_utilities/debugging.h>
 
 
 #include <security_utilities/debugging.h>
 
 
@@ -47,7 +48,7 @@ ServerChild::ServerChild()
 //
 // If the ServerChild is destroyed, kill its process, nice or hard.
 //
 //
 // If the ServerChild is destroyed, kill its process, nice or hard.
 //
-// In case  you wonder about the tango below, it's making sure we
+// In case you wonder about the tango below, it's making sure we
 // get to "It's dead, Jim" with the minimum number of checkChildren()
 // calls while still working correctly if this is the only thread alive.
 //
 // get to "It's dead, Jim" with the minimum number of checkChildren()
 // calls while still working correctly if this is the only thread alive.
 //
@@ -56,6 +57,8 @@ ServerChild::ServerChild()
 //
 ServerChild::~ServerChild()
 {
 //
 ServerChild::~ServerChild()
 {
+       mServicePort.destroy();
+       
        if (state() == alive) {
                this->kill(SIGTERM);            // shoot it once
                checkChildren();                        // check for quick death
        if (state() == alive) {
                this->kill(SIGTERM);            // shoot it once
                checkChildren();                        // check for quick death
@@ -90,10 +93,12 @@ void ServerChild::parentAction()
        if (state() == dead) {
                // our child died
                secdebug("serverchild", "%p (pid %d) died before checking in", this, pid());
        if (state() == dead) {
                // our child died
                secdebug("serverchild", "%p (pid %d) died before checking in", this, pid());
+               SECURITYD_CHILD_STILLBORN(this->pid());
        } else if (ready()) {
                // child has checked in and is ready for service
                secdebug("serverchild", "%p (pid %d) ready for service on port %d",
                        this, pid(), mServicePort.port());
        } else if (ready()) {
                // child has checked in and is ready for service
                secdebug("serverchild", "%p (pid %d) ready for service on port %d",
                        this, pid(), mServicePort.port());
+               SECURITYD_CHILD_READY(this->pid());
        } else
                assert(false);          // how did we ever get here?!
 }
        } else
                assert(false);          // how did we ever get here?!
 }
@@ -104,6 +109,7 @@ void ServerChild::parentAction()
 //
 void ServerChild::dying()
 {
 //
 void ServerChild::dying()
 {
+       SECURITYD_CHILD_DYING(this->pid());
        secdebug("serverchild", "%p is dead; resuming parent thread (if any)", this);
        mCheckinCond.signal();
 }
        secdebug("serverchild", "%p is dead; resuming parent thread (if any)", this);
        mCheckinCond.signal();
 }
@@ -120,10 +126,12 @@ void ServerChild::checkIn(Port servicePort, pid_t pid)
                        secdebug("serverchild", "%p (pid %d) checking in; resuming parent thread",
                                child, pid);
                }
                        secdebug("serverchild", "%p (pid %d) checking in; resuming parent thread",
                                child, pid);
                }
+               SECURITYD_CHILD_CHECKIN(pid, servicePort);
                child->mCheckinCond.signal();
        } else {
                // Child has died; is wrong kind; or spurious checkin.
                // If it was a proper child, death notifications will wake up the parent thread
                secdebug("serverchild", "pid %d not in child set; checkin ignored", pid);
                child->mCheckinCond.signal();
        } else {
                // Child has died; is wrong kind; or spurious checkin.
                // If it was a proper child, death notifications will wake up the parent thread
                secdebug("serverchild", "pid %d not in child set; checkin ignored", pid);
+               SECURITYD_CHILD_CHECKIN(pid, 0);
        }
 }
        }
 }