summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2016-07-14 10:47:33 -0500
committerGerrit Code Review2016-07-14 10:47:33 -0500
commitd4f632417684db9617e68cdd7bfc55a7985caceb (patch)
treec938befe02e59834eb079dea7153c7eaad48ae98
parent4c06cd86347aa85c9e5999ad5f5ca20ef5f4ac8e (diff)
parentec4f5c776d2bde026e2a74128218924be7b3f46a (diff)
downloadplatform-system-core-android-wear-7.1.1_r1.tar.gz
platform-system-core-android-wear-7.1.1_r1.tar.xz
platform-system-core-android-wear-7.1.1_r1.zip
Merge "liblog: reset pid and uid cache after a vfork()"android-wear-7.1.1_r1android-n-preview-5android-n-iot-preview-2
-rw-r--r--liblog/logger.h6
-rw-r--r--liblog/logger_lock.c26
-rw-r--r--liblog/pmsg_writer.c2
3 files changed, 5 insertions, 29 deletions
diff --git a/liblog/logger.h b/liblog/logger.h
index 508725610..2a4cfcb56 100644
--- a/liblog/logger.h
+++ b/liblog/logger.h
@@ -146,11 +146,13 @@ struct android_log_transport_context {
146/* OS specific dribs and drabs */ 146/* OS specific dribs and drabs */
147 147
148#if defined(_WIN32) 148#if defined(_WIN32)
149#include <private/android_filesystem_config.h>
149typedef uint32_t uid_t; 150typedef uint32_t uid_t;
151static inline uid_t __android_log_uid() { return AID_SYSTEM; }
152#else
153static inline uid_t __android_log_uid() { return getuid(); }
150#endif 154#endif
151 155
152LIBLOG_HIDDEN uid_t __android_log_uid();
153LIBLOG_HIDDEN pid_t __android_log_pid();
154LIBLOG_HIDDEN void __android_log_lock(); 156LIBLOG_HIDDEN void __android_log_lock();
155LIBLOG_HIDDEN int __android_log_trylock(); 157LIBLOG_HIDDEN int __android_log_trylock();
156LIBLOG_HIDDEN void __android_log_unlock(); 158LIBLOG_HIDDEN void __android_log_unlock();
diff --git a/liblog/logger_lock.c b/liblog/logger_lock.c
index ee979bd5e..14feee078 100644
--- a/liblog/logger_lock.c
+++ b/liblog/logger_lock.c
@@ -22,34 +22,8 @@
22#include <pthread.h> 22#include <pthread.h>
23#endif 23#endif
24 24
25#include <private/android_filesystem_config.h>
26
27#include "logger.h" 25#include "logger.h"
28 26
29LIBLOG_HIDDEN uid_t __android_log_uid()
30{
31#if defined(_WIN32)
32 return AID_SYSTEM;
33#else
34 static uid_t last_uid = AID_ROOT; /* logd *always* starts up as AID_ROOT */
35
36 if (last_uid == AID_ROOT) { /* have we called to get the UID yet? */
37 last_uid = getuid();
38 }
39 return last_uid;
40#endif
41}
42
43LIBLOG_HIDDEN pid_t __android_log_pid()
44{
45 static pid_t last_pid = (pid_t) -1;
46
47 if (last_pid == (pid_t) -1) {
48 last_pid = getpid();
49 }
50 return last_pid;
51}
52
53#if !defined(_WIN32) 27#if !defined(_WIN32)
54static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER; 28static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
55#endif 29#endif
diff --git a/liblog/pmsg_writer.c b/liblog/pmsg_writer.c
index 2ba31fab1..944febae8 100644
--- a/liblog/pmsg_writer.c
+++ b/liblog/pmsg_writer.c
@@ -142,7 +142,7 @@ static int pmsgWrite(log_id_t logId, struct timespec *ts,
142 pmsgHeader.magic = LOGGER_MAGIC; 142 pmsgHeader.magic = LOGGER_MAGIC;
143 pmsgHeader.len = sizeof(pmsgHeader) + sizeof(header); 143 pmsgHeader.len = sizeof(pmsgHeader) + sizeof(header);
144 pmsgHeader.uid = __android_log_uid(); 144 pmsgHeader.uid = __android_log_uid();
145 pmsgHeader.pid = __android_log_pid(); 145 pmsgHeader.pid = getpid();
146 146
147 header.id = logId; 147 header.id = logId;
148 header.tid = gettid(); 148 header.tid = gettid();