@@ -227,6 +227,8 @@ static void _oauth2_cache_register(oauth2_log_t *log, const char *name,
227227{
228228 oauth2_cache_list_t * ptr = NULL , * prev = NULL ;
229229
230+ oauth2_debug (log , "enter: %s" , name );
231+
230232 ptr = oauth2_mem_alloc (sizeof (oauth2_cache_list_t ));
231233 ptr -> name = oauth2_strdup (name );
232234 ptr -> cache = cache ;
@@ -239,15 +241,22 @@ static void _oauth2_cache_register(oauth2_log_t *log, const char *name,
239241 } else {
240242 _cache_list = ptr ;
241243 }
244+
245+ oauth2_debug (log , "leave" );
242246}
243247
244248oauth2_cache_t * _oauth2_cache_obtain (oauth2_log_t * log , const char * name )
245249{
250+ oauth2_cache_t * rv = NULL ;
246251 oauth2_cache_list_t * ptr = NULL , * result = NULL ;
247252
253+ oauth2_debug (log , "enter: %s" , name );
254+
248255 if (_cache_list == NULL ) {
249- oauth2_cache_init (log , NULL , NULL );
250- oauth2_cache_post_config (log , _cache_list -> cache );
256+ if (oauth2_cache_init (log , NULL , NULL ) == NULL )
257+ goto end ;
258+ if (oauth2_cache_post_config (log , _cache_list -> cache ) == false)
259+ goto end ;
251260 }
252261
253262 ptr = _cache_list ;
@@ -263,16 +272,27 @@ oauth2_cache_t *_oauth2_cache_obtain(oauth2_log_t *log, const char *name)
263272 ptr = ptr -> next ;
264273 }
265274
266- return result ? oauth2_cache_clone (log , result -> cache ) : NULL ;
275+ rv = result ? oauth2_cache_clone (log , result -> cache ) : NULL ;
276+
277+ end :
278+
279+ oauth2_debug (log , "leave: %p" , rv );
280+
281+ return rv ;
267282}
268283
269284void oauth2_cache_release (oauth2_log_t * log , oauth2_cache_t * cache )
270285{
271286 oauth2_cache_list_t * ptr = NULL , * prev = NULL ;
272- oauth2_uint_t refcount = cache -> refcount ;
287+ oauth2_uint_t refcount = 0 ;
273288
274- if (cache )
275- _oauth2_cache_free (log , cache );
289+ oauth2_debug (log , "enter" );
290+
291+ if (cache == NULL )
292+ goto end ;
293+
294+ refcount = cache -> refcount ;
295+ _oauth2_cache_free (log , cache );
276296
277297 if (refcount > 1 )
278298 goto end ;
@@ -296,13 +316,17 @@ void oauth2_cache_release(oauth2_log_t *log, oauth2_cache_t *cache)
296316
297317end :
298318
319+ oauth2_debug (log , "return" );
320+
299321 return ;
300322}
301323
302324bool oauth2_cache_post_config (oauth2_log_t * log , oauth2_cache_t * cache )
303325{
304326 bool rc = false;
305327
328+ oauth2_debug (log , "enter" );
329+
306330 if ((cache == NULL ) || (cache -> type == NULL ))
307331 goto end ;
308332
@@ -315,6 +339,8 @@ bool oauth2_cache_post_config(oauth2_log_t *log, oauth2_cache_t *cache)
315339
316340end :
317341
342+ oauth2_debug (log , "return: %d" , rc );
343+
318344 return rc ;
319345}
320346
@@ -420,7 +446,7 @@ bool oauth2_cache_set(oauth2_log_t *log, oauth2_cache_t *cache, const char *key,
420446 "enter: key=%s, len=%lu, ttl(s)=" OAUTH2_TIME_T_FORMAT
421447 ", type=%s, encrypt=%d" ,
422448 key , value ? (unsigned long )strlen (value ) : 0 , ttl_s ,
423- cache && cache -> type ? cache -> type -> name : "<n/a>" ,
449+ ( cache && cache -> type ) ? cache -> type -> name : "<n/a>" ,
424450 cache ? cache -> encrypt : -1 );
425451
426452 if ((cache == NULL ) || (cache -> type == NULL ) ||
0 commit comments