Skip to content

Commit b02b364

Browse files
committed
Adding dedicated vector per vendor to handle threads, standalone collector ...
1 parent e178a31 commit b02b364

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

doc/Changelog

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ The keys used are:
99

1010
current -- XX-XX.20XX
1111

12-
v1.1.3 -- 06-10.2023
13-
+ Adding support for certain releases of rhel & rocky Linux to the install.sh script
14-
! Adding simple checks before every "delete" statement to avoid double deletion
15-
! Fixing Segfault issue affecting start_grpc_dialout_collector() function
12+
v1.1.3 -- 07-10.2023
13+
+ Adding dedicated vector per vendor to handle threads, standalone collector
14+
+ Adding support for rhel & rocky Linux, install.sh script
15+
! Adding checks before every "delete" statement to avoid double deletion
16+
! Fixing Segfault issue affecting the start_grpc_dialout_collector() function
1617
! Fixing memory leak affecting the Srv::*Stream::Start() functions
1718
! Making the free_grpc_payload() and the InitGrpcPayload() function safer (pointers handling)
1819
! Making start_grpc_dialout_collector() safer (vector to store the workers threads)

src/bridge/grpc_collector_bridge.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ extern "C" {
350350
const char *workers_str)
351351
{
352352
if (main_cfg_parameters.at(ipv4_socket_str).empty() == false) {
353-
size_t replies =
353+
int replies =
354354
std::stoi(main_cfg_parameters.at(replies_str));
355355
if (replies < 0 || replies > 1000) {
356356
spdlog::get("multi-logger")->
@@ -359,15 +359,15 @@ extern "C" {
359359
"and 1000. (default = 0 => unlimited)", replies_str);
360360
std::exit(EXIT_FAILURE);
361361
}
362-
size_t workers = std::stoi(main_cfg_parameters.at(workers_str));
362+
int workers = std::stoi(main_cfg_parameters.at(workers_str));
363363
if (workers < 1 || workers > 5) {
364364
spdlog::get("multi-logger")->
365365
error("[{}] configuration issue: the "
366366
"allowed amount of workers is defined between 1 "
367367
"and 5. (default = 1)", workers_str);
368368
std::exit(EXIT_FAILURE);
369369
}
370-
for (size_t w = 0; w < workers; w++) {
370+
for (int w = 0; w < workers; w++) {
371371
int res = pthread_create(&workers_vec[w], NULL, VendorThread,
372372
(void *)ipv4_socket_str);
373373
if (res != 0) {

src/mdt_dialout_collector.cc

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,25 +193,41 @@ int main(int argc, char *argv[])
193193
zmq_single_thread_poller.detach();
194194
// --- ZMQ - Poller ---
195195

196-
std::vector<std::thread> workers;
196+
std::vector<std::thread> cisco_workers;
197+
std::vector<std::thread> juniper_workers;
198+
std::vector<std::thread> huawei_workers;
197199

198200
// Cisco
199-
LoadThreads(workers, "ipv4_socket_cisco", "replies_cisco",
201+
LoadThreads(cisco_workers, "ipv4_socket_cisco", "replies_cisco",
200202
"cisco_workers");
201203

202204
// Juniper
203-
LoadThreads(workers, "ipv4_socket_juniper", "replies_juniper",
205+
LoadThreads(juniper_workers, "ipv4_socket_juniper", "replies_juniper",
204206
"juniper_workers");
205207

206208
// Huawei
207-
LoadThreads(workers, "ipv4_socket_huawei", "replies_huawei",
209+
LoadThreads(huawei_workers, "ipv4_socket_huawei", "replies_huawei",
208210
"huawei_workers");
209211

210212
signal(SIGUSR1, SignalHandler);
211213

212-
//std::cout << "WORKERS: " << workers.size() << "\n";
214+
//std::cout << "CISCO_WORKERS: " << cisco_workers.size() << "\n";
215+
//std::cout << "JUNIPER_WORKERS: " << juniper_workers.size() << "\n";
216+
//std::cout << "HUAWEI_WORKERS: " << huawei_workers.size() << "\n";
213217

214-
for (std::thread &w : workers) {
218+
for (std::thread &w : cisco_workers) {
219+
if(w.joinable()) {
220+
w.join();
221+
}
222+
}
223+
224+
for (std::thread &w : juniper_workers) {
225+
if(w.joinable()) {
226+
w.join();
227+
}
228+
}
229+
230+
for (std::thread &w : huawei_workers) {
215231
if(w.joinable()) {
216232
w.join();
217233
}
@@ -270,7 +286,7 @@ void LoadThreads(std::vector<std::thread> &workers_vec,
270286
const std::string &workers_str)
271287
{
272288
if (main_cfg_parameters.at(ipv4_socket_str).empty() == false) {
273-
size_t replies =
289+
int replies =
274290
std::stoi(main_cfg_parameters.at(replies_str));
275291
if (replies < 0 || replies > 1000) {
276292
spdlog::get("multi-logger")->
@@ -279,15 +295,15 @@ void LoadThreads(std::vector<std::thread> &workers_vec,
279295
"and 1000. (default = 0 => unlimited)", replies_str);
280296
std::exit(EXIT_FAILURE);
281297
}
282-
size_t workers = std::stoi(main_cfg_parameters.at(workers_str));
298+
int workers = std::stoi(main_cfg_parameters.at(workers_str));
283299
if (workers < 1 || workers > 5) {
284300
spdlog::get("multi-logger")->
285301
error("[{}] configuration issue: the "
286302
"allowed amount of workers is defined between 1 "
287303
"and 5. (default = 1)", workers_str);
288304
std::exit(EXIT_FAILURE);
289305
}
290-
for (size_t w = 0; w < workers; w++) {
306+
for (int w = 0; w < workers; w++) {
291307
workers_vec.push_back(std::thread(&VendorThread,
292308
ipv4_socket_str));
293309
}

0 commit comments

Comments
 (0)