Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e170d1ac authored by Tom Cherry's avatar Tom Cherry
Browse files

logd: don't use SIGHUP to reinitialize

It doesn't look like there are any users, since there is a much better
mechanism, `logd --reinit` that exists for this behavior.  The
settings app and init.rc use that mechanism and they are the two major
clients that force logd to reinitialize.

This saves us from creating a thread and marginally cleans up
main.cpp.

Test: log reinitialization works
Change-Id: Icdb56b6f59adbba82812231a4f3a6ffd1a7955fc
parent 1a12ae3a
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@

#include <android-base/stringprintf.h>
#include <cutils/sockets.h>
#include <log/log_properties.h>
#include <private/android_filesystem_config.h>
#include <sysutils/SocketClient.h>

@@ -296,7 +297,20 @@ int CommandListener::ReinitCmd::runCommand(SocketClient* cli, int /*argc*/,
                                           char** /*argv*/) {
    setname();

    reinit_signal_handler(SIGHUP);
    android::prdebug("logd reinit");
    buf()->init();
    buf()->initPrune(nullptr);

    // This only works on userdebug and eng devices to re-read the
    // /data/misc/logd/event-log-tags file right after /data is mounted.
    // The operation is near to boot and should only happen once.  There
    // are races associated with its use since it can trigger a Rebuild
    // of the file, but that is a can-not-happen since the file was not
    // read yet.  More dangerous if called later, but if all is well it
    // should just skip over everything and not write any new entries.
    if (__android_log_is_debuggable()) {
        tags()->ReadFileEventLogTags(tags()->debug_event_log_tags);
    }

    cli->sendMsg("success");

+0 −3
Original line number Diff line number Diff line
@@ -24,9 +24,6 @@
#include "LogReader.h"
#include "LogTags.h"

// See main.cpp for implementation
void reinit_signal_handler(int /*signal*/);

class CommandListener : public FrameworkListener {
  public:
    CommandListener(LogBuffer* buf, LogTags* tags);
+1 −5
Original line number Diff line number Diff line
@@ -92,11 +92,7 @@ void LogBuffer::init() {
        unlock();
    }

    // We may have been triggered by a SIGHUP. Release any sleeping reader
    // threads to dump their current content.
    //
    // NB: this is _not_ performed in the context of a SIGHUP, it is
    // performed during startup, and in context of reinit administrative thread
    // Release any sleeping reader threads to dump their current content.
    LogTimeEntry::wrlock();

    LastLogTimes::iterator times = mTimes.begin();
+0 −17
Original line number Diff line number Diff line
@@ -391,23 +391,6 @@ const char* android::tagToName(uint32_t tag) {
    return me->tagToName(tag);
}

// Prototype in LogUtils.h allowing external access to our database.
//
// This only works on userdebug and eng devices to re-read the
// /data/misc/logd/event-log-tags file right after /data is mounted.
// The operation is near to boot and should only happen once.  There
// are races associated with its use since it can trigger a Rebuild
// of the file, but that is a can-not-happen since the file was not
// read yet.  More dangerous if called later, but if all is well it
// should just skip over everything and not write any new entries.
void android::ReReadEventLogTags() {
    LogTags* me = logtags;

    if (me && __android_log_is_debuggable()) {
        me->ReadFileEventLogTags(me->debug_event_log_tags);
    }
}

// converts an event tag into a format
const char* LogTags::tagToFormat(uint32_t tag) const {
    tag2format_const_iterator iform;
+1 −5
Original line number Diff line number Diff line
@@ -14,8 +14,7 @@
 * limitations under the License.
 */

#ifndef _LOGD_LOG_UTILS_H__
#define _LOGD_LOG_UTILS_H__
#pragma once

#include <sys/cdefs.h>
#include <sys/types.h>
@@ -41,7 +40,6 @@ char* tidToName(pid_t tid);

// Furnished in LogTags.cpp. Thread safe.
const char* tagToName(uint32_t tag);
void ReReadEventLogTags();

// Furnished by LogKlog.cpp
char* log_strntok_r(char* s, ssize_t& len, char*& saveptr, ssize_t& sublen);
@@ -72,5 +70,3 @@ static inline bool worstUidEnabledForLogid(log_id_t id) {
    return (id == LOG_ID_MAIN) || (id == LOG_ID_SYSTEM) ||
           (id == LOG_ID_RADIO) || (id == LOG_ID_EVENTS);
}

#endif  // _LOGD_LOG_UTILS_H__
Loading