]> 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 d1f82977b2008d987e01b1fc28837f0b2963134f..b81e32b76b28c74ae50f8922323327e93404515c 100644 (file)
@@ -1,3 +1,12 @@
+/*
+ * $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>
@@ -35,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,
-                                    &key, &data, 0)) {
-    if (errno == EAGAIN) 
+  while ((rc = db->db_didname->get(db->db_didname, NULL,
+                                     &key, &data, 0))) {
+    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;
   }
@@ -49,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 */