summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2012-03-06 11:30:13 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-03-06 11:30:13 -0800
commit78f6bcf853db3dd9b9b37a0ca4d4ee0374f6835a (patch)
treec8b92d557e35b39bcccad77c12025d795d5b8757 /include
parent397cf1986448cedde2a17093884a0ee8bf0d0b3f (diff)
parent8702bb17f40022e970e8acd40b348d074e39afc7 (diff)
downloadsystem_core-78f6bcf853db3dd9b9b37a0ca4d4ee0374f6835a.zip
system_core-78f6bcf853db3dd9b9b37a0ca4d4ee0374f6835a.tar.gz
system_core-78f6bcf853db3dd9b9b37a0ca4d4ee0374f6835a.tar.bz2
Merge "New NativeDaemonConnector protocol adds a seqnum."
Diffstat (limited to 'include')
-rw-r--r--include/sysutils/FrameworkListener.h7
-rw-r--r--include/sysutils/SocketClient.h17
-rw-r--r--include/sysutils/SocketListener.h8
3 files changed, 27 insertions, 5 deletions
diff --git a/include/sysutils/FrameworkListener.h b/include/sysutils/FrameworkListener.h
index 142f50c..756bacf 100644
--- a/include/sysutils/FrameworkListener.h
+++ b/include/sysutils/FrameworkListener.h
@@ -24,11 +24,17 @@ class SocketClient;
class FrameworkListener : public SocketListener {
public:
static const int CMD_ARGS_MAX = 16;
+
+ /* 1 out of errorRate will be dropped */
+ int errorRate;
private:
+ int mCommandCount;
+ bool mWithSeq;
FrameworkCommandCollection *mCommands;
public:
FrameworkListener(const char *socketName);
+ FrameworkListener(const char *socketName, bool withSeq);
virtual ~FrameworkListener() {}
protected:
@@ -37,5 +43,6 @@ protected:
private:
void dispatchCommand(SocketClient *c, char *data);
+ void init(const char *socketName, bool withSeq);
};
#endif
diff --git a/include/sysutils/SocketClient.h b/include/sysutils/SocketClient.h
index cee863f..65a5b1b 100644
--- a/include/sysutils/SocketClient.h
+++ b/include/sysutils/SocketClient.h
@@ -4,6 +4,7 @@
#include "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::sysutils::List<SocketClient *> SocketClientCollection;
diff --git a/include/sysutils/SocketListener.h b/include/sysutils/SocketListener.h
index 6592b01..8f56230 100644
--- a/include/sysutils/SocketListener.h
+++ b/include/sysutils/SocketListener.h
@@ -21,16 +21,18 @@
#include <sysutils/SocketClient.h>
class SocketListener {
- int mSock;
+ bool mListen;
const char *mSocketName;
+ int mSock;
SocketClientCollection *mClients;
pthread_mutex_t mClientsLock;
- bool mListen;
int mCtrlPipe[2];
pthread_t mThread;
+ bool mUseCmdNum;
public:
SocketListener(const char *socketName, bool listen);
+ SocketListener(const char *socketName, bool listen, bool useCmdNum);
SocketListener(int socketFd, bool listen);
virtual ~SocketListener();
@@ -38,7 +40,6 @@ public:
int stopListener();
void sendBroadcast(int code, const char *msg, bool addErrno);
- void sendBroadcast(const char *msg);
protected:
virtual bool onDataAvailable(SocketClient *c) = 0;
@@ -46,5 +47,6 @@ protected:
private:
static void *threadStart(void *obj);
void runListener();
+ void init(const char *socketName, int socketFd, bool listen, bool useCmdNum);
};
#endif