libcutils/mq.c
static void masterProxyExpectConnection(PeerProxy* masterProxy,
        Header* header) {
    // TODO: Restructure things so we don't need this check.
    // Verify that this really is the master.
    if (!masterProxy->master) {
        LOGW("Non-master process %d tried to send us a connection.", 
            masterProxy->credentials.pid);
        // Kill off the evil peer.
        peerProxyKill(masterProxy, false);
        return;
    }
    
    masterProxy->inputState = ACCEPTING_CONNECTION;
    Peer* localPeer = masterProxy->peer;
   
    // Create a peer proxy so we have somewhere to stash the creds.
    // See if we already have a proxy set up.
    pid_t pid = header->credentials.pid;
    peerLock(localPeer);
    PeerProxy* peerProxy = peerProxyGetOrCreate(localPeer, pid, false);
    if (peerProxy == NULL) {
        LOGW("Peer proxy creation failed: %s", strerror(errno));
    } else {
        // Fill in full credentials.
        peerProxy->credentials = header->credentials;
    }
    peerUnlock(localPeer);
    
    // Keep track of which peer proxy we're accepting a connection for.
    masterProxy->connecting = peerProxy;
}
/**
 * Switches the master peer proxy into a state where it's waiting for a
 * connection from the master.
 */
Switches the master peer proxy into a state where it's waiting for a
connection from the master.
Switches the master peer proxy into a state where it ' s waiting for a connection from the master .
static void masterProxyExpectConnection(PeerProxy* masterProxy,
        Header* header) {
    if (!masterProxy->master) {
        LOGW("Non-master process %d tried to send us a connection.", 
            masterProxy->credentials.pid);
        peerProxyKill(masterProxy, false);
        return;
    }
    masterProxy->inputState = ACCEPTING_CONNECTION;
    Peer* localPeer = masterProxy->peer;
    pid_t pid = header->credentials.pid;
    peerLock(localPeer);
    PeerProxy* peerProxy = peerProxyGetOrCreate(localPeer, pid, false);
    if (peerProxy == NULL) {
        LOGW("Peer proxy creation failed: %s", strerror(errno));
    } else {
        peerProxy->credentials = header->credentials;
    }
    peerUnlock(localPeer);
    masterProxy->connecting = peerProxy;
}
static void masterProxyExpectConnection ( PeerProxy * masterProxy , Header * header ) { if ( ! masterProxy -> master ) { LOGW ( " " , masterProxy -> credentials . pid ) ; peerProxyKill ( masterProxy , false ) ; return ; } masterProxy -> inputState = ACCEPTING_CONNECTION ; Peer * localPeer = masterProxy -> peer ; pid_t pid = header -> credentials . pid ; peerLock ( localPeer ) ; PeerProxy * peerProxy = peerProxyGetOrCreate ( localPeer , pid , false ) ; if ( peerProxy == NULL ) { LOGW ( " " , strerror ( errno ) ) ; } else { peerProxy -> credentials = header -> credentials ; } peerUnlock ( localPeer ) ; masterProxy -> connecting = peerProxy ; }
Switches the master peer proxy into a state where it's waiting for a
 connection from the master.
Switches the master peer proxy into a state where it ' s waiting for a connection from the master .
// TODO: Restructure things so we don't need this check. // Verify that this really is the master. // Kill off the evil peer. // Create a peer proxy so we have somewhere to stash the creds. // See if we already have a proxy set up. // Fill in full credentials. // Keep track of which peer proxy we're accepting a connection for.