From: scottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Mon, 12 Apr 2010 13:07:56 +0000 (+0000)
Subject: Restore the ability to set the maximum flesh depth by an entry
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9f1795cb24661f7d6e2efcc5e318b76d97a67fbf;p=evergreen%2Fmasslnc.git

Restore the ability to set the maximum flesh depth by an entry
in the configuration file.  This ability was inadvertently
eliminated in the previous commit.

M    Open-ILS/include/openils/oils_sql.h
M    Open-ILS/src/c-apps/oils_pcrud.c
M    Open-ILS/src/c-apps/oils_rstore.c
M    Open-ILS/src/c-apps/oils_cstore.c
M    Open-ILS/src/c-apps/oils_sql.c


git-svn-id: svn://svn.open-ils.org/ILS/trunk@16199 dcc99617-32d9-48b4-a31d-7c20da2025e4
---

diff --git a/Open-ILS/include/openils/oils_sql.h b/Open-ILS/include/openils/oils_sql.h
index 473731aedb..e01426f165 100644
--- a/Open-ILS/include/openils/oils_sql.h
+++ b/Open-ILS/include/openils/oils_sql.h
@@ -26,7 +26,7 @@ GNU General Public License for more details.
 extern "C" {
 #endif
 
-void oilsSetSQLOptions( const char* module_name, int do_pcrud );
+void oilsSetSQLOptions( const char* module_name, int do_pcrud, int flesh_depth );
 void oilsSetDBConnection( dbi_conn conn );
 int oilsExtendIDL( void );
 int str_is_true( const char* str );
diff --git a/Open-ILS/src/c-apps/oils_cstore.c b/Open-ILS/src/c-apps/oils_cstore.c
index c093b9d574..97bd43af81 100644
--- a/Open-ILS/src/c-apps/oils_cstore.c
+++ b/Open-ILS/src/c-apps/oils_cstore.c
@@ -17,8 +17,6 @@ static dbi_conn writehandle; /* our MASTER db connection */
 static dbi_conn dbhandle; /* our CURRENT db connection */
 //static osrfHash * readHandles;
 
-static int max_flesh_depth = 100;
-
 static const int enforce_pcrud = 0;     // Boolean
 static const char modulename[] = "open-ils.cstore";
 
@@ -93,10 +91,20 @@ int osrfAppInitialize() {
 	osrfLogInfo(OSRF_LOG_MARK, "Initializing the CStore Server...");
 	osrfLogInfo(OSRF_LOG_MARK, "Finding XML file...");
 
-	if (!oilsIDLInit( osrf_settings_host_value("/IDL") ))
+	if ( !oilsIDLInit( osrf_settings_host_value( "/IDL" )))
 		return 1; /* return non-zero to indicate error */
 
-	oilsSetSQLOptions( modulename, enforce_pcrud );
+	char* md = osrf_settings_host_value(
+		"/apps/%s/app_settings/max_query_recursion", modulename );
+	int max_flesh_depth = 100;
+	if( md )
+		max_flesh_depth = atoi( md );
+	if( max_flesh_depth < 0 )
+		max_flesh_depth = 1;
+	else if( max_flesh_depth > 1000 )
+		max_flesh_depth = 1000;
+
+	oilsSetSQLOptions( modulename, enforce_pcrud, max_flesh_depth );
 
 	growing_buffer* method_name = buffer_init(64);
 
@@ -276,8 +284,6 @@ int osrfAppChildInit() {
 	char* port   = osrf_settings_host_value("/apps/%s/app_settings/database/port", modulename );
 	char* db     = osrf_settings_host_value("/apps/%s/app_settings/database/db", modulename );
 	char* pw     = osrf_settings_host_value("/apps/%s/app_settings/database/pw", modulename );
-	char* md     = osrf_settings_host_value("/apps/%s/app_settings/max_query_recursion",
-			modulename );
 
 	osrfLogDebug(OSRF_LOG_MARK, "Attempting to load the database driver [%s]...", driver);
 	writehandle = dbi_conn_new(driver);
@@ -297,10 +303,6 @@ int osrfAppChildInit() {
 	if(pw)   dbi_conn_set_option(writehandle, "password", pw );
 	if(db)   dbi_conn_set_option(writehandle, "dbname", db );
 
-	if(md)                     max_flesh_depth = atoi(md);
-	if(max_flesh_depth < 0)    max_flesh_depth = 1;
-	if(max_flesh_depth > 1000) max_flesh_depth = 1000;
-
 	free(user);
 	free(host);
 	free(port);
diff --git a/Open-ILS/src/c-apps/oils_pcrud.c b/Open-ILS/src/c-apps/oils_pcrud.c
index c4470a7889..02653c8c33 100644
--- a/Open-ILS/src/c-apps/oils_pcrud.c
+++ b/Open-ILS/src/c-apps/oils_pcrud.c
@@ -20,8 +20,6 @@ static dbi_conn writehandle; /* our MASTER db connection */
 static dbi_conn dbhandle; /* our CURRENT db connection */
 //static osrfHash * readHandles;
 
-static int max_flesh_depth = 100;
-
 static const int enforce_pcrud = 1;     // Boolean
 static const char modulename[] = "open-ils.pcrud";
 
@@ -95,10 +93,20 @@ int osrfAppInitialize() {
 	osrfLogInfo(OSRF_LOG_MARK, "Initializing the PCRUD Server...");
 	osrfLogInfo(OSRF_LOG_MARK, "Finding XML file...");
 
-	if (!oilsIDLInit( osrf_settings_host_value("/IDL") ))
+	if ( !oilsIDLInit( osrf_settings_host_value( "/IDL" )))
 		return 1; /* return non-zero to indicate error */
 
-	oilsSetSQLOptions( modulename, enforce_pcrud );
+	char* md = osrf_settings_host_value(
+		"/apps/%s/app_settings/max_query_recursion", modulename );
+	int max_flesh_depth = 100;
+	if( md )
+		max_flesh_depth = atoi( md );
+	if( max_flesh_depth < 0 )
+		max_flesh_depth = 1;
+	else if( max_flesh_depth > 1000 )
+		max_flesh_depth = 1000;
+
+	oilsSetSQLOptions( modulename, enforce_pcrud, max_flesh_depth );
 
 	growing_buffer* method_name = buffer_init(64);
 
@@ -276,8 +284,6 @@ int osrfAppChildInit() {
 	char* port   = osrf_settings_host_value("/apps/%s/app_settings/database/port", modulename );
 	char* db     = osrf_settings_host_value("/apps/%s/app_settings/database/db", modulename );
 	char* pw     = osrf_settings_host_value("/apps/%s/app_settings/database/pw", modulename );
-	char* md     = osrf_settings_host_value("/apps/%s/app_settings/max_query_recursion",
-			modulename );
 
 	osrfLogDebug(OSRF_LOG_MARK, "Attempting to load the database driver [%s]...", driver);
 	writehandle = dbi_conn_new(driver);
@@ -297,10 +303,6 @@ int osrfAppChildInit() {
 	if(pw)   dbi_conn_set_option(writehandle, "password", pw );
 	if(db)   dbi_conn_set_option(writehandle, "dbname", db );
 
-	if(md)                     max_flesh_depth = atoi(md);
-	if(max_flesh_depth < 0)    max_flesh_depth = 1;
-	if(max_flesh_depth > 1000) max_flesh_depth = 1000;
-
 	free(user);
 	free(host);
 	free(port);
diff --git a/Open-ILS/src/c-apps/oils_rstore.c b/Open-ILS/src/c-apps/oils_rstore.c
index dd5dfecff1..582e1c7c3f 100644
--- a/Open-ILS/src/c-apps/oils_rstore.c
+++ b/Open-ILS/src/c-apps/oils_rstore.c
@@ -17,8 +17,6 @@ static dbi_conn writehandle; /* our MASTER db connection */
 static dbi_conn dbhandle; /* our CURRENT db connection */
 //static osrfHash * readHandles;
 
-static int max_flesh_depth = 100;
-
 static const int enforce_pcrud = 0;     // Boolean
 static const char modulename[] = "open-ils.reporter-store";
 
@@ -93,10 +91,20 @@ int osrfAppInitialize() {
 	osrfLogInfo(OSRF_LOG_MARK, "Initializing the RStore Server...");
 	osrfLogInfo(OSRF_LOG_MARK, "Finding XML file...");
 
-	if (!oilsIDLInit( osrf_settings_host_value("/IDL") ))
+	if ( !oilsIDLInit( osrf_settings_host_value( "/IDL" )))
 		return 1; /* return non-zero to indicate error */
 
-	oilsSetSQLOptions( modulename, enforce_pcrud );
+	char* md = osrf_settings_host_value(
+		"/apps/%s/app_settings/max_query_recursion", modulename );
+	int max_flesh_depth = 100;
+	if( md )
+		max_flesh_depth = atoi( md );
+	if( max_flesh_depth < 0 )
+		max_flesh_depth = 1;
+	else if( max_flesh_depth > 1000 )
+		max_flesh_depth = 1000;
+
+	oilsSetSQLOptions( modulename, enforce_pcrud, max_flesh_depth );
 
 	growing_buffer* method_name = buffer_init(64);
 
@@ -276,8 +284,6 @@ int osrfAppChildInit() {
 	char* port   = osrf_settings_host_value("/apps/%s/app_settings/database/port", modulename );
 	char* db     = osrf_settings_host_value("/apps/%s/app_settings/database/db", modulename );
 	char* pw     = osrf_settings_host_value("/apps/%s/app_settings/database/pw", modulename );
-	char* md     = osrf_settings_host_value("/apps/%s/app_settings/max_query_recursion",
-			modulename );
 
 	osrfLogDebug(OSRF_LOG_MARK, "Attempting to load the database driver [%s]...", driver);
 	writehandle = dbi_conn_new(driver);
@@ -297,10 +303,6 @@ int osrfAppChildInit() {
 	if(pw)   dbi_conn_set_option(writehandle, "password", pw );
 	if(db)   dbi_conn_set_option(writehandle, "dbname", db );
 
-	if(md)                     max_flesh_depth = atoi(md);
-	if(max_flesh_depth < 0)    max_flesh_depth = 1;
-	if(max_flesh_depth > 1000) max_flesh_depth = 1000;
-
 	free(user);
 	free(host);
 	free(port);
diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c
index 9d97311b8a..2611c1c363 100644
--- a/Open-ILS/src/c-apps/oils_sql.c
+++ b/Open-ILS/src/c-apps/oils_sql.c
@@ -153,7 +153,7 @@ static char* modulename = NULL;
 	Here we use the server name in messages to identify which kind of server issued them.
 	We use do_crud as a boolean to control whether or not to enforce the permissions scheme.
 */
-void oilsSetSQLOptions( const char* module_name, int do_pcrud ) {
+void oilsSetSQLOptions( const char* module_name, int do_pcrud, int flesh_depth ) {
 	if( !module_name )
 		module_name = "open-ils.cstore";   // bulletproofing with a default
 
@@ -161,8 +161,8 @@ void oilsSetSQLOptions( const char* module_name, int do_pcrud ) {
 		free( modulename );
 
 	modulename = strdup( module_name );
-
 	enforce_pcrud = do_pcrud;
+	max_flesh_depth = flesh_depth;
 }
 
 /**