summaryrefslogtreecommitdiffstats
path: root/logd
diff options
context:
space:
mode:
authorMark Salyzyn2015-03-17 09:56:32 -0500
committerMark Salyzyn2015-04-01 14:41:59 -0500
commite3aeeeeccc260c29ca5907a444f8d746bcc2f8a5 (patch)
treed03d386d0804bb07a175bd9e74aefd0a64aa2a68 /logd
parent221554749337a9c961c192596be5eb4e42083733 (diff)
downloadplatform-system-core-e3aeeeeccc260c29ca5907a444f8d746bcc2f8a5.tar.gz
platform-system-core-e3aeeeeccc260c29ca5907a444f8d746bcc2f8a5.tar.xz
platform-system-core-e3aeeeeccc260c29ca5907a444f8d746bcc2f8a5.zip
logd: syscall optimization
- prset(PR_SET_NAME) call once - No need to call getuid(), should be AID_LOGD Change-Id: I4dde0b178bc84e711b355cd7677b0dbf905a0634
Diffstat (limited to 'logd')
-rw-r--r--logd/CommandListener.cpp6
-rw-r--r--logd/LogAudit.cpp3
-rw-r--r--logd/LogListener.cpp9
-rw-r--r--logd/LogReader.cpp6
-rw-r--r--logd/LogStatistics.cpp2
-rw-r--r--logd/main.cpp2
6 files changed, 21 insertions, 7 deletions
diff --git a/logd/CommandListener.cpp b/logd/CommandListener.cpp
index 561ea3e50..bdfed3b2b 100644
--- a/logd/CommandListener.cpp
+++ b/logd/CommandListener.cpp
@@ -69,7 +69,11 @@ CommandListener::ClearCmd::ClearCmd(LogBuffer *buf)
69{ } 69{ }
70 70
71static void setname() { 71static void setname() {
72 prctl(PR_SET_NAME, "logd.control"); 72 static bool name_set;
73 if (!name_set) {
74 prctl(PR_SET_NAME, "logd.control");
75 name_set = true;
76 }
73} 77}
74 78
75int CommandListener::ClearCmd::runCommand(SocketClient *cli, 79int CommandListener::ClearCmd::runCommand(SocketClient *cli,
diff --git a/logd/LogAudit.cpp b/logd/LogAudit.cpp
index 6b3e63718..ab00422a9 100644
--- a/logd/LogAudit.cpp
+++ b/logd/LogAudit.cpp
@@ -24,6 +24,7 @@
24#include <sys/uio.h> 24#include <sys/uio.h>
25#include <syslog.h> 25#include <syslog.h>
26 26
27#include <private/android_filesystem_config.h>
27#include <private/android_logger.h> 28#include <private/android_logger.h>
28 29
29#include "libaudit.h" 30#include "libaudit.h"
@@ -110,7 +111,7 @@ int LogAudit::logPrint(const char *fmt, ...) {
110 111
111 pid_t pid = getpid(); 112 pid_t pid = getpid();
112 pid_t tid = gettid(); 113 pid_t tid = gettid();
113 uid_t uid = getuid(); 114 uid_t uid = AID_LOGD;
114 log_time now; 115 log_time now;
115 116
116 static const char audit_str[] = " audit("; 117 static const char audit_str[] = " audit(";
diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp
index fc9e30ff4..3b4ef8822 100644
--- a/logd/LogListener.cpp
+++ b/logd/LogListener.cpp
@@ -23,6 +23,7 @@
23 23
24#include <cutils/sockets.h> 24#include <cutils/sockets.h>
25#include <log/logger.h> 25#include <log/logger.h>
26#include <private/android_filesystem_config.h>
26#include <private/android_logger.h> 27#include <private/android_logger.h>
27 28
28#include "LogListener.h" 29#include "LogListener.h"
@@ -34,7 +35,11 @@ LogListener::LogListener(LogBuffer *buf, LogReader *reader)
34{ } 35{ }
35 36
36bool LogListener::onDataAvailable(SocketClient *cli) { 37bool LogListener::onDataAvailable(SocketClient *cli) {
37 prctl(PR_SET_NAME, "logd.writer"); 38 static bool name_set;
39 if (!name_set) {
40 prctl(PR_SET_NAME, "logd.writer");
41 name_set = true;
42 }
38 43
39 char buffer[sizeof_log_id_t + sizeof(uint16_t) + sizeof(log_time) 44 char buffer[sizeof_log_id_t + sizeof(uint16_t) + sizeof(log_time)
40 + LOGGER_ENTRY_MAX_PAYLOAD]; 45 + LOGGER_ENTRY_MAX_PAYLOAD];
@@ -75,7 +80,7 @@ bool LogListener::onDataAvailable(SocketClient *cli) {
75 return false; 80 return false;
76 } 81 }
77 82
78 if (cred->uid == getuid()) { 83 if (cred->uid == AID_LOGD) {
79 // ignore log messages we send to ourself. 84 // ignore log messages we send to ourself.
80 // Such log messages are often generated by libraries we depend on 85 // Such log messages are often generated by libraries we depend on
81 // which use standard Android logging. 86 // which use standard Android logging.
diff --git a/logd/LogReader.cpp b/logd/LogReader.cpp
index f7df27558..745e8477e 100644
--- a/logd/LogReader.cpp
+++ b/logd/LogReader.cpp
@@ -37,7 +37,11 @@ void LogReader::notifyNewLog() {
37} 37}
38 38
39bool LogReader::onDataAvailable(SocketClient *cli) { 39bool LogReader::onDataAvailable(SocketClient *cli) {
40 prctl(PR_SET_NAME, "logd.reader"); 40 static bool name_set;
41 if (!name_set) {
42 prctl(PR_SET_NAME, "logd.reader");
43 name_set = true;
44 }
41 45
42 char buffer[255]; 46 char buffer[255];
43 47
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
index accd660d6..6bb0b40ba 100644
--- a/logd/LogStatistics.cpp
+++ b/logd/LogStatistics.cpp
@@ -303,5 +303,5 @@ uid_t LogStatistics::pidToUid(pid_t pid) {
303 } 303 }
304 fclose(fp); 304 fclose(fp);
305 } 305 }
306 return getuid(); // associate this with the logger 306 return AID_LOGD; // associate this with the logger
307} 307}
diff --git a/logd/main.cpp b/logd/main.cpp
index a61beffb7..3ddc1df6e 100644
--- a/logd/main.cpp
+++ b/logd/main.cpp
@@ -35,8 +35,8 @@
35#include <cutils/properties.h> 35#include <cutils/properties.h>
36#include <cutils/sched_policy.h> 36#include <cutils/sched_policy.h>
37#include <cutils/sockets.h> 37#include <cutils/sockets.h>
38#include <private/android_filesystem_config.h>
38 39
39#include "private/android_filesystem_config.h"
40#include "CommandListener.h" 40#include "CommandListener.h"
41#include "LogBuffer.h" 41#include "LogBuffer.h"
42#include "LogListener.h" 42#include "LogListener.h"