summaryrefslogtreecommitdiffstats
path: root/opengl
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2012-01-30 09:08:27 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-01-30 09:08:27 -0800
commitb09316736fe7b721d92900ad901894fd5ce2b854 (patch)
tree10e9f00752b79e7ce0fffaf401ca7696a6f44fbe /opengl
parentc7685d6d6e4a7e3fe5b00d2420a66d1560a911dc (diff)
parent4c4d501205f758c3378736bd1f98b955bb189e54 (diff)
downloadframeworks_base-b09316736fe7b721d92900ad901894fd5ce2b854.zip
frameworks_base-b09316736fe7b721d92900ad901894fd5ce2b854.tar.gz
frameworks_base-b09316736fe7b721d92900ad901894fd5ce2b854.tar.bz2
Merge "gltrace: Use Unix Domain Socket rather than INET Socket"
Diffstat (limited to 'opengl')
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_eglapi.cpp8
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_transport.cpp25
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_transport.h7
3 files changed, 21 insertions, 19 deletions
diff --git a/opengl/libs/GLES_trace/src/gltrace_eglapi.cpp b/opengl/libs/GLES_trace/src/gltrace_eglapi.cpp
index c237d75..c442153 100644
--- a/opengl/libs/GLES_trace/src/gltrace_eglapi.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_eglapi.cpp
@@ -77,12 +77,10 @@ static void *commandReceiveTask(void *arg) {
}
void GLTrace_start() {
- char value[PROPERTY_VALUE_MAX];
+ char udsName[PROPERTY_VALUE_MAX];
- property_get("debug.egl.debug_port", value, "5039");
- const unsigned short port = (unsigned short)atoi(value);
-
- int clientSocket = gltrace::acceptClientConnection(port);
+ property_get("debug.egl.debug_portname", udsName, "gltrace");
+ int clientSocket = gltrace::acceptClientConnection(udsName);
if (clientSocket < 0) {
ALOGE("Error creating GLTrace server socket. Quitting application.");
exit(-1);
diff --git a/opengl/libs/GLES_trace/src/gltrace_transport.cpp b/opengl/libs/GLES_trace/src/gltrace_transport.cpp
index ce3fae5..5251b12 100644
--- a/opengl/libs/GLES_trace/src/gltrace_transport.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_transport.cpp
@@ -17,9 +17,10 @@
#include <stdlib.h>
#include <unistd.h>
+#include <unistd.h>
#include <sys/socket.h>
+#include <sys/un.h>
#include <netinet/in.h>
-#include <arpa/inet.h>
#include <cutils/log.h>
@@ -28,22 +29,24 @@
namespace android {
namespace gltrace {
-int acceptClientConnection(int serverPort) {
- int serverSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+int acceptClientConnection(char *sockname) {
+ int serverSocket = socket(AF_LOCAL, SOCK_STREAM, 0);
if (serverSocket < 0) {
ALOGE("Error (%d) while creating socket. Check if app has network permissions.",
serverSocket);
return -1;
}
- struct sockaddr_in server, client;
+ struct sockaddr_un server, client;
- server.sin_family = AF_INET;
- server.sin_addr.s_addr = htonl(INADDR_ANY);
- server.sin_port = htons(serverPort);
+ memset(&server, 0, sizeof server);
+ server.sun_family = AF_UNIX;
+ // the first byte of sun_path should be '\0' for abstract namespace
+ strcpy(server.sun_path + 1, sockname);
- socklen_t sockaddr_len = sizeof(sockaddr_in);
- if (bind(serverSocket, (struct sockaddr *) &server, sizeof(server)) < 0) {
+ // note that sockaddr_len should be set to the exact size of the buffer that is used.
+ socklen_t sockaddr_len = sizeof(server.sun_family) + strlen(sockname) + 1;
+ if (bind(serverSocket, (struct sockaddr *) &server, sockaddr_len) < 0) {
close(serverSocket);
ALOGE("Failed to bind the server socket");
return -1;
@@ -55,7 +58,7 @@ int acceptClientConnection(int serverPort) {
return -1;
}
- ALOGD("gltrace::waitForClientConnection: server listening @ port %d", serverPort);
+ ALOGD("gltrace::waitForClientConnection: server listening @ path %s", sockname);
int clientSocket = accept(serverSocket, (struct sockaddr *)&client, &sockaddr_len);
if (clientSocket < 0) {
@@ -64,7 +67,7 @@ int acceptClientConnection(int serverPort) {
return -1;
}
- ALOGD("gltrace::waitForClientConnection: client connected: %s", inet_ntoa(client.sin_addr));
+ ALOGD("gltrace::waitForClientConnection: client connected.");
// do not accept any more incoming connections
close(serverSocket);
diff --git a/opengl/libs/GLES_trace/src/gltrace_transport.h b/opengl/libs/GLES_trace/src/gltrace_transport.h
index d31df7b..3665035 100644
--- a/opengl/libs/GLES_trace/src/gltrace_transport.h
+++ b/opengl/libs/GLES_trace/src/gltrace_transport.h
@@ -76,10 +76,11 @@ public:
};
/**
- * Utility method: start a server at @serverPort, and wait for a client
- * connection. Returns the connected client socket on success, or -1 on failure.
+ * Utility method: start a server listening at @sockName (unix domain socket,
+ * abstract namespace path), and wait for a client connection.
+ * Returns the connected client socket on success, or -1 on failure.
*/
-int acceptClientConnection(int serverPort);
+int acceptClientConnection(char *sockName);
};
};