don't do the fcntl unless the file was openeed
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Thu, 21 Feb 1991 00:59:45 +0000 (16:59 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Thu, 21 Feb 1991 00:59:45 +0000 (16:59 -0800)
SCCS-vsn: lib/libc/db/hash/hash.c 5.4

usr/src/lib/libc/db/hash/hash.c

index 5d9215c..9647f51 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash.c     5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)hash.c     5.4 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -133,10 +133,12 @@ HASHINFO  *info;          /* Special directives for create */
         new_table = 1;
     }
 
         new_table = 1;
     }
 
-    if ( file && ((hashp->fp = open ( file, flags, mode )) == -1)) {
-       RETURN_ERROR (errno, error0);
+    if ( file ) {
+       if ((hashp->fp = open ( file, flags, mode )) == -1) {
+           RETURN_ERROR (errno, error0);
+       }
+       (void)fcntl(hashp->fp, F_SETFD, 1);
     }
     }
-    (void)fcntl(hashp->fp, F_SETFD, 1);
 
     if ( new_table ) {
        if ( !(hashp = init_hash( info )) ) {
 
     if ( new_table ) {
        if ( !(hashp = init_hash( info )) ) {