@@ -224,23 +224,33 @@ extern "C" {
224
224
std::exit (EXIT_FAILURE);
225
225
}
226
226
227
- // Use a vector to store the worker threads
228
- std::vector<pthread_t > workers (MAX_WORKERS);
227
+ // Use arrays to store the worker threads per vendor
228
+ pthread_t cisco_workers[MAX_WORKERS] = {0 };
229
+ pthread_t juniper_workers[MAX_WORKERS] = {0 };
230
+ pthread_t huawei_workers[MAX_WORKERS] = {0 };
229
231
230
232
// Cisco
231
- LoadThreads (workers. data () , " ipv4_socket_cisco" , " replies_cisco" ,
233
+ LoadThreads (cisco_workers , " ipv4_socket_cisco" , " replies_cisco" ,
232
234
" cisco_workers" );
233
235
234
236
// Juniper
235
- LoadThreads (workers. data () , " ipv4_socket_juniper" , " replies_juniper" ,
237
+ LoadThreads (juniper_workers , " ipv4_socket_juniper" , " replies_juniper" ,
236
238
" juniper_workers" );
237
239
238
240
// Huawei
239
- LoadThreads (workers. data () , " ipv4_socket_huawei" , " replies_huawei" ,
241
+ LoadThreads (huawei_workers , " ipv4_socket_huawei" , " replies_huawei" ,
240
242
" huawei_workers" );
241
243
242
- for (size_t w = 0 ; w < MAX_WORKERS; w++) {
243
- pthread_detach (workers[w]);
244
+ for (size_t w = 0 ; w < MAX_WORKERS && cisco_workers[w] != 0 ; w++) {
245
+ pthread_detach (cisco_workers[w]);
246
+ }
247
+
248
+ for (size_t w = 0 ; w < MAX_WORKERS && juniper_workers[w] != 0 ; w++) {
249
+ pthread_detach (juniper_workers[w]);
250
+ }
251
+
252
+ for (size_t w = 0 ; w < MAX_WORKERS && huawei_workers[w] != 0 ; w++) {
253
+ pthread_detach (huawei_workers[w]);
244
254
}
245
255
}
246
256
@@ -357,8 +367,7 @@ extern "C" {
357
367
" and 5. (default = 1)" , workers_str);
358
368
std::exit (EXIT_FAILURE);
359
369
}
360
- size_t w;
361
- for (w = 0 ; w < workers; w++) {
370
+ for (size_t w = 0 ; w < workers; w++) {
362
371
int res = pthread_create (&workers_vec[w], NULL , VendorThread,
363
372
(void *)ipv4_socket_str);
364
373
if (res != 0 ) {
0 commit comments