kopia lustrzana https://github.com/Hamlib/Hamlib
Remove conditionals based on HAVE_PTHREAD
rodzic
002677e48c
commit
1c0de2107c
|
@ -54,9 +54,7 @@
|
|||
# include <netdb.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
# include <pthread.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
|
||||
#include "hamlib/amplifier.h"
|
||||
|
||||
|
@ -168,10 +166,8 @@ int main(int argc, char *argv[])
|
|||
char host[NI_MAXHOST];
|
||||
char serv[NI_MAXSERV];
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_t thread;
|
||||
pthread_attr_t attr;
|
||||
#endif
|
||||
struct handle_data *arg;
|
||||
#ifdef SIGPIPE
|
||||
#if HAVE_SIGACTION
|
||||
|
@ -557,7 +553,6 @@ int main(int argc, char *argv[])
|
|||
host,
|
||||
serv);
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
|
||||
|
@ -569,9 +564,6 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
}
|
||||
|
||||
#else
|
||||
handle_socket(arg);
|
||||
#endif
|
||||
}
|
||||
|
||||
while (retcode == 0);
|
||||
|
@ -676,9 +668,7 @@ handle_exit:
|
|||
#endif
|
||||
free(arg);
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_exit(NULL);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,9 +64,7 @@
|
|||
# include <netdb.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
# include <pthread.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include "misc.h"
|
||||
|
@ -129,9 +127,7 @@ void *handle_socket(void *arg);
|
|||
void usage(void);
|
||||
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
static unsigned client_count;
|
||||
#endif
|
||||
|
||||
static RIG *my_rig; /* handle to rig (instance) */
|
||||
static volatile int rig_opened = 0;
|
||||
|
@ -159,7 +155,6 @@ static int bind_all = 0;
|
|||
|
||||
void mutex_rigctld(int lock)
|
||||
{
|
||||
#ifdef HAVE_PTHREAD
|
||||
static pthread_mutex_t client_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
if (lock)
|
||||
|
@ -173,7 +168,6 @@ void mutex_rigctld(int lock)
|
|||
pthread_mutex_unlock(&client_lock);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -273,10 +267,8 @@ int main(int argc, char *argv[])
|
|||
struct sigaction act;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_t thread;
|
||||
pthread_attr_t attr;
|
||||
#endif
|
||||
struct handle_data *arg;
|
||||
int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
|
||||
int i;
|
||||
|
@ -1070,7 +1062,6 @@ int main(int argc, char *argv[])
|
|||
host,
|
||||
serv);
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
|
||||
|
@ -1082,16 +1073,12 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
}
|
||||
|
||||
#else
|
||||
handle_socket(arg);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
while (!ctrl_c);
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: while loop done\n", __func__);
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
/* allow threads to finish current action */
|
||||
mutex_rigctld(1);
|
||||
|
||||
|
@ -1107,9 +1094,6 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
rig_close(my_rig);
|
||||
mutex_rigctld(0);
|
||||
#else
|
||||
rig_close(my_rig); /* close port */
|
||||
#endif
|
||||
|
||||
rig_cleanup(my_rig); /* if you care about memory */
|
||||
|
||||
|
@ -1185,7 +1169,6 @@ void *handle_socket(void *arg)
|
|||
goto handle_exit;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
mutex_rigctld(1);
|
||||
|
||||
++client_count;
|
||||
|
@ -1206,19 +1189,6 @@ void *handle_socket(void *arg)
|
|||
#endif
|
||||
|
||||
mutex_rigctld(0);
|
||||
#else
|
||||
mutex_rigctld(1);
|
||||
retcode = rig_open(my_rig);
|
||||
mutex_rigctld(0);
|
||||
|
||||
if (RIG_OK == retcode && verbose > RIG_DEBUG_ERR)
|
||||
{
|
||||
printf("Opened rig model %d, '%s'\n",
|
||||
my_rig->caps->rig_model,
|
||||
my_rig->caps->model_name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (my_rig->caps->get_powerstat)
|
||||
{
|
||||
|
@ -1314,21 +1284,16 @@ void *handle_socket(void *arg)
|
|||
}
|
||||
while (!ctrl_c && (retcode == RIG_OK || RIG_IS_SOFT_ERRCODE(retcode)));
|
||||
|
||||
#if defined(HAVE_PTHREAD)
|
||||
|
||||
mutex_rigctld(1);
|
||||
if (rigctld_idle && client_count == 1)
|
||||
#else
|
||||
if (rigctld_idle)
|
||||
#endif
|
||||
{
|
||||
rig_close(my_rig);
|
||||
|
||||
if (verbose > RIG_DEBUG_ERR) { printf("Closed rig model %s. Will reopen for new clients\n", my_rig->caps->model_name); }
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
--client_count;
|
||||
mutex_rigctld(0);
|
||||
|
||||
if (rigctld_idle && client_count > 0) { printf("%u client%s still connected so rig remains open\n", client_count, client_count > 1 ? "s" : ""); }
|
||||
|
||||
|
@ -1349,17 +1314,6 @@ void *handle_socket(void *arg)
|
|||
}
|
||||
|
||||
mutex_rigctld(0);
|
||||
#endif
|
||||
#else
|
||||
rig_close(my_rig);
|
||||
|
||||
if (verbose > RIG_DEBUG_ERR)
|
||||
{
|
||||
printf("Closed rig model %d, '%s - will reopen for new clients'\n",
|
||||
my_rig->caps->rig_model,
|
||||
my_rig->caps->model_name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if ((retcode = getnameinfo((struct sockaddr const *)&handle_data_arg->cli_addr,
|
||||
|
@ -1404,9 +1358,7 @@ handle_exit:
|
|||
|
||||
free(arg);
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_exit(NULL);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue