]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/cnid/cnid_get.c
Fix a bunch of problems with database contention and corruption. Note:
[netatalk.git] / libatalk / cnid / cnid_get.c
index e569e8c9962e600950988e99013246e4e49ea6b1..b81e32b76b28c74ae50f8922323327e93404515c 100644 (file)
@@ -1,11 +1,12 @@
 /*
- * $Id: cnid_get.c,v 1.3 2001-08-15 02:16:25 srittau Exp $
+ * $Id: cnid_get.c,v 1.5 2001-09-21 15:08:37 jmarcus Exp $
  */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
 
+#ifdef CNID_DB
 #include <stdio.h>
 #include <string.h>
 #include <sys/param.h>
@@ -43,13 +44,13 @@ cnid_t cnid_get(void *CNID, const cnid_t did, const char *name,
   key.data = start;
   key.size = CNID_DID_LEN + len + 1;
 
-  while ((errno = db->db_didname->get(db->db_didname, NULL,
+  while ((rc = db->db_didname->get(db->db_didname, NULL,
                                      &key, &data, 0))) {
-    if (errno == EAGAIN) 
+    if (rc == EAGAIN) 
       continue;
 
-    if (errno != DB_NOTFOUND)
-      syslog(LOG_ERR, "cnid_get: can't get CNID(%u:%s)", did, name);
+    if (rc != DB_NOTFOUND)
+      syslog(LOG_ERR, "cnid_get: can't get CNID(%u:%s) (%d)", did, name, rc);
 
     return 0;
   }
@@ -57,3 +58,4 @@ cnid_t cnid_get(void *CNID, const cnid_t did, const char *name,
   memcpy(&id, data.data, sizeof(id));
   return id;
 }
+#endif /* CNID_DB */