Merge "liblp: Replace some |const char*| inputs with std::string."
diff --git a/base/include/android-base/mapped_file.h b/base/include/android-base/mapped_file.h
index b719646..2ab49ab 100644
--- a/base/include/android-base/mapped_file.h
+++ b/base/include/android-base/mapped_file.h
@@ -36,7 +36,7 @@
namespace base {
/**
- * A region of a file mapped into memory.
+ * A region of a file mapped into memory, also known as MmapFile.
*/
class MappedFile {
public:
diff --git a/logd/main.cpp b/logd/main.cpp
index 28dcc5a..23bbf86 100644
--- a/logd/main.cpp
+++ b/logd/main.cpp
@@ -150,43 +150,14 @@
}
}
-static sem_t uidName;
-static uid_t uid;
-static char* name;
-
static sem_t reinit;
static bool reinit_running = false;
static LogBuffer* logBuf = nullptr;
-static bool package_list_parser_cb(pkg_info* info, void* /* userdata */) {
- bool rc = true;
- if (info->uid == uid) {
- name = strdup(info->name);
- // false to stop processing
- rc = false;
- }
-
- packagelist_free(info);
- return rc;
-}
-
static void* reinit_thread_start(void* /*obj*/) {
prctl(PR_SET_NAME, "logd.daemon");
while (reinit_running && !sem_wait(&reinit) && reinit_running) {
- // uidToName Privileged Worker
- if (uid) {
- name = nullptr;
-
- // if we got the perms wrong above, this would spam if we reported
- // problems with acquisition of an uid name from the packages.
- (void)packagelist_parse(package_list_parser_cb, nullptr);
-
- uid = 0;
- sem_post(&uidName);
- continue;
- }
-
if (fdDmesg >= 0) {
static const char reinit_message[] = { KMSG_PRIORITY(LOG_INFO),
'l',
@@ -223,26 +194,30 @@
return nullptr;
}
-static sem_t sem_name;
-
char* android::uidToName(uid_t u) {
- if (!u || !reinit_running) {
- return nullptr;
- }
+ struct Userdata {
+ uid_t uid;
+ char* name;
+ } userdata = {
+ .uid = u,
+ .name = nullptr,
+ };
- sem_wait(&sem_name);
+ packagelist_parse(
+ [](pkg_info* info, void* callback_parameter) {
+ auto userdata = reinterpret_cast<Userdata*>(callback_parameter);
+ bool result = true;
+ if (info->uid == userdata->uid) {
+ userdata->name = strdup(info->name);
+ // false to stop processing
+ result = false;
+ }
+ packagelist_free(info);
+ return result;
+ },
+ &userdata);
- // Not multi-thread safe, we use sem_name to protect
- uid = u;
-
- name = nullptr;
- sem_post(&reinit);
- sem_wait(&uidName);
- char* ret = name;
-
- sem_post(&sem_name);
-
- return ret;
+ return userdata.name;
}
// Serves as a global method to trigger reinitialization
@@ -363,8 +338,6 @@
// Reinit Thread
sem_init(&reinit, 0, 0);
- sem_init(&uidName, 0, 0);
- sem_init(&sem_name, 0, 1);
pthread_attr_t attr;
if (!pthread_attr_init(&attr)) {
struct sched_param param;
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 29a0ad4..7cb0f66 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -602,8 +602,9 @@
# Set SELinux security contexts on upgrade or policy update.
restorecon --recursive --skip-ce /data
- # Check any timezone data in /data is newer than the copy in the runtime module, delete if not.
- exec - system system -- /system/bin/tzdatacheck /apex/com.android.runtime/etc/tz /data/misc/zoneinfo
+ # Check any timezone data in /data is newer than the copy in the time zone data
+ # module, delete if not.
+ exec - system system -- /system/bin/tzdatacheck /apex/com.android.tzdata/etc/tz /data/misc/zoneinfo
# If there is no post-fs-data action in the init.<device>.rc file, you
# must uncomment this line, otherwise encrypted filesystems