]> git.saurik.com Git - apple/security.git/blobdiff - securityd/src/connection.cpp
Security-59306.101.1.tar.gz
[apple/security.git] / securityd / src / connection.cpp
index ec973d843044faa0f81a415811aa8acd7f3b00c0..7b7e864f74d0ffe80f9db36adbf17c6fd82701fb 100644 (file)
@@ -56,7 +56,7 @@ Connection::Connection(Process &proc, Port rPort)
        // bump the send-rights count on the reply port so we keep the right after replying
        mClientPort.modRefs(MACH_PORT_RIGHT_SEND, +1);
        
-       SECURITYD_CLIENT_CONNECTION_NEW(this, rPort, &proc);
+    secinfo("SecServer", "New client connection %p: %d %d", this, rPort.port(), proc.uid());
 }
 
 
@@ -64,64 +64,25 @@ Connection::Connection(Process &proc, Port rPort)
 // When a Connection's destructor executes, the connection must already have been
 // terminated. All we have to do here is clean up a bit.
 //
-Connection::~Connection()
+Connection::~Connection() try
 {
-       SECURITYD_CLIENT_CONNECTION_RELEASE(this);
+    mClientPort.deallocate();
+    secinfo("SecServer", "releasing client connection %p", this);
        assert(!agentWait);
+} catch (...) {
+    secerror("SecServer: Error deallocating connection port");
+    return;
 }
 
-
 //
 // Set the (last known) guest handle for this connection.
 //
 void Connection::guestRef(SecGuestRef newGuest, SecCSFlags flags)
 {
-       secdebug("SS", "Connection %p switches to guest 0x%x", this, newGuest);
+       secinfo("SecServer", "Connection %p switches to guest 0x%x", this, newGuest);
        mGuestRef = newGuest;
 }
 
-
-//
-// Terminate a Connection normally.
-// This is assumed to be properly sequenced, so no thread races are possible.
-//
-void Connection::terminate()
-{
-       // cleanly discard port rights
-       assert(state == idle);
-       mClientPort.modRefs(MACH_PORT_RIGHT_SEND, -1);  // discard surplus send right
-       assert(mClientPort.getRefs(MACH_PORT_RIGHT_SEND) == 1); // one left for final reply
-       secdebug("SS", "Connection %p terminated", this);
-}
-
-
-//
-// Abort a Connection.
-// This may be called from thread A while thread B is working a request for the Connection,
-// so we must be careful.
-//
-void Connection::abort(bool keepReplyPort)
-{
-       StLock<Mutex> _(*this);
-    if (!keepReplyPort)
-        mClientPort.destroy();         // dead as a doornail already
-       switch (state) {
-       case idle:
-               secdebug("SS", "Connection %p aborted", this);
-               break;
-       case busy:
-               state = dying;                          // shoot me soon, please
-               if (agentWait)
-                       agentWait->disconnect();
-               secdebug("SS", "Connection %p abort deferred (busy)", this);
-               break;
-       default:
-               assert(false);                          // impossible (we hope)
-               break;
-       }
-}
-
-
 //
 // Service request framing.
 // These are here so "hanging" connection service threads don't fall
@@ -139,7 +100,7 @@ void Connection::beginWork(audit_token_t &auditToken)
                mOverrideReturn = CSSM_OK;      // clear override
                break;
        case busy:
-               secdebug("SS", "Attempt to re-enter connection %p(port %d)", this, mClientPort.port());
+               secinfo("SecServer", "Attempt to re-enter connection %p(port %d)", this, mClientPort.port());
                CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR);        //@@@ some state-error code instead?
        default:
                assert(false);
@@ -171,7 +132,7 @@ void Connection::endWork(CSSM_RETURN &rcode)
                state = idle;
                return;
        case dying:
-               secdebug("SS", "Connection %p abort resuming", this);
+               secinfo("SecServer", "Connection %p abort resuming", this);
                return;
        default:
                assert(false);