aboutsummaryrefslogtreecommitdiffstats
path: root/libsysutils
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@android.com>2010-10-27 10:23:16 -0700
committerBrad Fitzpatrick <bradfitz@android.com>2011-01-06 11:09:55 -0800
commita2a1f3149fb32d95bc81ddfd713d5bba9d6cbc61 (patch)
tree1e9d4f376979f5ef570c03bac03cfdeab987e8e8 /libsysutils
parentf1c2a7352f19cf729f91bf2559fc93ef12c74dca (diff)
downloadsystem_core-a2a1f3149fb32d95bc81ddfd713d5bba9d6cbc61.tar.gz
system_core-a2a1f3149fb32d95bc81ddfd713d5bba9d6cbc61.tar.bz2
system_core-a2a1f3149fb32d95bc81ddfd713d5bba9d6cbc61.zip
Let SocketClient users write binary data to clients.
This is a dependency for the DNS proxy CLs. This CL also adds a new socket for the netd process to inherit which is owned by the inet group. (so only apps with the INTERNET permission can use the DNS proxy...) Change-Id: I8a51924e0ed56c6066f77e6f1b02d39bdadac51e
Diffstat (limited to 'libsysutils')
-rw-r--r--libsysutils/src/SocketClient.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/libsysutils/src/SocketClient.cpp b/libsysutils/src/SocketClient.cpp
index 8e5f1545..ff2315b6 100644
--- a/libsysutils/src/SocketClient.cpp
+++ b/libsysutils/src/SocketClient.cpp
@@ -50,14 +50,22 @@ int SocketClient::sendMsg(const char *msg) {
}
// Send the message including null character
+ if (sendData(msg, strlen(msg) + 1) != 0) {
+ SLOGW("Unable to send msg '%s'", msg);
+ return -1;
+ }
+ return 0;
+}
+
+int SocketClient::sendData(const void* data, int len) {
int rc = 0;
- const char *p = msg;
- int brtw = strlen(msg) + 1;
+ const char *p = (const char*) data;
+ int brtw = len;
pthread_mutex_lock(&mWriteMutex);
- while(brtw) {
- if ((rc = write(mSocket,p, brtw)) < 0) {
- SLOGW("Unable to send msg '%s' (%s)", msg, strerror(errno));
+ while (brtw > 0) {
+ if ((rc = write(mSocket, p, brtw)) < 0) {
+ SLOGW("write error (%s)", strerror(errno));
pthread_mutex_unlock(&mWriteMutex);
return -1;
} else if (!rc) {