From: Alan T. DeKok Date: Thu, 18 Oct 2018 13:31:41 +0000 (-0400) Subject: we always have pthread here, too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c7291159ea045fa75cd50daa9367b7a5a0949d0;p=thirdparty%2Ffreeradius-server.git we always have pthread here, too --- diff --git a/src/modules/proto_detail/proto_detail.c b/src/modules/proto_detail/proto_detail.c index daf4af7a8e4..339a43c193c 100644 --- a/src/modules/proto_detail/proto_detail.c +++ b/src/modules/proto_detail/proto_detail.c @@ -669,9 +669,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf) } } -#ifdef HAVE_PTHREAD_H (void) pthread_mutex_init(&inst->worker_mutex, NULL); -#endif return 0; } @@ -688,9 +686,7 @@ static int mod_detach(void *instance) { proto_detail_t *inst = talloc_get_type_abort(instance, proto_detail_t); -#ifdef HAVE_PTHREAD_H pthread_mutex_destroy(&inst->worker_mutex); -#endif return 0; } diff --git a/src/modules/proto_detail/proto_detail.h b/src/modules/proto_detail/proto_detail.h index 218bd6abfbf..db41c22de43 100644 --- a/src/modules/proto_detail/proto_detail.h +++ b/src/modules/proto_detail/proto_detail.h @@ -64,9 +64,7 @@ typedef struct proto_detail_t { fr_listen_t *listen; //!< The listener structure which describes //!< the I/O path. -#ifdef HAVE_PTHREAD_H pthread_mutex_t worker_mutex; //!< for the workers -#endif int num_workers; //!< number of workers } proto_detail_t; @@ -136,15 +134,7 @@ typedef struct proto_detail_process_t { rlm_components_t send_type; } proto_detail_process_t; -#ifdef HAVE_PTHREAD_H #include -#define PTHREAD_MUTEX_LOCK pthread_mutex_lock -#define PTHREAD_MUTEX_UNLOCK pthread_mutex_unlock - -#else -#define PTHREAD_MUTEX_LOCK -#define PTHREAD_MUTEX_UNLOCK -#endif #ifdef __cplusplus } diff --git a/src/modules/proto_detail/proto_detail_file.c b/src/modules/proto_detail/proto_detail_file.c index a855243bb58..7b8f918eaad 100644 --- a/src/modules/proto_detail/proto_detail_file.c +++ b/src/modules/proto_detail/proto_detail_file.c @@ -103,9 +103,9 @@ static void mod_vnode_extend(fr_listen_t *li, UNUSED uint32_t fflags) proto_detail_file_t *inst = talloc_get_type_abort(li->thread_instance, proto_detail_file_t); bool has_worker = false; - PTHREAD_MUTEX_LOCK(&inst->parent->worker_mutex); + pthread_mutex_lock(&inst->parent->worker_mutex); has_worker = (inst->parent->num_workers != 0); - PTHREAD_MUTEX_UNLOCK(&inst->parent->worker_mutex); + pthread_mutex_unlock(&inst->parent->worker_mutex); if (has_worker) return; @@ -354,9 +354,9 @@ static int work_exists(proto_detail_file_t *inst, int fd) li->default_message_size = inst->parent->max_packet_size; li->num_messages = inst->parent->num_messages; - PTHREAD_MUTEX_LOCK(&inst->parent->worker_mutex); + pthread_mutex_lock(&inst->parent->worker_mutex); inst->parent->num_workers++; - PTHREAD_MUTEX_UNLOCK(&inst->parent->worker_mutex); + pthread_mutex_unlock(&inst->parent->worker_mutex); /* * Instantiate the new worker. @@ -452,9 +452,9 @@ static void work_init(proto_detail_file_t *inst) int fd, rcode; bool has_worker; - PTHREAD_MUTEX_LOCK(&inst->parent->worker_mutex); + pthread_mutex_lock(&inst->parent->worker_mutex); has_worker = (inst->parent->num_workers != 0); - PTHREAD_MUTEX_UNLOCK(&inst->parent->worker_mutex); + pthread_mutex_unlock(&inst->parent->worker_mutex); /* * The worker is still processing the file, poll until diff --git a/src/modules/proto_detail/proto_detail_work.c b/src/modules/proto_detail/proto_detail_work.c index 5aa290b7d2e..e4af61231c4 100644 --- a/src/modules/proto_detail/proto_detail_work.c +++ b/src/modules/proto_detail/proto_detail_work.c @@ -722,10 +722,10 @@ static int mod_close_internal(proto_detail_work_t *inst) * hacks in proto_detail which let us start up with * "transport = work" for debugging purposes. */ - PTHREAD_MUTEX_LOCK(&inst->parent->worker_mutex); + pthread_mutex_lock(&inst->parent->worker_mutex); inst->parent->work_io_instance = NULL; if (inst->parent->num_workers > 0) inst->parent->num_workers--; - PTHREAD_MUTEX_UNLOCK(&inst->parent->worker_mutex); + pthread_mutex_unlock(&inst->parent->worker_mutex); DEBUG("Closing and deleting detail worker file %s", inst->name);