Skip to content

Commit

Permalink
tools/nut-scanner/scan_snmp.c, tools/nut-scanner/scan_nut.c: fix orde…
Browse files Browse the repository at this point in the history
…r of WIN32 active init calls vs. pthread variable declarations [networkupstools#2511]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 8, 2024
1 parent a60d9ea commit d86ec9c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
13 changes: 8 additions & 5 deletions tools/nut-scanner/scan_nut.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,6 @@ nutscan_device_t * nutscan_scan_nut(const char* startIP, const char* stopIP, con
int change_action_handler = 0;
#endif
struct scan_nut_arg *nut_arg;
#ifdef WIN32
WSADATA WSAdata;
WSAStartup(2,&WSAdata);
atexit((void(*)(void))WSACleanup);
#endif

#ifdef HAVE_PTHREAD
# ifdef HAVE_SEMAPHORE
Expand All @@ -265,7 +260,15 @@ nutscan_device_t * nutscan_scan_nut(const char* startIP, const char* stopIP, con
# if (defined HAVE_PTHREAD_TRYJOIN) || (defined HAVE_SEMAPHORE)
size_t max_threads_scantype = max_threads_oldnut;
# endif
#endif /* HAVE_PTHREAD */

#ifdef WIN32
WSADATA WSAdata;
WSAStartup(2,&WSAdata);
atexit((void(*)(void))WSACleanup);
#endif

#ifdef HAVE_PTHREAD
pthread_mutex_init(&dev_mutex, NULL);

# ifdef HAVE_SEMAPHORE
Expand Down
15 changes: 8 additions & 7 deletions tools/nut-scanner/scan_snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1035,20 +1035,21 @@ nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip
sem_t semaphore_scantype_inst;
sem_t * semaphore_scantype = &semaphore_scantype_inst;
# endif /* HAVE_SEMAPHORE */

# ifdef WIN32
WSADATA WSAdata;
WSAStartup(2,&WSAdata);
atexit((void(*)(void))WSACleanup);
# endif

pthread_t thread;
nutscan_thread_t * thread_array = NULL;
size_t thread_count = 0, i;
# if (defined HAVE_PTHREAD_TRYJOIN) || (defined HAVE_SEMAPHORE)
size_t max_threads_scantype = max_threads_netsnmp;
# endif
#endif /* HAVE_PTHREAD */

#ifdef WIN32
WSADATA WSAdata;
WSAStartup(2,&WSAdata);
atexit((void(*)(void))WSACleanup);
#endif

#ifdef HAVE_PTHREAD
pthread_mutex_init(&dev_mutex, NULL);

# ifdef HAVE_SEMAPHORE
Expand Down

0 comments on commit d86ec9c

Please sign in to comment.