Loading include/sysutils/SocketClient.h +3 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ class SocketClient { int mSocket; bool mSocketOwned; pthread_mutex_t mWriteMutex; /* Peer process ID */ Loading @@ -24,8 +25,8 @@ class SocketClient { int mRefCount; public: SocketClient(int sock); virtual ~SocketClient() {} SocketClient(int sock, bool owned); virtual ~SocketClient(); int getSocket() { return mSocket; } pid_t getPid() const { return mPid; } Loading libsysutils/src/SocketClient.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -10,8 +10,9 @@ #include <sysutils/SocketClient.h> SocketClient::SocketClient(int socket) SocketClient::SocketClient(int socket, bool owned) : mSocket(socket) , mSocketOwned(owned) , mPid(-1) , mUid(-1) , mGid(-1) Loading @@ -32,6 +33,13 @@ SocketClient::SocketClient(int socket) } } SocketClient::~SocketClient() { if (mSocketOwned) { close(mSocket); } } int SocketClient::sendMsg(int code, const char *msg, bool addErrno) { char *buf; const char* arg; Loading libsysutils/src/SocketListener.cpp +4 −8 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ int SocketListener::startListener() { SLOGE("Unable to listen on socket (%s)", strerror(errno)); return -1; } else if (!mListen) mClients->push_back(new SocketClient(mSock)); mClients->push_back(new SocketClient(mSock, false)); if (pipe(mCtrlPipe)) { SLOGE("pipe failed (%s)", strerror(errno)); Loading Loading @@ -191,7 +191,7 @@ void SocketListener::runListener() { continue; } pthread_mutex_lock(&mClientsLock); mClients->push_back(new SocketClient(c)); mClients->push_back(new SocketClient(c, true)); pthread_mutex_unlock(&mClientsLock); } Loading Loading @@ -225,12 +225,8 @@ void SocketListener::runListener() { } } pthread_mutex_unlock(&mClientsLock); /* Destroy the client */ int socket = c->getSocket(); if (c->decRef()) { // Note: 'c' is deleted memory at this point. close(socket); } /* Remove our reference to the client */ c->decRef(); } } } Loading Loading
include/sysutils/SocketClient.h +3 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ class SocketClient { int mSocket; bool mSocketOwned; pthread_mutex_t mWriteMutex; /* Peer process ID */ Loading @@ -24,8 +25,8 @@ class SocketClient { int mRefCount; public: SocketClient(int sock); virtual ~SocketClient() {} SocketClient(int sock, bool owned); virtual ~SocketClient(); int getSocket() { return mSocket; } pid_t getPid() const { return mPid; } Loading
libsysutils/src/SocketClient.cpp +9 −1 Original line number Diff line number Diff line Loading @@ -10,8 +10,9 @@ #include <sysutils/SocketClient.h> SocketClient::SocketClient(int socket) SocketClient::SocketClient(int socket, bool owned) : mSocket(socket) , mSocketOwned(owned) , mPid(-1) , mUid(-1) , mGid(-1) Loading @@ -32,6 +33,13 @@ SocketClient::SocketClient(int socket) } } SocketClient::~SocketClient() { if (mSocketOwned) { close(mSocket); } } int SocketClient::sendMsg(int code, const char *msg, bool addErrno) { char *buf; const char* arg; Loading
libsysutils/src/SocketListener.cpp +4 −8 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ int SocketListener::startListener() { SLOGE("Unable to listen on socket (%s)", strerror(errno)); return -1; } else if (!mListen) mClients->push_back(new SocketClient(mSock)); mClients->push_back(new SocketClient(mSock, false)); if (pipe(mCtrlPipe)) { SLOGE("pipe failed (%s)", strerror(errno)); Loading Loading @@ -191,7 +191,7 @@ void SocketListener::runListener() { continue; } pthread_mutex_lock(&mClientsLock); mClients->push_back(new SocketClient(c)); mClients->push_back(new SocketClient(c, true)); pthread_mutex_unlock(&mClientsLock); } Loading Loading @@ -225,12 +225,8 @@ void SocketListener::runListener() { } } pthread_mutex_unlock(&mClientsLock); /* Destroy the client */ int socket = c->getSocket(); if (c->decRef()) { // Note: 'c' is deleted memory at this point. close(socket); } /* Remove our reference to the client */ c->decRef(); } } } Loading