summaryrefslogtreecommitdiffstats
path: root/include/sysutils/SocketClient.h
diff options
context:
space:
mode:
authorXianzhu Wang <wangxianzhu@google.com>2011-09-29 12:59:55 +0800
committerXianzhu Wang <wangxianzhu@google.com>2011-09-29 13:42:32 +0800
commit4520246d3534c087f3e9253c34f99dd1e45b7bd7 (patch)
tree68fb2d909e6258f785347d60a026b42efeaa93b4 /include/sysutils/SocketClient.h
parent2a32df25b8bb307693173911041458aaca84c84c (diff)
downloadsystem_core-4520246d3534c087f3e9253c34f99dd1e45b7bd7.zip
system_core-4520246d3534c087f3e9253c34f99dd1e45b7bd7.tar.gz
system_core-4520246d3534c087f3e9253c34f99dd1e45b7bd7.tar.bz2
Fix SocketListener socket leak issue.
The problem was: if a socket is shared between SocketListener and another thread, only if the last reference is removed by SocketListener can the socket be closed, otherwise the socket will leak. This sometimes happens in netd's dnsproxyd. This change let the SocketClient own the socket and close the socket when the SocketClient is destructed. Change-Id: I2865fbfe9ee4d8b3e43d7e02919dbb2d261f70de
Diffstat (limited to 'include/sysutils/SocketClient.h')
-rw-r--r--include/sysutils/SocketClient.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/sysutils/SocketClient.h b/include/sysutils/SocketClient.h
index d6bb7d5..7d2b1d6 100644
--- a/include/sysutils/SocketClient.h
+++ b/include/sysutils/SocketClient.h
@@ -8,6 +8,7 @@
class SocketClient {
int mSocket;
+ bool mSocketOwned;
pthread_mutex_t mWriteMutex;
/* Peer process ID */
@@ -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; }