]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
we always have pthread here, too
authorAlan T. DeKok <aland@freeradius.org>
Thu, 18 Oct 2018 13:31:41 +0000 (09:31 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 18 Oct 2018 13:58:18 +0000 (09:58 -0400)
src/modules/proto_detail/proto_detail.c
src/modules/proto_detail/proto_detail.h
src/modules/proto_detail/proto_detail_file.c
src/modules/proto_detail/proto_detail_work.c

index daf4af7a8e4bf7cab2d0c4b6c2afd4093b942721..339a43c193c559085e1b5be954c96c824036e0ba 100644 (file)
@@ -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;
 }
index 218bd6abfbf95e45f4e34c7daa2c3cdb5c61dbdf..db41c22de438b389dce32b5a027e8703a526c08d 100644 (file)
@@ -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 <pthread.h>
-#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
 }
index a855243bb5825a0ccd1d972199d234af187d768b..7b8f918eaad3988f672ec83e86bcd28178d2ce92 100644 (file)
@@ -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
index 5aa290b7d2ef2a89eb0465f31dd210986079c898..e4af61231c4da7cef01b8f52c835ca7a10c4ad1b 100644 (file)
@@ -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);