]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
do closing in mod_close(), not mod_detach()
authorAlan T. DeKok <aland@freeradius.org>
Fri, 21 Sep 2018 14:49:22 +0000 (10:49 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 21 Sep 2018 14:49:22 +0000 (10:49 -0400)
src/modules/proto_detail/proto_detail_work.c

index ef4962c71eec0f45a3e90fa9ae8833f3366db5ec..7931a7b90d956216106f48f56bae7fd577820a4b 100644 (file)
@@ -717,9 +717,14 @@ static int mod_open(fr_listen_t *li)
 
 static int mod_close_internal(proto_detail_work_t *inst)
 {
+       /*
+        *      One less worker...  we check for "0" because of the
+        *      hacks in proto_detail which let us start up with
+        *      "transport = work" for debugging purposes.
+        */
        PTHREAD_MUTEX_LOCK(&inst->parent->worker_mutex);
        inst->parent->work_io_instance = NULL;
-       inst->parent->num_workers--;
+       if (inst->parent->num_workers > 0) inst->parent->num_workers--;
        PTHREAD_MUTEX_UNLOCK(&inst->parent->worker_mutex);
 
        DEBUG("Closing and deleting detail worker file %s", inst->name);
@@ -743,8 +748,6 @@ static int mod_close_internal(proto_detail_work_t *inst)
 }
 
 
-
-
 /** Close  a detail listener
  *
  */
@@ -869,24 +872,6 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        return 0;
 }
 
-static int mod_detach(void *instance)
-{
-       proto_detail_work_t     *inst = talloc_get_type_abort(instance, proto_detail_work_t);
-
-       if (inst->fd >= 0) close(inst->fd);
-
-       /*
-        *      One less worker...  we check for "0" because of the
-        *      hacks in proto_detail which let us start up with
-        *      "transport = work" for debugging purposes.
-        */
-       PTHREAD_MUTEX_LOCK(&inst->parent->worker_mutex);
-       if (inst->parent->num_workers > 0) inst->parent->num_workers--;
-       PTHREAD_MUTEX_UNLOCK(&inst->parent->worker_mutex);
-
-       return 0;
-}
-
 
 /** Private interface for use by proto_detail_file
  *
@@ -897,7 +882,6 @@ fr_app_io_t proto_detail_work = {
        .name                   = "detail_work",
        .config                 = file_listen_config,
        .inst_size              = sizeof(proto_detail_work_t),
-       .detach                 = mod_detach,
        .bootstrap              = mod_bootstrap,
        .instantiate            = mod_instantiate,