Skip to content

Commit

Permalink
tools/nut-scanner/scan_*.c: update some comments [networkupstools#2511]
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 8, 2024
1 parent 1fccd76 commit f8944fe
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
9 changes: 8 additions & 1 deletion tools/nut-scanner/scan_eaton_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,15 @@ nutscan_device_t * nutscan_scan_eaton_serial(const char* ports_range)
char *current_port_name = NULL;
char **serial_ports_list;
int current_port_nb;

#ifdef HAVE_PTHREAD
# ifdef HAVE_SEMAPHORE
sem_t * semaphore = nutscan_semaphore();
# endif
/* TODO? Port semaphore_scantype / max_threads_scantype
* from sibling sources? We do not have that many serial
* ports to care much, usually... right?
*/
# endif /* HAVE_SEMAPHORE */
pthread_t thread;
nutscan_thread_t * thread_array = NULL;
size_t thread_count = 0, i;
Expand Down Expand Up @@ -484,6 +489,7 @@ nutscan_device_t * nutscan_scan_eaton_serial(const char* ports_range)
"(launched overall: %" PRIuSIZE "), "
"waiting until some would finish",
__func__, curr_threads, thread_count);

while (curr_threads >= max_threads) {
for (i = 0; i < thread_count ; i++) {
int ret;
Expand Down Expand Up @@ -528,6 +534,7 @@ nutscan_device_t * nutscan_scan_eaton_serial(const char* ports_range)
}
upsdebugx(2, "%s: proceeding with scan", __func__);
}

/* NOTE: No change to default "pass" in this ifdef:
* if we got to this line, we have a slot to use */
# endif /* HAVE_PTHREAD_TRYJOIN */
Expand Down
1 change: 1 addition & 0 deletions tools/nut-scanner/scan_ipmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ nutscan_device_t * nutscan_scan_ipmi(const char * start_ip, const char * stop_ip
current_nut_dev = nutscan_scan_ipmi_device(NULL, NULL);
}
else {
/* TODO: Port HAVE_PTHREAD_TRYJOIN etc. from other files? */
if (start_ip == stop_ip || !stop_ip) {
upsdebugx(1, "%s: Scanning remote PSU for single IP address: %s",
__func__, start_ip);
Expand Down
4 changes: 3 additions & 1 deletion tools/nut-scanner/scan_nut.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ nutscan_device_t * nutscan_scan_nut(const char* startIP, const char* stopIP, con
"(launched overall: %" PRIuSIZE "), "
"waiting until some would finish",
__func__, curr_threads, thread_count);

while (curr_threads >= max_threads
|| (curr_threads >= max_threads_scantype && max_threads_scantype > 0)
) {
Expand Down Expand Up @@ -425,6 +426,7 @@ nutscan_device_t * nutscan_scan_nut(const char* startIP, const char* stopIP, con
}
upsdebugx(2, "%s: proceeding with scan", __func__);
}

/* NOTE: No change to default "pass" in this ifdef:
* if we got to this line, we have a slot to use */
# endif /* HAVE_PTHREAD_TRYJOIN */
Expand Down Expand Up @@ -520,7 +522,7 @@ nutscan_device_t * nutscan_scan_nut(const char* startIP, const char* stopIP, con
}
# else
# ifdef HAVE_PTHREAD_TRYJOIN
/* TODO: Move the wait-loop for TRYJOIN here? */
/* TODO: Move the wait-loop for TRYJOIN here? */
# endif /* HAVE_PTHREAD_TRYJOIN */
# endif /* HAVE_SEMAPHORE */
#endif /* HAVE_PTHREAD */
Expand Down
5 changes: 4 additions & 1 deletion tools/nut-scanner/scan_snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip
nutscan_snmp_t * tmp_sec;
nutscan_ip_iter_t ip;
char * ip_str = NULL;

#ifdef HAVE_PTHREAD
# ifdef HAVE_SEMAPHORE
sem_t * semaphore = nutscan_semaphore();
Expand Down Expand Up @@ -1153,6 +1154,7 @@ nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip
"(launched overall: %" PRIuSIZE "), "
"waiting until some would finish",
__func__, curr_threads, thread_count);

while (curr_threads >= max_threads
|| (curr_threads >= max_threads_scantype && max_threads_scantype > 0)
) {
Expand Down Expand Up @@ -1201,6 +1203,7 @@ nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip
}
upsdebugx(2, "%s: proceeding with scan", __func__);
}

/* NOTE: No change to default "pass" in this ifdef:
* if we got to this line, we have a slot to use */
# endif /* HAVE_PTHREAD_TRYJOIN */
Expand Down Expand Up @@ -1279,7 +1282,7 @@ nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip
}
# else
# ifdef HAVE_PTHREAD_TRYJOIN
/* TODO: Move the wait-loop for TRYJOIN here? */
/* TODO: Move the wait-loop for TRYJOIN here? */
# endif /* HAVE_PTHREAD_TRYJOIN */
# endif /* HAVE_SEMAPHORE */
#endif /* HAVE_PTHREAD */
Expand Down
2 changes: 1 addition & 1 deletion tools/nut-scanner/scan_xml_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ nutscan_device_t * nutscan_scan_xml_http_range(const char * start_ip, const char

thread_count++;
new_thread_array = realloc(thread_array,
thread_count*sizeof(nutscan_thread_t));
thread_count * sizeof(nutscan_thread_t));
if (new_thread_array == NULL) {
upsdebugx(1, "%s: Failed to realloc thread array", __func__);
break;
Expand Down

0 comments on commit f8944fe

Please sign in to comment.