]> arthur.barton.de Git - netatalk.git/commitdiff
Those damn linked lists: fix cache expiration bug.
authorfranklahm <franklahm>
Fri, 23 Apr 2010 11:37:05 +0000 (11:37 +0000)
committerfranklahm <franklahm>
Fri, 23 Apr 2010 11:37:05 +0000 (11:37 +0000)
Also fixed: LDAP connection retry.

libatalk/acl/cache.c
libatalk/acl/ldap.c

index 0d60d9857169f011f230a7514d53acb53f1e58e7..3b3a888f8682629393038d799b0782e9abe19cb4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  $Id: cache.c,v 1.5 2010-04-23 10:31:40 franklahm Exp $
+  $Id: cache.c,v 1.6 2010-04-23 11:37:05 franklahm Exp $
   Copyright (c) 2008,2009 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
@@ -221,8 +221,10 @@ int search_cachebyname( const char *name, uuidtype_t type, uuidp_t uuid) {
                 /* remove item */
                 if (entry->prev) /* 2nd to last in queue */
                     entry->prev->next = entry->next;
-                else        /* queue head */
-                    namecache[hash] = entry->next;
+                else  { /* queue head */
+                    if ((namecache[hash] = entry->next) != NULL)
+                        namecache[hash]->prev = NULL;
+                }
                 free(entry->name);
                 free(entry->uuid);
                 free(entry);
@@ -267,11 +269,13 @@ int search_cachebyuuid( uuidp_t uuidp, char **name, uuidtype_t *type) {
         if (ret == 0) {
             tim = time(NULL);
             if ((tim - entry->creationtime) > CACHESECONDS) {
-                LOG(log_info, logtype_default, "search_cachebyuuid: expired: name:\'%s\' in queue {%d}", entry->name, hash);
-                if (entry->prev)
+                LOG(log_debug, logtype_default, "search_cachebyuuid: expired: name:\'%s\' in queue {%d}", entry->name, hash);
+                if (entry->prev) /* 2nd to last in queue */
                     entry->prev->next = entry->next;
-                else
-                    uuidcache[hash] = entry->next;
+                else { /* queue head  */
+                    if ((uuidcache[hash] = entry->next) != NULL)
+                        uuidcache[hash]->prev = NULL;
+                }
                 free(entry->name);
                 free(entry->uuid);
                 free(entry);
index bd7925f559b786935d8368ef8522b62ef16bf38d..847f3e3299d04f607791642f8879c43d6af56790 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  $Id: ldap.c,v 1.6 2010-04-22 12:08:14 franklahm Exp $
+  $Id: ldap.c,v 1.7 2010-04-23 11:37:06 franklahm Exp $
   Copyright (c) 2008,2009 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
@@ -100,7 +100,7 @@ static int ldap_getattr_fromfilter_withbase_scope( const char *searchbase,
                                                    int scope,
                                                    ldapcon_t conflags,
                                                    char **result) {
-    int ret = 0;
+    int ret;
     int ldaperr;
     int retrycount = 0;
     int desired_version  = LDAP_VERSION3;
@@ -119,6 +119,8 @@ static int ldap_getattr_fromfilter_withbase_scope( const char *searchbase,
 
     /* init LDAP if necessary */
 retry:
+    ret = 0;
+
     if (!ldapconnected) {
         LOG(log_maxdebug, logtype_default, "ldap_getattr_fromfilter_withbase_scope: LDAP server: \"%s\"",
             ldap_server);