Fix a bug spotted by Jason Stephenson and Thomas Berezansky
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 13 Mar 2012 21:40:28 +0000 (17:40 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 19 Mar 2012 13:50:26 +0000 (09:50 -0400)
I was leaving local variables called 'cache' high and dry in many
functions calling the initSessionCache() function that was introduced to
reduce code repetition.

This seems to fix that

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>

Open-ILS/src/c-apps/oils_sql.c

index d02fb2c..4d33f7d 100644 (file)
@@ -529,10 +529,11 @@ static void pcacheFree( char* key, void* item ) {
        Create a cache for the session by making the session's userData member point
        to an osrfHash instance.
 */
-static void initSessionCache( osrfMethodContext* ctx ) {
+static osrfHash* initSessionCache( osrfMethodContext* ctx ) {
        ctx->session->userData = osrfNewHash();
        osrfHashSetCallback( (osrfHash*) ctx->session->userData, &sessionDataFree );
        ctx->session->userDataFree = &userDataFree;
+       return ctx->session->userData;
 }
 
 /**
@@ -550,7 +551,7 @@ static void setXactId( osrfMethodContext* ctx ) {
                // If the session doesn't already have a hash, create one.  Make sure
                // that the application session frees the hash when it terminates.
                if( NULL == cache )
-                       initSessionCache( ctx );
+                       cache = initSessionCache( ctx );
 
                // Save the transaction id in the hash, with the key "xact_id"
                osrfHashSet( cache, strdup( session->session_id ), "xact_id" );
@@ -597,7 +598,7 @@ static void setPermLocationCache( osrfMethodContext* ctx, const char* perm, osrf
                // If the session doesn't already have a hash, create one.  Make sure
                // that the application session frees the hash when it terminates.
                if( NULL == cache )
-                       initSessionCache( ctx );
+                       cache = initSessionCache( ctx );
 
                osrfHash* pcache = osrfHashGet(cache, "pcache");
 
@@ -649,7 +650,7 @@ static void setUserLogin( osrfMethodContext* ctx, jsonObject* user_login ) {
                // If the session doesn't already have a hash, create one.  Make sure
                // that the application session frees the hash when it terminates.
                if( NULL == cache )
-                       initSessionCache( ctx );
+                       cache = initSessionCache( ctx );
 
                if( user_login )
                        osrfHashSet( cache, user_login, "user_login" );
@@ -688,7 +689,7 @@ static void setAuthkey( osrfMethodContext* ctx, const char* authkey ) {
                // If the session doesn't already have a hash, create one.  Make sure
                // that the application session frees the hash when it terminates.
                if( NULL == cache )
-                       initSessionCache( ctx );
+                       cache = initSessionCache( ctx );
 
                // Save the transaction id in the hash, with the key "xact_id"
                if( authkey && *authkey )
@@ -5561,7 +5562,7 @@ static jsonObject* doFieldmapperSearch( osrfMethodContext* ctx, osrfHash* class_
        char* pkey = osrfHashGet( class_meta, "primarykey" );
 
        if (!ctx->session->userData)
-               initSessionCache( ctx );
+               (void) initSessionCache( ctx );
 
        char *methodtype = osrfHashGet( (osrfHash *) ctx->method->userData, "methodtype" );
        char *inside_verify = osrfHashGet( (osrfHash*) ctx->session->userData, "inside_verify" );