summaryrefslogtreecommitdiffstats
path: root/logd
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2015-01-16 13:38:07 -0800
committerMark Salyzyn <salyzyn@google.com>2015-01-23 23:32:11 +0000
commitb5f6e45d6bddd2f6262bf387c3314dc744896320 (patch)
tree6b866998680afb3dde2db6b1f9d8e2e57852b73c /logd
parent2c7f05d88c3d59eea5ce82a4762cf3c6477565c7 (diff)
downloadcore-b5f6e45d6bddd2f6262bf387c3314dc744896320.tar.gz
core-b5f6e45d6bddd2f6262bf387c3314dc744896320.tar.bz2
core-b5f6e45d6bddd2f6262bf387c3314dc744896320.zip
logd: create private/android_logger.h
- create a structure to depict the private header expected at logd end of socket. - utilize this new structure instead of unscalable byte stream technique used to unpack in logd. Change-Id: I2d0e5c3531c279f2dc1fbd74807210ff8d804de0
Diffstat (limited to 'logd')
-rw-r--r--logd/LogListener.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp
index 8186cea97..fc9e30ff4 100644
--- a/logd/LogListener.cpp
+++ b/logd/LogListener.cpp
@@ -23,6 +23,7 @@
#include <cutils/sockets.h>
#include <log/logger.h>
+#include <private/android_logger.h>
#include "LogListener.h"
@@ -54,7 +55,7 @@ bool LogListener::onDataAvailable(SocketClient *cli) {
int socket = cli->getSocket();
ssize_t n = recvmsg(socket, &hdr, 0);
- if (n <= (ssize_t)(sizeof_log_id_t + sizeof(uint16_t) + sizeof(log_time))) {
+ if (n <= (ssize_t)(sizeof(android_log_header_t))) {
return false;
}
@@ -81,28 +82,19 @@ bool LogListener::onDataAvailable(SocketClient *cli) {
return false;
}
- // First log element is always log_id.
- log_id_t log_id = (log_id_t) *((typeof_log_id_t *) buffer);
- if (log_id < 0 || log_id >= LOG_ID_MAX) {
+ android_log_header_t *header = reinterpret_cast<android_log_header_t *>(buffer);
+ if (/* header->id < LOG_ID_MIN || */ header->id >= LOG_ID_MAX) {
return false;
}
- char *msg = ((char *)buffer) + sizeof_log_id_t;
- n -= sizeof_log_id_t;
- // second element is the thread id of the caller
- pid_t tid = (pid_t) *((uint16_t *) msg);
- msg += sizeof(uint16_t);
- n -= sizeof(uint16_t);
-
- // third element is the realtime at point of caller
- log_time realtime(msg);
- msg += sizeof(log_time);
- n -= sizeof(log_time);
+ char *msg = ((char *)buffer) + sizeof(android_log_header_t);
+ n -= sizeof(android_log_header_t);
// NB: hdr.msg_flags & MSG_TRUNC is not tested, silently passing a
// truncated message to the logs.
- logbuf->log(log_id, realtime, cred->uid, cred->pid, tid, msg,
+ logbuf->log((log_id_t)header->id, header->realtime,
+ cred->uid, cred->pid, header->tid, msg,
((size_t) n <= USHRT_MAX) ? (unsigned short) n : USHRT_MAX);
reader->notifyNewLog();