]> arthur.barton.de Git - netatalk.git/commitdiff
Clean up code after all the recent commits.
authorjmarcus <jmarcus>
Thu, 13 Dec 2001 03:31:34 +0000 (03:31 +0000)
committerjmarcus <jmarcus>
Thu, 13 Dec 2001 03:31:34 +0000 (03:31 +0000)
libatalk/cnid/cnid_add.c
libatalk/cnid/cnid_close.c
libatalk/cnid/cnid_open.c
libatalk/cnid/cnid_update.c

index 562649622e85e0bb0a7d3218fc528475534a7340..f5896c0b3343801b1d0d5686fb912985e2c1834b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cnid_add.c,v 1.18 2001-12-12 09:16:20 jmarcus Exp $
+ * $Id: cnid_add.c,v 1.19 2001-12-13 03:31:34 jmarcus Exp $
  *
  * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved. See COPYRIGHT.
@@ -220,14 +220,14 @@ retry_get:
     }
 
 
-       if (0) {
+    if (0) {
 retry:
-       t.tv_usec = rand() % 1000000;
+        t.tv_usec = rand() % 1000000;
 #ifdef DEBUG
-       syslog(LOG_INFO, "cnid_add: Hitting MAX_ABORTS, sleeping");
+        syslog(LOG_INFO, "cnid_add: Hitting MAX_ABORTS, sleeping");
 #endif
-       (void)select(0, NULL, NULL, NULL, &t);
-       }
+        (void)select(0, NULL, NULL, NULL, &t);
+    }
     if ((rc = txn_begin(db->dbenv, NULL, &tid, 0)) != 0) {
         syslog(LOG_ERR, "cnid_add: Failed to begin transaction: %s",
                db_strerror(rc));
index 1200e21187e8e90ded9c6e4f7197849923a2636c..ccb1af8e1816ded8474eb14f972750b7c1cec1a1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cnid_close.c,v 1.15 2001-12-13 02:39:37 jmarcus Exp $
+ * $Id: cnid_close.c,v 1.16 2001-12-13 03:31:34 jmarcus Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -45,14 +45,14 @@ void cnid_close(void *CNID) {
         lock.l_start = lock.l_len = 0;
         if (fcntl(db->lockfd, F_SETLK, &lock) == 0) {
             char **list, **first;
-                       
-                       /* Checkpoint the databases until we can checkpoint no
-                        * more. */
-                       rc = txn_checkpoint(db->dbenv, 0, 0, 0);
-                       while (rc == DB_INCOMPLETE) {
-                               rc = txn_checkpoint(db->dbenv, 0, 0, 0);
-                       }
-                       
+
+            /* Checkpoint the databases until we can checkpoint no
+             * more. */
+            rc = txn_checkpoint(db->dbenv, 0, 0, 0);
+            while (rc == DB_INCOMPLETE) {
+                rc = txn_checkpoint(db->dbenv, 0, 0, 0);
+            }
+
             chdir(db->dbenv->db_log_dir ? db->dbenv->db_log_dir : db->dbenv->db_home);
 #if DB_VERSION_MINOR > 2
             if ((rc = log_archive(db->dbenv, &list, DB_ARCH_LOG)) != 0) {
index 14a2c27fc4f562b886a9b5847a7bec57b944d4d3..e708624296e5eb6268c29535196aaf1157d433d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cnid_open.c,v 1.26 2001-12-13 02:39:37 jmarcus Exp $
+ * $Id: cnid_open.c,v 1.27 2001-12-13 03:31:34 jmarcus Exp $
  *
  * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved. See COPYRIGHT.
@@ -190,7 +190,7 @@ void *cnid_open(const char *dir) {
     struct stat st, rsb;
     struct flock lock;
     char path[MAXPATHLEN + 1];
-       char recover_file[MAXPATHLEN + 1];
+    char recover_file[MAXPATHLEN + 1];
     CNID_private *db;
     DBT key, data;
     DB_TXN *tid;
@@ -230,12 +230,12 @@ void *cnid_open(const char *dir) {
         goto fail_adouble;
     }
 
-       /* Make sure cnid.lock goes in .AppleDB. */
-       strcat(path, "/");
-       len++;
+    /* Make sure cnid.lock goes in .AppleDB. */
+    strcat(path, "/");
+    len++;
 
-       strcpy(recover_file, path);
-       strcat(recover_file, DBRECOVERFILE);
+    strcpy(recover_file, path);
+    strcat(recover_file, DBRECOVERFILE);
 
     /* Search for a byte lock.  This allows us to cleanup the log files
      * at cnid_close() in a clean fashion.
@@ -247,35 +247,35 @@ void *cnid_open(const char *dir) {
         lock.l_start = 0;
         lock.l_len = 1;
         while (fcntl(db->lockfd, F_SETLK, &lock) < 0) {
-               if (++lock.l_start > MAXITER) {
-                       syslog(LOG_ERR, "cnid_open: Cannot establish logfile cleanup for database environment %s lock (lock failed)", path);
-                       close(db->lockfd);
-                       db->lockfd = -1;
-                       break;
-               }
-       }
-       }
+            if (++lock.l_start > MAXITER) {
+                syslog(LOG_ERR, "cnid_open: Cannot establish logfile cleanup for database environment %s lock (lock failed)", path);
+                close(db->lockfd);
+                db->lockfd = -1;
+                break;
+            }
+        }
+    }
     else {
         syslog(LOG_ERR, "cnid_open: Cannot establish logfile cleanup lock for database environment %s (open() failed)", path);
     }
 
-       /* Create a file to represent database recovery.  While this file
-        * exists, the database is being recovered, and all other clients will
-        * sleep until recovery is complete, and this file goes away. */
-       if (!have_lock && db->lockfd > -1 && lock.l_start == 0) {
-               if (stat(recover_file, &rsb) == 0) {
-                       (void)remove(recover_file);
-               }
-               if ((rfd = open(recover_file, O_RDWR | O_CREAT, 0666)) > -1) {
-               DBEXTRAS |= DB_RECOVER;
-                       have_lock = 1;
-               }
-       }
-       else if (!have_lock) {
-               while (stat(recover_file, &rsb) == 0) {
-                       sleep(1);
-               }
-       }
+    /* Create a file to represent database recovery.  While this file
+     * exists, the database is being recovered, and all other clients will
+     * sleep until recovery is complete, and this file goes away. */
+    if (!have_lock && db->lockfd > -1 && lock.l_start == 0) {
+        if (stat(recover_file, &rsb) == 0) {
+            (void)remove(recover_file);
+        }
+        if ((rfd = open(recover_file, O_RDWR | O_CREAT, 0666)) > -1) {
+            DBEXTRAS |= DB_RECOVER;
+            have_lock = 1;
+        }
+    }
+    else if (!have_lock) {
+        while (stat(recover_file, &rsb) == 0) {
+            sleep(1);
+        }
+    }
 
     path[len + DBHOMELEN] = '\0';
     open_flag = DB_CREATE;
@@ -327,21 +327,21 @@ void *cnid_open(const char *dir) {
         syslog(LOG_INFO, "cnid_open: Obtained read-only database environment %s", path);
     }
 
-       /* If we have the recovery lock, close the file, remove it, so other
-        * clients can proceed opening the DB environment. */
-       if (rfd > -1) {
-               (void)remove(recover_file);
-               switch(errno) {
-                       case 0:
-                       case ENOENT:
-                               break;
-                       default:
-                               syslog(LOG_ERR, "cnid_open: Unable to remove %s: %s",
-                                       recover_file, strerror(errno));
-               }
-               close(rfd);
-               rfd = -1;
-       }
+    /* If we have the recovery lock, close the file, remove it, so other
+     * clients can proceed opening the DB environment. */
+    if (rfd > -1) {
+        (void)remove(recover_file);
+        switch(errno) {
+        case 0:
+        case ENOENT:
+            break;
+        default:
+            syslog(LOG_ERR, "cnid_open: Unable to remove %s: %s",
+                   recover_file, strerror(errno));
+        }
+        close(rfd);
+        rfd = -1;
+    }
 
     /* did/name reverse mapping.  We use a BTree for this one. */
     if ((rc = db_create(&db->db_didname, db->dbenv, 0)) != 0) {
index 1fc6ab32ef98a4b9baa4737671839123b66f9a08..035a425771967115648a630009f559c542d9e1c4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cnid_update.c,v 1.14 2001-12-12 09:16:20 jmarcus Exp $
+ * $Id: cnid_update.c,v 1.15 2001-12-13 03:31:34 jmarcus Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -56,11 +56,11 @@ retry:
         switch (rc) {
         case DB_LOCK_DEADLOCK:
             goto retry;
-               case DB_NOTFOUND:
-                       /* Silently fail here.  We're allowed to do this since this CNID
-                        * might have been deleted out from under us, or someone has
-                        * called cnid_lookup then cnid_update (which is redundant). */
-                        return 0;
+        case DB_NOTFOUND:
+            /* Silently fail here.  We're allowed to do this since this CNID
+             * might have been deleted out from under us, or someone has
+             * called cnid_lookup then cnid_update (which is redundant). */
+            return 0;
         default:
             goto update_err;
         }