bump cereal (#29561)

old-commit-hash: e726505918
This commit is contained in:
Adeeb Shihadeh 2023-08-23 13:42:37 -07:00 committed by GitHub
parent 97e9d55588
commit 6b2ffe9490
5 changed files with 22 additions and 11 deletions

2
cereal

@ -1 +1 @@
Subproject commit 736a4cce2c51cb73465e88dae6ff4cec5b9c3b43
Subproject commit fa580de1b42534d3417306c416784e1add99ad32

View File

@ -253,6 +253,14 @@ std::string dir_name(std::string const &path) {
return path.substr(0, pos);
}
bool starts_with(const std::string &s1, const std::string &s2) {
return strncmp(s1.c_str(), s2.c_str(), s2.size()) == 0;
}
bool ends_with(const std::string &s1, const std::string &s2) {
return strcmp(s1.c_str() + (s1.size() - s2.size()), s2.c_str()) == 0;
}
std::string check_output(const std::string& command) {
char buffer[128];
std::string result;

View File

@ -77,6 +77,8 @@ float getenv(const char* key, float default_val);
std::string hexdump(const uint8_t* in, const size_t size);
std::string dir_name(std::string const& path);
bool starts_with(const std::string &s1, const std::string &s2);
bool ends_with(const std::string &s1, const std::string &s2);
// ***** random helpers *****
int random_int(int min, int max);

View File

@ -207,11 +207,11 @@ void loggerd_thread() {
std::unique_ptr<Poller> poller(Poller::create());
// subscribe to all socks
for (const auto& it : services) {
const bool encoder = strcmp(it.name+strlen(it.name)-strlen("EncodeData"), "EncodeData") == 0;
const bool livestream_encoder = strncmp(it.name, "livestream", strlen("livestream")) == 0;
for (const auto& [_, it] : services) {
const bool encoder = util::ends_with(it.name, "EncodeData");
const bool livestream_encoder = util::starts_with(it.name, "livestream");
if (!it.should_log && (!encoder || livestream_encoder)) continue;
LOGD("logging %s (on port %d)", it.name, it.port);
LOGD("logging %s (on port %d)", it.name.c_str(), it.port);
SubSocket * sock = SubSocket::create(ctx.get(), it.name);
assert(sock != NULL);
@ -221,7 +221,7 @@ void loggerd_thread() {
.counter = 0,
.freq = it.decimation,
.encoder = encoder,
.user_flag = (strcmp(it.name, "userFlag") == 0),
.user_flag = it.name == "userFlag",
};
}

View File

@ -16,19 +16,20 @@ Replay::Replay(QString route, QStringList allow, QStringList block, QStringList
auto event_struct = capnp::Schema::from<cereal::Event>().asStruct();
sockets_.resize(event_struct.getUnionFields().size());
for (const auto &it : services) {
uint16_t which = event_struct.getFieldByName(it.name).getProto().getDiscriminantValue();
auto name = it.second.name.c_str();
uint16_t which = event_struct.getFieldByName(name).getProto().getDiscriminantValue();
if ((which == cereal::Event::Which::UI_DEBUG || which == cereal::Event::Which::USER_FLAG) &&
!(flags & REPLAY_FLAG_ALL_SERVICES) &&
!allow.contains(it.name)) {
!allow.contains(name)) {
continue;
}
if ((allow.empty() || allow.contains(it.name)) && !block.contains(it.name)) {
sockets_[which] = it.name;
if ((allow.empty() || allow.contains(name)) && !block.contains(name)) {
sockets_[which] = name;
if (!allow.empty() || !block.empty()) {
allow_list.insert((cereal::Event::Which)which);
}
s.push_back(it.name);
s.push_back(name);
}
}