Skip to content

Commit 50a1ef5

Browse files
authored
DPL: fix for sending configuration with spaces (#5390)
1 parent 042639a commit 50a1ef5

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

Analysis/Tutorials/src/configurableObjects.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ auto printMatrix(Array2D<T> const& m)
5252
}
5353

5454
static constexpr float defaultm[3][4] = {{1.1, 1.2, 1.3, 1.4}, {2.1, 2.2, 2.3, 2.4}, {3.1, 3.2, 3.3, 3.4}};
55-
static LabeledArray<float> la{&defaultm[0][0], 3, 4, {"r1", "r2", "r3"}, {"c1", "c2", "c3", "c4"}};
55+
static LabeledArray<float> la{&defaultm[0][0], 3, 4, {"r 1", "r 2", "r 3"}, {"c 1", "c 2", "c 3", "c 4"}};
5656

5757
struct ConfigurableObjectDemo {
5858
Configurable<configurableCut> cut{"cut", {0.5, 1, true}, "generic cut"};
@@ -61,7 +61,7 @@ struct ConfigurableObjectDemo {
6161
// note that size is fixed by this declaration - externally supplied vector needs to be the same size!
6262
Configurable<std::vector<int>> array{"array", {0, 0, 0, 0, 0, 0, 0}, "generic array"};
6363
Configurable<Array2D<float>> vmatrix{"matrix", {&defaultm[0][0], 3, 4}, "generic matrix"};
64-
Configurable<LabeledArray<float>> vla{"vla", {defaultm[0], 3, 4, {"r1", "r2", "r3"}, {"c1", "c2", "c3", "c4"}}, "labeled array"};
64+
Configurable<LabeledArray<float>> vla{"vla", {defaultm[0], 3, 4, {"r 1", "r 2", "r 3"}, {"c 1", "c 2", "c 3", "c 4"}}, "labeled array"};
6565

6666
void init(InitContext const&){};
6767
void process(aod::Collision const&, aod::Tracks const& tracks)

Framework/Core/src/DataProcessingDevice.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ void DataProcessingDevice::Init()
238238
} else {
239239
str = entry.second.get_value<std::string>();
240240
}
241-
std::string configString = fmt::format("[CONFIG] {}={} 1 {}", entry.first, str, configStore->provenance(entry.first.c_str())).c_str();
241+
std::string configString = fmt::format("[CONFIG];{}={};1;{}", entry.first, str, configStore->provenance(entry.first.c_str())).c_str();
242242
mServiceRegistry.get<DriverClient>().tell(configString.c_str());
243243
}
244244

Framework/Core/src/DeviceConfigInfo.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bool DeviceConfigHelper::parseConfig(std::string_view s, ParsedConfigMatch& matc
2424
{
2525
const char* begin = s.begin();
2626
const char* end = s.end();
27-
if (s.size() > 17 && (strncmp("[CONFIG] ", begin + 17, 9) != 0)) {
27+
if (s.size() > 17 && (strncmp("[CONFIG];", begin + 17, 9) != 0)) {
2828
return false;
2929
}
3030
if (s.size() < 17 + 9) {
@@ -36,14 +36,15 @@ bool DeviceConfigHelper::parseConfig(std::string_view s, ParsedConfigMatch& matc
3636
return false;
3737
}
3838
match.beginValue = match.endKey + 1;
39-
match.endValue = (char const*)memchr(match.beginValue, ' ', end - match.beginValue);
39+
match.endValue = (char const*)memchr(match.beginValue, ';', end - match.beginValue);
4040
if (match.endValue == nullptr) {
4141
return false;
4242
}
43+
4344
char* next = nullptr;
44-
match.timestamp = strtoll(match.endValue, &next, 10);
45+
match.timestamp = strtoll(match.endValue + 1, &next, 10);
4546

46-
if (!next || *next != ' ') {
47+
if (!next || *next != ';') {
4748
return false;
4849
}
4950

Framework/Core/test/test_DeviceConfigInfo.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ BOOST_AUTO_TEST_CASE(TestDeviceConfigInfo)
8383
BOOST_REQUIRE_EQUAL(result, false);
8484

8585
// Parse a simple configuration bit
86-
configString = "foo[XX:XX:XX][INFO] [CONFIG] foo=bar 1789372894 prov\n";
86+
configString = "foo[XX:XX:XX][INFO] [CONFIG];foo=bar;1789372894;prov\n";
8787
std::string_view config{configString.data() + 3, configString.size() - 4};
88-
BOOST_REQUIRE_EQUAL(config, std::string("[XX:XX:XX][INFO] [CONFIG] foo=bar 1789372894 prov"));
88+
BOOST_REQUIRE_EQUAL(config, std::string("[XX:XX:XX][INFO] [CONFIG];foo=bar;1789372894;prov"));
8989
result = DeviceConfigHelper::parseConfig(config, match);
9090
BOOST_REQUIRE_EQUAL(result, true);
9191
BOOST_CHECK(strncmp(match.beginKey, "foo", 3) == 0);
@@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(TestDeviceConfigInfo)
100100
BOOST_CHECK_EQUAL(info.currentProvenance.get<std::string>("foo"), "prov");
101101

102102
// Parse an array
103-
configString = "foo[XX:XX:XX][INFO] [CONFIG] array={\"\":\"1\",\"\":\"2\",\"\":\"3\",\"\":\"4\",\"\":\"5\"} 1789372894 prov\n";
103+
configString = "foo[XX:XX:XX][INFO] [CONFIG];array={\"\":\"1\",\"\":\"2\",\"\":\"3\",\"\":\"4\",\"\":\"5\"};1789372894;prov\n";
104104
std::string_view configa{configString.data() + 3, configString.size() - 4};
105105
result = DeviceConfigHelper::parseConfig(configa, match);
106106
auto valueString = std::string(match.beginValue, match.endValue - match.beginValue);

0 commit comments

Comments
 (0)