check for in memory tree
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 14 Nov 1992 09:17:54 +0000 (01:17 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 14 Nov 1992 09:17:54 +0000 (01:17 -0800)
SCCS-vsn: lib/libc/db/recno/rec_close.c 5.6

usr/src/lib/libc/db/recno/rec_close.c

index 691223f..1933bec 100644 (file)
@@ -6,15 +6,17 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_close.c        5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)rec_close.c        5.6 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
 #include <sys/uio.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
 #include <sys/uio.h>
-#include <errno.h>
+
 #include <db.h>
 #include <db.h>
-#include <unistd.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdio.h>
+#include <unistd.h>
+
 #include "recno.h"
 
 /*
 #include "recno.h"
 
 /*
@@ -38,7 +40,8 @@ __rec_close(dbp)
 
        /* Committed to closing. */
        t = dbp->internal;
 
        /* Committed to closing. */
        t = dbp->internal;
-       rval = t->bt_rfp == NULL ? close(t->bt_rfd) : fclose(t->bt_rfp);
+       rval = ISSET(t, BTF_RINMEM) ? 0 :
+           t->bt_rfp == NULL ? close(t->bt_rfd) : fclose(t->bt_rfp);
 
        if (__bt_close(dbp) == RET_ERROR)
                return (RET_ERROR);
 
        if (__bt_close(dbp) == RET_ERROR)
                return (RET_ERROR);
@@ -68,8 +71,7 @@ __rec_sync(dbp)
 
        t = dbp->internal;
 
 
        t = dbp->internal;
 
-       if (ISSET(t, BTF_INMEM) || ISSET(t, BTF_RDONLY) ||
-           NOTSET(t, BTF_MODIFIED))
+       if (ISSET(t, BTF_RDONLY | BTF_RINMEM) || !ISSET(t, BTF_MODIFIED))
                return (RET_SUCCESS);
 
        /* Read any remaining records into the tree. */
                return (RET_SUCCESS);
 
        /* Read any remaining records into the tree. */
@@ -102,6 +104,6 @@ __rec_sync(dbp)
                return (RET_ERROR);
        if (ftruncate(t->bt_rfd, off))
                return (RET_ERROR);
                return (RET_ERROR);
        if (ftruncate(t->bt_rfd, off))
                return (RET_ERROR);
-       UNSET(t, BTF_MODIFIED);
+       CLR(t, BTF_MODIFIED);
        return (RET_SUCCESS);
 }
        return (RET_SUCCESS);
 }