summaryrefslogtreecommitdiffstats
path: root/include/sysutils/SocketClient.h
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2012-02-07 12:23:14 -0800
committerRobert Greenwalt <rgreenwalt@google.com>2012-03-05 11:44:43 -0800
commit8702bb17f40022e970e8acd40b348d074e39afc7 (patch)
tree5b8f27e686d6d2b7850129c3d59f435103c482b2 /include/sysutils/SocketClient.h
parentca3bf25570c197757f75b749cddecfea88cbcdc1 (diff)
downloadsystem_core-8702bb17f40022e970e8acd40b348d074e39afc7.zip
system_core-8702bb17f40022e970e8acd40b348d074e39afc7.tar.gz
system_core-8702bb17f40022e970e8acd40b348d074e39afc7.tar.bz2
New NativeDaemonConnector protocol adds a seqnum.
Allows for one socket to be multiplexed for multiple requests. Doesn't use command sequence numbers for broadcasts - would make no sense. Doesn't alter current default behavior so OEM's using these classes won't notice a difference. bug:5864209 Change-Id: Ie3b19c4f81eea868569229a365c8cb7de249c2dd
Diffstat (limited to 'include/sysutils/SocketClient.h')
-rw-r--r--include/sysutils/SocketClient.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/include/sysutils/SocketClient.h b/include/sysutils/SocketClient.h
index 7d2b1d6..6473b3a 100644
--- a/include/sysutils/SocketClient.h
+++ b/include/sysutils/SocketClient.h
@@ -4,6 +4,7 @@
#include "../../../frameworks/base/include/utils/List.h"
#include <pthread.h>
+#include <cutils/atomic.h>
#include <sys/types.h>
class SocketClient {
@@ -24,20 +25,27 @@ class SocketClient {
pthread_mutex_t mRefCountMutex;
int mRefCount;
+ int mCmdNum;
+
+ bool mUseCmdNum;
+
public:
SocketClient(int sock, bool owned);
+ SocketClient(int sock, bool owned, bool useCmdNum);
virtual ~SocketClient();
int getSocket() { return mSocket; }
pid_t getPid() const { return mPid; }
uid_t getUid() const { return mUid; }
gid_t getGid() const { return mGid; }
+ void setCmdNum(int cmdNum) { android_atomic_release_store(cmdNum, &mCmdNum); }
+ int getCmdNum() { return mCmdNum; }
// Send null-terminated C strings:
int sendMsg(int code, const char *msg, bool addErrno);
- int sendMsg(const char *msg);
+ int sendMsg(int code, const char *msg, bool addErrno, bool useCmdNum);
- // Sending binary data:
+ //Sending binary data:
int sendData(const void *data, int len);
// Optional reference counting. Reference count starts at 1. If
@@ -46,6 +54,11 @@ public:
// decRef() when it's done with the client.
void incRef();
bool decRef(); // returns true at 0 (but note: SocketClient already deleted)
+
+private:
+ // Send null-terminated C strings
+ int sendMsg(const char *msg);
+ void init(int socket, bool owned, bool useCmdNum);
};
typedef android::List<SocketClient *> SocketClientCollection;