From 53050b31c4f77930ffad360576bbdc7b7e65abd7 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Tue, 9 Aug 2011 14:12:43 -0400 Subject: [PATCH] Branchify beginnings of a patch to LP bug #702206. Signed-off-by: Jason Stephenson --- Open-ILS/src/c-apps/oils_sql.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c index b79c5799a5..cc5ae77117 100644 --- a/Open-ILS/src/c-apps/oils_sql.c +++ b/Open-ILS/src/c-apps/oils_sql.c @@ -330,6 +330,17 @@ int oilsExtendIDL( dbi_conn handle ) { growing_buffer* query_buf = buffer_init( 64 ); int results_found = 0; // boolean + // Set a statement timeout of 1 second + dbi_result result = dbi_conn_query( handle, "SET statement_timeout TO 5000;" ); + if( result ) { + dbi_result_free( result ); + } else { + const char* msg; + int errnum = dbi_conn_error( handle, &msg ); + osrfLogError( OSRF_LOG_MARK, "Could not set session timeout! %s", + msg ? msg : "(No description available)" ); + } + // For each class in the IDL... while( (class = osrfHashIteratorNext( class_itr ) ) ) { const char* classname = osrfHashIteratorKey( class_itr ); @@ -353,7 +364,7 @@ int oilsExtendIDL( dbi_conn handle ) { osrfLogDebug( OSRF_LOG_MARK, "%s Investigatory SQL = %s", modulename, OSRF_BUFFER_C_STR( query_buf ) ); - dbi_result result = dbi_conn_query( handle, OSRF_BUFFER_C_STR( query_buf ) ); + result = dbi_conn_query( handle, OSRF_BUFFER_C_STR( query_buf ) ); if( result ) { results_found = 1; @@ -440,6 +451,17 @@ int oilsExtendIDL( dbi_conn handle ) { osrfHashIteratorFree( class_itr ); child_initialized = 1; + // Unset a statement timeout of 1 second + result = dbi_conn_query( handle, "SET statement_timeout TO DEFAULT;" ); + if( result ) { + dbi_result_free( result ); + } else { + const char* msg; + int errnum = dbi_conn_error( handle, &msg ); + osrfLogError( OSRF_LOG_MARK, "Could not set session timeout! %s", + msg ? msg : "(No description available)" ); + } + if( !results_found ) { osrfLogError( OSRF_LOG_MARK, "No results found for any class -- bad database connection?" ); -- 2.11.0