mod_conn_create should not be global
authorAlan T. DeKok <aland@freeradius.org>
Fri, 24 Feb 2017 16:49:41 +0000 (11:49 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 24 Feb 2017 16:49:41 +0000 (11:49 -0500)
src/modules/rlm_sql/rlm_sql.c
src/modules/rlm_sql/rlm_sql.h
src/modules/rlm_sql/sql.c

index f60753d..6050246 100644 (file)
@@ -919,6 +919,50 @@ static int mod_bootstrap(CONF_SECTION *conf, void *instance)
 }
 
 
+static void *mod_conn_create(TALLOC_CTX *ctx, void *instance)
+{
+       int rcode;
+       rlm_sql_t *inst = instance;
+       rlm_sql_handle_t *handle;
+
+       /*
+        *      Connections cannot be alloced from the inst or
+        *      pool contexts due to threading issues.
+        */
+       handle = talloc_zero(ctx, rlm_sql_handle_t);
+       if (!handle) return NULL;
+
+       handle->log_ctx = talloc_pool(handle, 2048);
+       if (!handle->log_ctx) {
+               talloc_free(handle);
+               return NULL;
+       }
+
+       /*
+        *      Handle requires a pointer to the SQL inst so the
+        *      destructor has access to the module configuration.
+        */
+       handle->inst = inst;
+
+       rcode = (inst->module->sql_socket_init)(handle, inst->config);
+       if (rcode != 0) {
+       fail:
+               /*
+                *      Destroy any half opened connections.
+                */
+               talloc_free(handle);
+               return NULL;
+       }
+
+       if (inst->config->connect_query) {
+               if (rlm_sql_select_query(inst, NULL, &handle, inst->config->connect_query) != RLM_SQL_OK) goto fail;
+               (inst->module->sql_finish_select_query)(handle, inst->config);
+       }
+
+       return handle;
+}
+
+
 static int mod_instantiate(CONF_SECTION *conf, void *instance)
 {
        rlm_sql_t *inst = instance;
index a241353..eba8a90 100644 (file)
@@ -242,7 +242,6 @@ typedef struct sql_grouplist {
        struct sql_grouplist    *next;
 } rlm_sql_grouplist_t;
 
-void           *mod_conn_create(TALLOC_CTX *ctx, void *instance);
 int            sql_fr_pair_list_afrom_str(TALLOC_CTX *ctx, REQUEST *request, VALUE_PAIR **first_pair, rlm_sql_row_t row);
 int            sql_read_realms(rlm_sql_handle_t *handle);
 int            sql_getvpdata(TALLOC_CTX *ctx, rlm_sql_t *inst, REQUEST *request, rlm_sql_handle_t **handle, VALUE_PAIR **pair, char const *query);
index 51ba11d..05d0bc2 100644 (file)
@@ -54,49 +54,6 @@ const FR_NAME_NUMBER sql_rcode_table[] = {
 };
 
 
-void *mod_conn_create(TALLOC_CTX *ctx, void *instance)
-{
-       int rcode;
-       rlm_sql_t *inst = instance;
-       rlm_sql_handle_t *handle;
-
-       /*
-        *      Connections cannot be alloced from the inst or
-        *      pool contexts due to threading issues.
-        */
-       handle = talloc_zero(ctx, rlm_sql_handle_t);
-       if (!handle) return NULL;
-
-       handle->log_ctx = talloc_pool(handle, 2048);
-       if (!handle->log_ctx) {
-               talloc_free(handle);
-               return NULL;
-       }
-
-       /*
-        *      Handle requires a pointer to the SQL inst so the
-        *      destructor has access to the module configuration.
-        */
-       handle->inst = inst;
-
-       rcode = (inst->module->sql_socket_init)(handle, inst->config);
-       if (rcode != 0) {
-       fail:
-               /*
-                *      Destroy any half opened connections.
-                */
-               talloc_free(handle);
-               return NULL;
-       }
-
-       if (inst->config->connect_query) {
-               if (rlm_sql_select_query(inst, NULL, &handle, inst->config->connect_query) != RLM_SQL_OK) goto fail;
-               (inst->module->sql_finish_select_query)(handle, inst->config);
-       }
-
-       return handle;
-}
-
 /*************************************************************************
  *
  *     Function: sql_fr_pair_list_afrom_str