fix loggerd after bootlog split (#19840)

* fix loggerd after bootlog split

* logger handles that

* unused

Co-authored-by: Comma Device <device@comma.ai>
pull/19842/head
Adeeb Shihadeh 4 years ago committed by GitHub
parent 13ea3ccf6d
commit 2e64049ea4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      selfdrive/loggerd/SConscript
  2. 44
      selfdrive/loggerd/logger.cc
  3. 10
      selfdrive/loggerd/loggerd.cc
  4. 7
      selfdrive/manager.py

@ -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

@ -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,21 +134,7 @@ 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));
@ -194,8 +200,8 @@ static LoggerHandle* logger_open(LoggerState *s, const char* root_path) {
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)

Loading…
Cancel
Save