mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-29 10:32:10 +08:00
fix loggerd after bootlog split (#19840)
* fix loggerd after bootlog split * logger handles that * unused Co-authored-by: Comma Device <device@comma.ai> old-commit-hash: 2e64049ea4996af6bcd6fc1ff9338f5e20a5b393
This commit is contained in:
@@ -2,11 +2,11 @@ Import('env', 'arch', 'cereal', 'messaging', 'common', 'visionipc', 'gpucommon')
|
||||
|
||||
|
||||
logger_lib = env.Library('logger', ["logger.cc"])
|
||||
src = ['loggerd.cc']
|
||||
libs = [logger_lib, 'zmq', 'capnp', 'kj', 'z',
|
||||
'avformat', 'avcodec', 'swscale', 'avutil',
|
||||
'yuv', 'bz2', 'OpenCL', common, cereal, messaging, visionipc]
|
||||
|
||||
src = ['loggerd.cc']
|
||||
if arch in ["aarch64", "larch64"]:
|
||||
src += ['omx_encoder.cc']
|
||||
libs += ['OmxCore', 'gsl', 'CB'] + gpucommon
|
||||
|
||||
+28
-20
@@ -6,7 +6,6 @@
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -18,14 +17,17 @@
|
||||
#ifdef QCOM
|
||||
#include <cutils/properties.h>
|
||||
#endif
|
||||
#include "messaging.hpp"
|
||||
|
||||
#include "common/swaglog.h"
|
||||
#include "common/params.h"
|
||||
#include "common/util.h"
|
||||
#include "common/version.h"
|
||||
#include "messaging.hpp"
|
||||
#include "logger.h"
|
||||
|
||||
|
||||
// ***** logging helpers *****
|
||||
|
||||
void append_property(const char* key, const char* value, void *cookie) {
|
||||
std::vector<std::pair<std::string, std::string> > *properties =
|
||||
(std::vector<std::pair<std::string, std::string> > *)cookie;
|
||||
@@ -33,6 +35,24 @@ void append_property(const char* key, const char* value, void *cookie) {
|
||||
properties->push_back(std::make_pair(std::string(key), std::string(value)));
|
||||
}
|
||||
|
||||
static int mkpath(char* file_path) {
|
||||
assert(file_path && *file_path);
|
||||
char* p;
|
||||
for (p=strchr(file_path+1, '/'); p; p=strchr(p+1, '/')) {
|
||||
*p = '\0';
|
||||
if (mkdir(file_path, 0777)==-1) {
|
||||
if (errno != EEXIST) {
|
||||
*p = '/';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
*p = '/';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ***** log metadata *****
|
||||
|
||||
void log_init_data(LoggerState *s) {
|
||||
MessageBuilder msg;
|
||||
auto init = msg.initEvent().initInitData();
|
||||
@@ -114,25 +134,11 @@ static void log_sentinel(LoggerState *s, cereal::Sentinel::SentinelType type) {
|
||||
logger_log(s, bytes.begin(), bytes.size(), true);
|
||||
}
|
||||
|
||||
static int mkpath(char* file_path) {
|
||||
assert(file_path && *file_path);
|
||||
char* p;
|
||||
for (p=strchr(file_path+1, '/'); p; p=strchr(p+1, '/')) {
|
||||
*p = '\0';
|
||||
if (mkdir(file_path, 0777)==-1) {
|
||||
if (errno != EEXIST) {
|
||||
*p = '/';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
*p = '/';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// ***** logging functions *****
|
||||
|
||||
void logger_init(LoggerState *s, const char* log_name, bool has_qlog) {
|
||||
memset(s, 0, sizeof(*s));
|
||||
|
||||
|
||||
umask(0);
|
||||
|
||||
pthread_mutex_init(&s->lock, NULL);
|
||||
@@ -191,11 +197,11 @@ static LoggerHandle* logger_open(LoggerState *s, const char* root_path) {
|
||||
h->bz_qlog = BZ2_bzWriteOpen(&bzerror, h->qlog_file, 9, 0, 30);
|
||||
if (bzerror != BZ_OK) goto fail;
|
||||
}
|
||||
|
||||
|
||||
pthread_mutex_init(&h->lock, NULL);
|
||||
h->refcnt++;
|
||||
log_init_data(s);
|
||||
return h;
|
||||
|
||||
fail:
|
||||
LOGE("logger failed to open files");
|
||||
if (h->bz_file) {
|
||||
@@ -246,6 +252,8 @@ int logger_next(LoggerState *s, const char* root_path,
|
||||
|
||||
pthread_mutex_unlock(&s->lock);
|
||||
|
||||
// write beggining of log metadata
|
||||
log_init_data(s);
|
||||
log_sentinel(s, is_start_of_route ? cereal::Sentinel::SentinelType::START_OF_ROUTE : cereal::Sentinel::SentinelType::START_OF_SEGMENT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
@@ -18,6 +17,7 @@
|
||||
#include <random>
|
||||
|
||||
#include <ftw.h>
|
||||
|
||||
#include "common/timing.h"
|
||||
#include "common/params.h"
|
||||
#include "common/swaglog.h"
|
||||
@@ -101,14 +101,6 @@ namespace {
|
||||
|
||||
constexpr int SEGMENT_LENGTH = 60;
|
||||
|
||||
double randrange(double a, double b) __attribute__((unused));
|
||||
double randrange(double a, double b) {
|
||||
static std::mt19937 gen(millis_since_boot());
|
||||
|
||||
std::uniform_real_distribution<> dist(a, b);
|
||||
return dist(gen);
|
||||
}
|
||||
|
||||
ExitHandler do_exit;
|
||||
|
||||
class RotateState {
|
||||
|
||||
@@ -146,7 +146,6 @@ import cereal.messaging as messaging
|
||||
|
||||
from common.params import Params
|
||||
from selfdrive.registration import register
|
||||
from selfdrive.loggerd.config import ROOT
|
||||
from selfdrive.launcher import launcher
|
||||
|
||||
|
||||
@@ -421,12 +420,6 @@ def manager_init():
|
||||
crash.bind_user(id=dongle_id)
|
||||
crash.bind_extra(version=version, dirty=dirty, is_eon=True)
|
||||
|
||||
os.umask(0)
|
||||
try:
|
||||
os.mkdir(ROOT, 0o777)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# ensure shared libraries are readable by apks
|
||||
if EON:
|
||||
os.chmod(BASEDIR, 0o755)
|
||||
|
||||
Reference in New Issue
Block a user