libcutils/mq.c
static void peerProxyRead(SelectableFd* fd) {
    LOGD("Reading...");
    PeerProxy* peerProxy = (PeerProxy*) fd->data;
    int state = peerProxy->inputState;
    Buffer* in = peerProxy->inputBuffer;
    switch (state) {
        case READING_HEADER:
            if (peerProxyBufferInput(peerProxy)) {
                LOGD("Header read.");
                // We've read the complete header.
                Header* header = (Header*) in->data;
                peerProxyHandleHeader(peerProxy, header);
            }
            break;
        case READING_BYTES:
            LOGD("Reading bytes...");
            if (peerProxyBufferInput(peerProxy)) {
                LOGD("Bytes read.");
                // We have the complete packet. Notify bytes listener.
                peerProxy->peer->onBytes(peerProxy->credentials,
                    in->data, in->size);
                        
                // Get ready for the next packet.
                peerProxyExpectHeader(peerProxy);
            }
            break;
        case ACCEPTING_CONNECTION:
            masterProxyAcceptConnection(peerProxy);
            break;
        default:
            LOG_ALWAYS_FATAL("Unknown state: %d", state);
    }
}
/**
 * Reads input from a peer process.
 */
Reads input from a peer process.
Reads input from a peer process .
static void peerProxyRead(SelectableFd* fd) {
    LOGD("Reading...");
    PeerProxy* peerProxy = (PeerProxy*) fd->data;
    int state = peerProxy->inputState;
    Buffer* in = peerProxy->inputBuffer;
    switch (state) {
        case READING_HEADER:
            if (peerProxyBufferInput(peerProxy)) {
                LOGD("Header read.");
                Header* header = (Header*) in->data;
                peerProxyHandleHeader(peerProxy, header);
            }
            break;
        case READING_BYTES:
            LOGD("Reading bytes...");
            if (peerProxyBufferInput(peerProxy)) {
                LOGD("Bytes read.");
                peerProxy->peer->onBytes(peerProxy->credentials,
                    in->data, in->size);
                peerProxyExpectHeader(peerProxy);
            }
            break;
        case ACCEPTING_CONNECTION:
            masterProxyAcceptConnection(peerProxy);
            break;
        default:
            LOG_ALWAYS_FATAL("Unknown state: %d", state);
    }
}
static void peerProxyRead ( SelectableFd * fd ) { LOGD ( " " ) ; PeerProxy * peerProxy = ( PeerProxy * ) fd -> data ; int state = peerProxy -> inputState ; Buffer * in = peerProxy -> inputBuffer ; switch ( state ) { case READING_HEADER : if ( peerProxyBufferInput ( peerProxy ) ) { LOGD ( " " ) ; Header * header = ( Header * ) in -> data ; peerProxyHandleHeader ( peerProxy , header ) ; } break ; case READING_BYTES : LOGD ( " " ) ; if ( peerProxyBufferInput ( peerProxy ) ) { LOGD ( " " ) ; peerProxy -> peer -> onBytes ( peerProxy -> credentials , in -> data , in -> size ) ; peerProxyExpectHeader ( peerProxy ) ; } break ; case ACCEPTING_CONNECTION : masterProxyAcceptConnection ( peerProxy ) ; break ; default : LOG_ALWAYS_FATAL ( " " , state ) ; } }
Reads input from a peer process.
Reads input from a peer process .
// We've read the complete header. // We have the complete packet. Notify bytes listener. // Get ready for the next packet.