Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit abffc7f7 authored by Jean-Baptiste Queru's avatar Jean-Baptiste Queru Committed by Android Git Automerger
Browse files

am fa7860a2: Merge changes Iff15ac5e,I52fce957,I6c2a1d56,I929ea38b,Ia0476219,Ia9a357de,Ifb82ae2c

* commit 'fa7860a2':
  Rename LOG_ASSERT to ALOG_ASSERT
  Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF)
  Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF)
  Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF)
  Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF)
  Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF)
  Rename (IF_)LOG() to (IF_)ALOG()
parents 37a5ecfb fa7860a2
Loading
Loading
Loading
Loading
+111 −55
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ extern "C" {
// ---------------------------------------------------------------------

/*
 * Normally we strip LOGV (VERBOSE messages) from release builds.
 * Normally we strip ALOGV (VERBOSE messages) from release builds.
 * You can modify this (for example with "#define LOG_NDEBUG 0"
 * at the top of your source file) to change that behavior.
 */
@@ -73,91 +73,121 @@ extern "C" {
/*
 * Simplified macro to send a verbose log message using the current LOG_TAG.
 */
#ifndef LOGV
#ifndef ALOGV
#if LOG_NDEBUG
#define LOGV(...)   ((void)0)
#define ALOGV(...)   ((void)0)
#else
#define LOGV(...) ((void)LOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#endif
// Temporary measure for code still using old LOG macros.
#ifndef LOGV
#define LOGV ALOGV
#endif
#define ALOGV LOGV
#endif

#define CONDITION(cond)     (__builtin_expect((cond)!=0, 0))

#ifndef LOGV_IF
#ifndef ALOGV_IF
#if LOG_NDEBUG
#define LOGV_IF(cond, ...)   ((void)0)
#define ALOGV_IF(cond, ...)   ((void)0)
#else
#define LOGV_IF(cond, ...) \
#define ALOGV_IF(cond, ...) \
    ( (CONDITION(cond)) \
    ? ((void)LOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
    ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
    : (void)0 )
#endif
#define ALOGV_IF LOGV_IF
// Temporary measure for code still using old LOG macros.
#ifndef LOGV_IF
#define LOGV_IF ALOGV_IF
#endif
#endif

/*
 * Simplified macro to send a debug log message using the current LOG_TAG.
 */
#ifndef ALOGD
#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
// Temporary measure for code still using old LOG macros.
#ifndef LOGD
#define LOGD(...) ((void)LOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#define ALOGD LOGD
#define LOGD ALOGD
#endif
#endif

#ifndef LOGD_IF
#define LOGD_IF(cond, ...) \
#ifndef ALOGD_IF
#define ALOGD_IF(cond, ...) \
    ( (CONDITION(cond)) \
    ? ((void)LOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
    ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
    : (void)0 )
#define ALOGD_IF LOGD_IF
// Temporary measure for code still using old LOG macros.
#ifndef LOGD_IF
#define LOGD_IF ALOGD_IF
#endif
#endif

/*
 * Simplified macro to send an info log message using the current LOG_TAG.
 */
#ifndef ALOGI
#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
// Temporary measure for code still using old LOG macros.
#ifndef LOGI
#define LOGI(...) ((void)LOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
#define ALOGI LOGI
#define LOGI ALOGI
#endif
#endif

#ifndef LOGI_IF
#define LOGI_IF(cond, ...) \
#ifndef ALOGI_IF
#define ALOGI_IF(cond, ...) \
    ( (CONDITION(cond)) \
    ? ((void)LOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
    ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
    : (void)0 )
#define ALOGI_IF LOGI_IF
// Temporary measure for code still using old LOG macros.
#ifndef LOGI_IF
#define LOGI_IF ALOGI_IF
#endif
#endif

/*
 * Simplified macro to send a warning log message using the current LOG_TAG.
 */
#ifndef ALOGW
#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
// Temporary measure for code still using old LOG macros.
#ifndef LOGW
#define LOGW(...) ((void)LOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
#define ALOGW LOGW
#define LOGW ALOGW
#endif
#endif

#ifndef LOGW_IF
#define LOGW_IF(cond, ...) \
#ifndef ALOGW_IF
#define ALOGW_IF(cond, ...) \
    ( (CONDITION(cond)) \
    ? ((void)LOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
    ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
    : (void)0 )
#define ALOGW_IF LOGW_IF
// Temporary measure for code still using old LOG macros.
#ifndef LOGW_IF
#define LOGW_IF ALOGW_IF
#endif
#endif

/*
 * Simplified macro to send an error log message using the current LOG_TAG.
 */
#ifndef ALOGE
#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
// Temporary measure for code still using old LOG macros.
#ifndef LOGE
#define LOGE(...) ((void)LOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
#define ALOGE LOGE
#define LOGE ALOGE
#endif
#endif

#ifndef LOGE_IF
#define LOGE_IF(cond, ...) \
#ifndef ALOGE_IF
#define ALOGE_IF(cond, ...) \
    ( (CONDITION(cond)) \
    ? ((void)LOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
    ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
    : (void)0 )
#define ALOGE_IF LOGE_IF
// Temporary measure for code still using old LOG macros.
#ifndef LOGE_IF
#define LOGE_IF ALOGE_IF
#endif
#endif

// ---------------------------------------------------------------------
@@ -166,49 +196,64 @@ extern "C" {
 * Conditional based on whether the current LOG_TAG is enabled at
 * verbose priority.
 */
#ifndef IF_LOGV
#ifndef IF_ALOGV
#if LOG_NDEBUG
#define IF_LOGV() if (false)
#define IF_ALOGV() if (false)
#else
#define IF_LOGV() IF_LOG(LOG_VERBOSE, LOG_TAG)
#define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG)
#endif
// Temporary measure for code still using old LOG macros.
#ifndef IF_LOGV
#define IF_LOGV IF_ALOGV
#endif
#define IF_ALOGV IF_LOGV
#endif

/*
 * Conditional based on whether the current LOG_TAG is enabled at
 * debug priority.
 */
#ifndef IF_ALOGD
#define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG)
// Temporary measure for code still using old LOG macros.
#ifndef IF_LOGD
#define IF_LOGD() IF_LOG(LOG_DEBUG, LOG_TAG)
#define IF_ALOGD IF_LOGD
#define IF_LOGD IF_ALOGD
#endif
#endif

/*
 * Conditional based on whether the current LOG_TAG is enabled at
 * info priority.
 */
#ifndef IF_ALOGI
#define IF_ALOGI() IF_ALOG(LOG_INFO, LOG_TAG)
// Temporary measure for code still using old LOG macros.
#ifndef IF_LOGI
#define IF_LOGI() IF_LOG(LOG_INFO, LOG_TAG)
#define IF_ALOGI IF_LOGI
#define IF_LOGI IF_ALOGI
#endif
#endif

/*
 * Conditional based on whether the current LOG_TAG is enabled at
 * warn priority.
 */
#ifndef IF_ALOGW
#define IF_ALOGW() IF_ALOG(LOG_WARN, LOG_TAG)
// Temporary measure for code still using old LOG macros.
#ifndef IF_LOGW
#define IF_LOGW() IF_LOG(LOG_WARN, LOG_TAG)
#define IF_ALOGW IF_LOGW
#define IF_LOGW IF_ALOGW
#endif
#endif

/*
 * Conditional based on whether the current LOG_TAG is enabled at
 * error priority.
 */
#ifndef IF_ALOGE
#define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG)
// Temporary measure for code still using old LOG macros.
#ifndef IF_LOGE
#define IF_LOGE() IF_LOG(LOG_ERROR, LOG_TAG)
#define IF_ALOGE IF_LOGE
#define IF_LOGE IF_ALOGE
#endif
#endif


@@ -344,10 +389,13 @@ extern "C" {
 * Assertion that generates a log message when the assertion fails.
 * Stripped out of release builds.  Uses the current LOG_TAG.
 */
#ifndef ALOG_ASSERT
#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__)
//#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond)
// Temporary measure for code still using old LOG macros.
#ifndef LOG_ASSERT
#define LOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__)
//#define LOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond)
#define ALOG_ASSERT LOG_ASSERT
#define LOG_ASSERT ALOG_ASSERT
#endif
#endif

// ---------------------------------------------------------------------
@@ -356,13 +404,17 @@ extern "C" {
 * Basic log message macro.
 *
 * Example:
 *  LOG(LOG_WARN, NULL, "Failed with error %d", errno);
 *  ALOG(LOG_WARN, NULL, "Failed with error %d", errno);
 *
 * The second argument may be NULL or "" to indicate the "global" tag.
 */
#ifndef LOG
#define LOG(priority, tag, ...) \
#ifndef ALOG
#define ALOG(priority, tag, ...) \
    LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
// Temporary measure for code still using old LOG macros.
#ifndef LOG
#define LOG ALOG
#endif
#endif

/*
@@ -384,9 +436,13 @@ extern "C" {
/*
 * Conditional given a desired logging priority and tag.
 */
#ifndef IF_LOG
#define IF_LOG(priority, tag) \
#ifndef IF_ALOG
#define IF_ALOG(priority, tag) \
    if (android_testLog(ANDROID_##priority, tag))
// Temporary measure for code still using old LOG macros.
#ifndef IF_LOG
#define IF_LOG IF_ALOG
#endif
#endif

// ---------------------------------------------------------------------
@@ -440,7 +496,7 @@ typedef enum {
    __android_log_vprint(prio, tag, fmt)

/* XXX Macros to work around syntax errors in places where format string
 * arg is not passed to LOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
 * arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
 * (happens only in debug builds).
 */

+3 −3
Original line number Diff line number Diff line
@@ -104,9 +104,9 @@ ssize_t bufferWrite(Buffer* buffer, int fd) {
    if (bytesWritten >= 0) {
        buffer->remaining -= bytesWritten;

        LOGD("Buffer bytes written: %d", (int) bytesWritten);
        LOGD("Buffer size: %d", (int) buffer->size);
        LOGD("Buffer remaining: %d", (int) buffer->remaining);        
        ALOGD("Buffer bytes written: %d", (int) bytesWritten);
        ALOGD("Buffer size: %d", (int) buffer->size);
        ALOGD("Buffer remaining: %d", (int) buffer->remaining);

        return buffer->remaining;
    }
+7 −7
Original line number Diff line number Diff line
@@ -25,14 +25,14 @@
#include <cutils/log.h>
#else
#include <stdio.h>
#define LOG(level, ...) \
#define ALOG(level, ...) \
        ((void)printf("cutils:" level "/" LOG_TAG ": " __VA_ARGS__))
#define LOGV(...)   LOG("V", __VA_ARGS__)
#define LOGD(...)   LOG("D", __VA_ARGS__)
#define LOGI(...)   LOG("I", __VA_ARGS__)
#define LOGW(...)   LOG("W", __VA_ARGS__)
#define LOGE(...)   LOG("E", __VA_ARGS__)
#define LOG_ALWAYS_FATAL(...)   do { LOGE(__VA_ARGS__); exit(1); } while (0)
#define ALOGV(...)   ALOG("V", __VA_ARGS__)
#define ALOGD(...)   ALOG("D", __VA_ARGS__)
#define ALOGI(...)   ALOG("I", __VA_ARGS__)
#define ALOGW(...)   ALOG("W", __VA_ARGS__)
#define ALOGE(...)   ALOG("E", __VA_ARGS__)
#define LOG_ALWAYS_FATAL(...)   do { ALOGE(__VA_ARGS__); exit(1); } while (0)
#endif

#endif // _CUTILS_LOGHACK_H
+41 −41
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ static void setNonBlocking(int fd) {
static void closeWithWarning(int fd) {
    int result = close(fd);
    if (result == -1) {
        LOGW("close() error: %s", strerror(errno));
        ALOGW("close() error: %s", strerror(errno));
    }
}

@@ -263,7 +263,7 @@ static void peerUnlock(Peer* peer) {

/** Frees a simple, i.e. header-only, outgoing packet. */
static void outgoingPacketFree(OutgoingPacket* packet) {
    LOGD("Freeing outgoing packet.");
    ALOGD("Freeing outgoing packet.");
	free(packet);
}

@@ -374,10 +374,10 @@ static bool peerProxyRemoveConnection(void* key, void* value, void* context) {
 */
static void peerProxyKill(PeerProxy* peerProxy, bool errnoIsSet) {
    if (errnoIsSet) {
        LOGI("Peer %d died. errno: %s", peerProxy->credentials.pid, 
        ALOGI("Peer %d died. errno: %s", peerProxy->credentials.pid, 
                strerror(errno));
    } else {
        LOGI("Peer %d died.", peerProxy->credentials.pid);
        ALOGI("Peer %d died.", peerProxy->credentials.pid);
    }
    
    // If we lost the master, we're up a creek. We can't let this happen.
@@ -433,12 +433,12 @@ static void peerProxyKill(PeerProxy* peerProxy, bool errnoIsSet) {
static void peerProxyHandleError(PeerProxy* peerProxy, char* functionName) {
    if (errno == EINTR) {
        // Log interruptions but otherwise ignore them.
        LOGW("%s() interrupted.", functionName);
        ALOGW("%s() interrupted.", functionName);
    } else if (errno == EAGAIN) {
    	LOGD("EWOULDBLOCK");
        ALOGD("EWOULDBLOCK");
        // Ignore.
    } else {
        LOGW("Error returned by %s().", functionName);
        ALOGW("Error returned by %s().", functionName);
        peerProxyKill(peerProxy, true);
    }
}
@@ -461,7 +461,7 @@ static bool peerProxyWriteFromBuffer(PeerProxy* peerProxy, Buffer* outgoing) {
static void peerProxyWriteBytes(PeerProxy* peerProxy) {	
	Buffer* buffer = peerProxy->currentPacket->bytes;
	if (peerProxyWriteFromBuffer(peerProxy, buffer)) {
        LOGD("Bytes written.");
        ALOGD("Bytes written.");
        peerProxyNextPacket(peerProxy);
    }    
}
@@ -527,10 +527,10 @@ static void peerProxyWrite(SelectableFd* fd) {
    Buffer* outgoingHeader = &peerProxy->outgoingHeader;
    bool headerWritten = bufferWriteComplete(outgoingHeader);
    if (!headerWritten) {
        LOGD("Writing header...");
        ALOGD("Writing header...");
        headerWritten = peerProxyWriteFromBuffer(peerProxy, outgoingHeader);
        if (headerWritten) {
            LOGD("Header written.");
            ALOGD("Header written.");
        }
    }    

@@ -559,7 +559,7 @@ static void peerProxyWrite(SelectableFd* fd) {
 * Sets up a peer proxy's fd before we try to select() it.
 */
static void peerProxyBeforeSelect(SelectableFd* fd) {
    LOGD("Before select...");
    ALOGD("Before select...");

    PeerProxy* peerProxy = (PeerProxy*) fd->data;
  
@@ -568,7 +568,7 @@ static void peerProxyBeforeSelect(SelectableFd* fd) {
    peerUnlock(peerProxy->peer);
    
    if (hasPackets) {
        LOGD("Packets found. Setting onWritable().");
        ALOGD("Packets found. Setting onWritable().");
            
        fd->onWritable = &peerProxyWrite;
    } else {
@@ -579,11 +579,11 @@ static void peerProxyBeforeSelect(SelectableFd* fd) {

/** Prepare to read bytes from the peer. */
static void peerProxyExpectBytes(PeerProxy* peerProxy, Header* header) {
	LOGD("Expecting %d bytes.", header->size);
    ALOGD("Expecting %d bytes.", header->size);

    peerProxy->inputState = READING_BYTES;
    if (bufferPrepareForRead(peerProxy->inputBuffer, header->size) == -1) {
        LOGW("Couldn't allocate memory for incoming data. Size: %u",
        ALOGW("Couldn't allocate memory for incoming data. Size: %u",
                (unsigned int) header->size);    
        
        // TODO: Ignore the packet and log a warning?
@@ -670,7 +670,7 @@ static void masterProxyExpectConnection(PeerProxy* masterProxy,
    // 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.", 
        ALOGW("Non-master process %d tried to send us a connection.", 
            masterProxy->credentials.pid);
        // Kill off the evil peer.
        peerProxyKill(masterProxy, false);
@@ -686,7 +686,7 @@ static void masterProxyExpectConnection(PeerProxy* masterProxy,
    peerLock(localPeer);
    PeerProxy* peerProxy = peerProxyGetOrCreate(localPeer, pid, false);
    if (peerProxy == NULL) {
        LOGW("Peer proxy creation failed: %s", strerror(errno));
        ALOGW("Peer proxy creation failed: %s", strerror(errno));
    } else {
        // Fill in full credentials.
        peerProxy->credentials = header->credentials;
@@ -746,7 +746,7 @@ static void masterProxyAcceptConnection(PeerProxy* masterProxy) {
    if (size < 0) {
        if (errno == EINTR) {
            // Log interruptions but otherwise ignore them.
            LOGW("recvmsg() interrupted.");
            ALOGW("recvmsg() interrupted.");
            return;
        } else if (errno == EAGAIN) {
            // Keep waiting for the connection.
@@ -777,14 +777,14 @@ static void masterProxyAcceptConnection(PeerProxy* masterProxy) {
    // The peer proxy this connection is for.
    PeerProxy* peerProxy = masterProxy->connecting;
    if (peerProxy == NULL) {
        LOGW("Received connection for unknown peer.");
        ALOGW("Received connection for unknown peer.");
        closeWithWarning(incomingFd);
    } else {
        Peer* peer = masterProxy->peer;
        
        SelectableFd* selectableFd = selectorAdd(peer->selector, incomingFd);
        if (selectableFd == NULL) {
            LOGW("Error adding fd to selector for %d.",
            ALOGW("Error adding fd to selector for %d.",
                    peerProxy->credentials.pid);
            closeWithWarning(incomingFd);
            peerProxyKill(peerProxy, false);
@@ -811,7 +811,7 @@ static void masterConnectPeers(PeerProxy* peerA, PeerProxy* peerB) {
    int sockets[2];
    int result = socketpair(AF_LOCAL, SOCK_STREAM, 0, sockets);
    if (result == -1) {
        LOGW("socketpair() error: %s", strerror(errno));
        ALOGW("socketpair() error: %s", strerror(errno));
        // TODO: Send CONNECTION_FAILED packets to peers.
        return;
    }
@@ -821,7 +821,7 @@ static void masterConnectPeers(PeerProxy* peerA, PeerProxy* peerB) {
    if (packetA == NULL || packetB == NULL) {
        free(packetA);
        free(packetB);
        LOGW("malloc() error. Failed to tell process %d that process %d is"
        ALOGW("malloc() error. Failed to tell process %d that process %d is"
                " dead.", peerA->credentials.pid, peerB->credentials.pid);
        return;
    }
@@ -852,7 +852,7 @@ static void masterReportConnectionError(PeerProxy* peerProxy,
        Credentials credentials) {
    OutgoingPacket* packet = calloc(1, sizeof(OutgoingPacket));
    if (packet == NULL) {
        LOGW("malloc() error. Failed to tell process %d that process %d is"
        ALOGW("malloc() error. Failed to tell process %d that process %d is"
                " dead.", peerProxy->credentials.pid, credentials.pid);
        return;
    }
@@ -902,10 +902,10 @@ static void masterProxyHandleConnectionError(PeerProxy* masterProxy,
    peerUnlock(peer);

    if (peerProxy != NULL) {
        LOGI("Couldn't connect to %d.", pid);
        ALOGI("Couldn't connect to %d.", pid);
        peerProxyKill(peerProxy, false);
    } else {
        LOGW("Peer proxy for %d not found. This shouldn't happen.", pid);
        ALOGW("Peer proxy for %d not found. This shouldn't happen.", pid);
    }
    
    peerProxyExpectHeader(masterProxy);
@@ -929,7 +929,7 @@ static void peerProxyHandleHeader(PeerProxy* peerProxy, Header* header) {
            peerProxyExpectBytes(peerProxy, header);
            break;
        default:
            LOGW("Invalid packet type from %d: %d", peerProxy->credentials.pid, 
            ALOGW("Invalid packet type from %d: %d", peerProxy->credentials.pid, 
                    header->type);
            peerProxyKill(peerProxy, false);
    }
@@ -947,7 +947,7 @@ static bool peerProxyBufferInput(PeerProxy* peerProxy) {
        return false;
    } else if (size == 0) {
        // EOF.
    	LOGI("EOF");
    	ALOGI("EOF");
        peerProxyKill(peerProxy, false);
        return false;
    } else if (bufferReadComplete(in)) {
@@ -963,23 +963,23 @@ static bool peerProxyBufferInput(PeerProxy* peerProxy) {
 * Reads input from a peer process.
 */
static void peerProxyRead(SelectableFd* fd) {
    LOGD("Reading...");
    ALOGD("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.");
                ALOGD("Header read.");
                // We've read the complete header.
                Header* header = (Header*) in->data;
                peerProxyHandleHeader(peerProxy, header);
            }
            break;
        case READING_BYTES:
            LOGD("Reading bytes...");
            ALOGD("Reading bytes...");
            if (peerProxyBufferInput(peerProxy)) {
                LOGD("Bytes read.");
                ALOGD("Bytes read.");
                // We have the complete packet. Notify bytes listener.
                peerProxy->peer->onBytes(peerProxy->credentials,
                    in->data, in->size);
@@ -1026,11 +1026,11 @@ static void masterAcceptConnection(SelectableFd* listenerFd) {
    // Accept connection.
    int socket = accept(listenerFd->fd, NULL, NULL);
    if (socket == -1) {
        LOGW("accept() error: %s", strerror(errno));
        ALOGW("accept() error: %s", strerror(errno));
        return;
    }
    
    LOGD("Accepted connection as fd %d.", socket);
    ALOGD("Accepted connection as fd %d.", socket);
    
    // Get credentials.
    Credentials credentials;
@@ -1040,7 +1040,7 @@ static void masterAcceptConnection(SelectableFd* listenerFd) {
                &ucredentials, &credentialsSize);
    // We might want to verify credentialsSize.
    if (result == -1) {
        LOGW("getsockopt() error: %s", strerror(errno));
        ALOGW("getsockopt() error: %s", strerror(errno));
        closeWithWarning(socket);
        return;
    }
@@ -1050,7 +1050,7 @@ static void masterAcceptConnection(SelectableFd* listenerFd) {
    credentials.uid = ucredentials.uid;
    credentials.gid = ucredentials.gid;
    
    LOGI("Accepted connection from process %d.", credentials.pid);
    ALOGI("Accepted connection from process %d.", credentials.pid);
   
    Peer* masterPeer = (Peer*) listenerFd->data;
    
@@ -1061,7 +1061,7 @@ static void masterAcceptConnection(SelectableFd* listenerFd) {
        = hashmapGet(masterPeer->peerProxies, &credentials.pid);
    if (peerProxy != NULL) {
        peerUnlock(masterPeer);
        LOGW("Alread connected to process %d.", credentials.pid);
        ALOGW("Alread connected to process %d.", credentials.pid);
        closeWithWarning(socket);
        return;
    }
@@ -1070,7 +1070,7 @@ static void masterAcceptConnection(SelectableFd* listenerFd) {
    SelectableFd* socketFd = selectorAdd(masterPeer->selector, socket);
    if (socketFd == NULL) {
        peerUnlock(masterPeer);
        LOGW("malloc() failed.");
        ALOGW("malloc() failed.");
        closeWithWarning(socket);
        return;
    }
@@ -1079,7 +1079,7 @@ static void masterAcceptConnection(SelectableFd* listenerFd) {
    peerProxy = peerProxyCreate(masterPeer, credentials);
    peerUnlock(masterPeer);
    if (peerProxy == NULL) {
        LOGW("malloc() failed.");
        ALOGW("malloc() failed.");
        socketFd->remove = true;
        closeWithWarning(socket);
    }
@@ -1118,7 +1118,7 @@ static Peer* localPeer;

/** Frees a packet of bytes. */
static void outgoingPacketFreeBytes(OutgoingPacket* packet) {
    LOGD("Freeing outgoing packet.");
    ALOGD("Freeing outgoing packet.");
    bufferFree(packet->bytes);
    free(packet);
}
@@ -1270,7 +1270,7 @@ void masterPeerInitialize(BytesListener* bytesListener,
        LOG_ALWAYS_FATAL("bind() error: %s", strerror(errno));
    }

    LOGD("Listener socket: %d",  listenerSocket);   
    ALOGD("Listener socket: %d",  listenerSocket);
    
    // Queue up to 16 connections.
    result = listen(listenerSocket, 16);
+9 −9
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ static int connectToServer(const char* fileName)
    
    sock = socket(AF_UNIX, SOCK_STREAM, 0);
    if (sock < 0) {
        LOGW("UNIX domain socket create failed (errno=%d)\n", errno);
        ALOGW("UNIX domain socket create failed (errno=%d)\n", errno);
        return -1;
    }

@@ -110,7 +110,7 @@ static int connectToServer(const char* fileName)
    if (cc < 0) {
        // ENOENT means socket file doesn't exist
        // ECONNREFUSED means socket exists but nobody is listening
        //LOGW("AF_UNIX connect failed for '%s': %s\n",
        //ALOGW("AF_UNIX connect failed for '%s': %s\n",
        //    fileName, strerror(errno));
        close(sock);
        return -1;
@@ -128,9 +128,9 @@ static void init(void)

    gPropFd = connectToServer(SYSTEM_PROPERTY_PIPE_NAME);
    if (gPropFd < 0) {
        //LOGW("not connected to system property server\n");
        //ALOGW("not connected to system property server\n");
    } else {
        //LOGV("Connected to system property server\n");
        //ALOGV("Connected to system property server\n");
    }
}

@@ -140,7 +140,7 @@ int property_get(const char *key, char *value, const char *default_value)
    char recvBuf[1+PROPERTY_VALUE_MAX];
    int len = -1;

    //LOGV("PROPERTY GET [%s]\n", key);
    //ALOGV("PROPERTY GET [%s]\n", key);

    pthread_once(&gInitOnce, init);
    if (gPropFd < 0) {
@@ -189,12 +189,12 @@ int property_get(const char *key, char *value, const char *default_value)
        strcpy(value, recvBuf+1);
        len = strlen(value);
    } else {
        LOGE("Got strange response to property_get request (%d)\n",
        ALOGE("Got strange response to property_get request (%d)\n",
            recvBuf[0]);
        assert(0);
        return -1;
    }
    //LOGV("PROP [found=%d def='%s'] (%d) [%s]: [%s]\n",
    //ALOGV("PROP [found=%d def='%s'] (%d) [%s]: [%s]\n",
    //    recvBuf[0], default_value, len, key, value);

    return len;
@@ -207,7 +207,7 @@ int property_set(const char *key, const char *value)
    char recvBuf[1];
    int result = -1;

    //LOGV("PROPERTY SET [%s]: [%s]\n", key, value);
    //ALOGV("PROPERTY SET [%s]: [%s]\n", key, value);

    pthread_once(&gInitOnce, init);
    if (gPropFd < 0)
@@ -241,7 +241,7 @@ int property_set(const char *key, const char *value)
int property_list(void (*propfn)(const char *key, const char *value, void *cookie), 
                  void *cookie)
{
    //LOGV("PROPERTY LIST\n");
    //ALOGV("PROPERTY LIST\n");
    pthread_once(&gInitOnce, init);
    if (gPropFd < 0)
        return -1;
Loading