diff options
author | Mark Salyzyn <salyzyn@google.com> | 2015-03-17 07:56:32 -0700 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2015-04-01 19:41:59 +0000 |
commit | e3aeeeeccc260c29ca5907a444f8d746bcc2f8a5 (patch) | |
tree | d03d386d0804bb07a175bd9e74aefd0a64aa2a68 /logd | |
parent | 221554749337a9c961c192596be5eb4e42083733 (diff) | |
download | system_core-e3aeeeeccc260c29ca5907a444f8d746bcc2f8a5.zip system_core-e3aeeeeccc260c29ca5907a444f8d746bcc2f8a5.tar.gz system_core-e3aeeeeccc260c29ca5907a444f8d746bcc2f8a5.tar.bz2 |
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.cpp | 6 | ||||
-rw-r--r-- | logd/LogAudit.cpp | 3 | ||||
-rw-r--r-- | logd/LogListener.cpp | 9 | ||||
-rw-r--r-- | logd/LogReader.cpp | 6 | ||||
-rw-r--r-- | logd/LogStatistics.cpp | 2 | ||||
-rw-r--r-- | logd/main.cpp | 2 |
6 files changed, 21 insertions, 7 deletions
diff --git a/logd/CommandListener.cpp b/logd/CommandListener.cpp index 561ea3e..bdfed3b 100644 --- a/logd/CommandListener.cpp +++ b/logd/CommandListener.cpp @@ -69,7 +69,11 @@ CommandListener::ClearCmd::ClearCmd(LogBuffer *buf) { } static void setname() { - prctl(PR_SET_NAME, "logd.control"); + static bool name_set; + if (!name_set) { + prctl(PR_SET_NAME, "logd.control"); + name_set = true; + } } int CommandListener::ClearCmd::runCommand(SocketClient *cli, diff --git a/logd/LogAudit.cpp b/logd/LogAudit.cpp index 6b3e637..ab00422 100644 --- a/logd/LogAudit.cpp +++ b/logd/LogAudit.cpp @@ -24,6 +24,7 @@ #include <sys/uio.h> #include <syslog.h> +#include <private/android_filesystem_config.h> #include <private/android_logger.h> #include "libaudit.h" @@ -110,7 +111,7 @@ int LogAudit::logPrint(const char *fmt, ...) { pid_t pid = getpid(); pid_t tid = gettid(); - uid_t uid = getuid(); + uid_t uid = AID_LOGD; log_time now; static const char audit_str[] = " audit("; diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp index fc9e30f..3b4ef88 100644 --- a/logd/LogListener.cpp +++ b/logd/LogListener.cpp @@ -23,6 +23,7 @@ #include <cutils/sockets.h> #include <log/logger.h> +#include <private/android_filesystem_config.h> #include <private/android_logger.h> #include "LogListener.h" @@ -34,7 +35,11 @@ LogListener::LogListener(LogBuffer *buf, LogReader *reader) { } bool LogListener::onDataAvailable(SocketClient *cli) { - prctl(PR_SET_NAME, "logd.writer"); + static bool name_set; + if (!name_set) { + prctl(PR_SET_NAME, "logd.writer"); + name_set = true; + } char buffer[sizeof_log_id_t + sizeof(uint16_t) + sizeof(log_time) + LOGGER_ENTRY_MAX_PAYLOAD]; @@ -75,7 +80,7 @@ bool LogListener::onDataAvailable(SocketClient *cli) { return false; } - if (cred->uid == getuid()) { + if (cred->uid == AID_LOGD) { // ignore log messages we send to ourself. // Such log messages are often generated by libraries we depend on // which use standard Android logging. diff --git a/logd/LogReader.cpp b/logd/LogReader.cpp index f7df275..745e847 100644 --- a/logd/LogReader.cpp +++ b/logd/LogReader.cpp @@ -37,7 +37,11 @@ void LogReader::notifyNewLog() { } bool LogReader::onDataAvailable(SocketClient *cli) { - prctl(PR_SET_NAME, "logd.reader"); + static bool name_set; + if (!name_set) { + prctl(PR_SET_NAME, "logd.reader"); + name_set = true; + } char buffer[255]; diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp index accd660..6bb0b40 100644 --- a/logd/LogStatistics.cpp +++ b/logd/LogStatistics.cpp @@ -303,5 +303,5 @@ uid_t LogStatistics::pidToUid(pid_t pid) { } fclose(fp); } - return getuid(); // associate this with the logger + return AID_LOGD; // associate this with the logger } diff --git a/logd/main.cpp b/logd/main.cpp index a61beff..3ddc1df 100644 --- a/logd/main.cpp +++ b/logd/main.cpp @@ -35,8 +35,8 @@ #include <cutils/properties.h> #include <cutils/sched_policy.h> #include <cutils/sockets.h> +#include <private/android_filesystem_config.h> -#include "private/android_filesystem_config.h" #include "CommandListener.h" #include "LogBuffer.h" #include "LogListener.h" |