]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
This commit was generated by cvs2svn to compensate for changes in r489,
authorSam Hartman <hartmans@debian.org>
Mon, 10 Jun 2002 11:48:35 +0000 (11:48 +0000)
committerSam Hartman <hartmans@debian.org>
Mon, 10 Jun 2002 11:48:35 +0000 (11:48 +0000)
which included commits to RCS files with non-trunk default branches.

32 files changed:
NEWS
acinclude.m4
configure-libafs.in
src/afs/VNOPS/afs_vnop_attrs.c
src/afs/VNOPS/afs_vnop_remove.c
src/afs/afs_callback.c
src/afs/afs_segments.c
src/afs/sysincludes.h
src/afsd/afsd.c
src/des/crypt.c
src/dir/buffer.c
src/fsint/afsaux.c
src/fsint/afsint.xg
src/fsint/common.xg
src/libafs/MakefileProto.AIX.in
src/libafs/MakefileProto.DARWIN.in
src/libafs/MakefileProto.FBSD.in
src/libafs/MakefileProto.HPUX.in
src/libafs/MakefileProto.IRIX.in
src/libafs/MakefileProto.OBSD.in
src/libafs/MakefileProto.SOLARIS.in
src/rx/rx_kcommon.c
src/rx/rx_kcommon.h
src/rx/xdr.h
src/rx/xdr_rx.c
src/rxgen/rpc_main.c
src/rxkad/rxkad_client.c
src/rxkad/rxkad_common.c
src/util/NTMakefile
src/viced/host.c
src/vlserver/vldbint.xg
src/vol/ihandle.c

diff --git a/NEWS b/NEWS
index 61bda66ada312f929ad17b9114e99f86e900163a..999ef87614bcbda248938940c2eb2e03f2873338 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,13 @@
 OpenAFS News -- history of user-visible changes. October 19, 2001
 
+* Changes incorporated in OpenAFS 1.2.5
+
+** A remote denial of service attack in the AIX and IRIX clients has
+   been fixed.  Users of those platforms are strongly encouraged to
+   upgrade.
+
+** Fixed race conditions in fileserver that could result in crash.
+
 * Changes incorporated in OpenAFS 1.2.4
 
 ** Server logfiles now more consistant about format in which hosts are
index e72a8885f8259ebe8407d12081ec97ee56da42e3..66568869215800f6c9ade05cce56bc2a863384d1 100644 (file)
@@ -251,6 +251,9 @@ else
                powerpc-apple-darwin5.4*)
                        AFS_SYSNAME="ppc_darwin_14"
                        ;;
+               powerpc-apple-darwin5.5*)
+                       AFS_SYSNAME="ppc_darwin_14"
+                       ;;
                sparc-sun-solaris2.5*)
                        AFS_SYSNAME="sun4x_55"
                        ;;
index f64440e31572bed13136922bc71ed1ce16f45722..f707876575210a57539ff6d2b2c236a153e5c152 100644 (file)
@@ -1,5 +1,5 @@
 AC_INIT(Makefile.common)
-AM_INIT_AUTOMAKE(openafs-libafs,1.2.4)
+AM_INIT_AUTOMAKE(openafs-libafs,1.2.5)
 AC_CONFIG_HEADER(config/afsconfig.h)
 define(OPENAFS_CONFIGURE_LIBAFS)
 
index cc4b9af22438399610659b2882b818a21d2458c9..f19091435d698dd3e68da2dd7048cdc1e5ee2271 100644 (file)
@@ -21,7 +21,7 @@
 #include <afsconfig.h>
 #include "../afs/param.h"
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v 1.1.1.8 2002/05/10 23:44:19 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v 1.1.1.9 2002/06/10 11:40:12 hartmans Exp $");
 
 #include "../afs/sysincludes.h"        /* Standard vendor system headers */
 #include "../afs/afsincludes.h"        /* Afs-based standard headers */
@@ -93,7 +93,7 @@ afs_CopyOutAttrs(avc, attrs)
     attrs->va_nlink = avc->m.LinkCount;
     attrs->va_size = avc->m.Length;
     attrs->va_atime.tv_sec = attrs->va_mtime.tv_sec = attrs->va_ctime.tv_sec =
-       avc->m.Date;
+       (int)avc->m.Date;
     /* set microseconds to be dataversion # so that we approximate NFS-style
      * use of mtime as a dataversion #.  We take it mod 512K because
      * microseconds *must* be less than a million, and 512K is the biggest
index 29ad5b26764856eceb3d29324cd08321fbec3216..467083c5da17dcdf3e51498107621818b07b1230 100644 (file)
@@ -22,7 +22,7 @@
 #include <afsconfig.h>
 #include "../afs/param.h"
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.1.1.7 2002/05/10 23:44:24 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.1.1.8 2002/06/10 11:40:14 hartmans Exp $");
 
 #include "../afs/sysincludes.h"        /* Standard vendor system headers */
 #include "../afs/afsincludes.h"        /* Afs-based standard headers */
@@ -356,7 +356,7 @@ tagain:
        char *unlname = newname();
 
        ReleaseWriteLock(&adp->lock);
-       code = afsrename(adp, aname, adp, unlname, acred);
+       code = afsrename(adp, aname, adp, unlname, acred, &treq);
        Tnam1 = unlname;
        if (!code) {
            tvc->mvid = (struct VenusFid *)unlname;
index f33062b8f4841f87677b181fe8cf015cb3d7077a..6eb2d4e0d0ebad69c8f0a610eb53c4cdfaee4d23 100644 (file)
@@ -16,7 +16,7 @@
 #include <afsconfig.h>
 #include "../afs/param.h"
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_callback.c,v 1.1.1.8 2002/05/10 23:43:09 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_callback.c,v 1.1.1.9 2002/06/10 11:39:52 hartmans Exp $");
 
 #include "../afs/sysincludes.h" /*Standard vendor system headers*/
 #include "../afs/afsincludes.h" /*AFS-based standard headers*/
@@ -1125,7 +1125,7 @@ int SRXAFSCB_GetCellServDB(
     struct rx_call *a_call,
     afs_int32 a_index,
     char **a_name,
-    afs_int32 *a_hosts)
+    serverList *a_hosts)
 {
     afs_int32 i, j;
     struct cell *tcell;
@@ -1137,27 +1137,27 @@ int SRXAFSCB_GetCellServDB(
 #endif /* RX_ENABLE_LOCKS */
     AFS_STATCNT(SRXAFSCB_GetCellServDB);
 
-    memset(a_hosts, 0, AFSMAXCELLHOSTS * sizeof(afs_int32));
-
-    /* search the list for the cell with this index */
-    ObtainReadLock(&afs_xcell);
-
     tcell = afs_GetCellByIndex(a_index, READ_LOCK, 0);
 
     if (!tcell) {
       i = 0;
+      a_hosts->serverList_val = 0;
+      a_hosts->serverList_len = 0;
     } else {
       p_name = tcell->cellName;
-      for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++) {
-       a_hosts[j] = ntohl(tcell->cellHosts[j]->addr->sa_ip);
-      }
+      for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++)
+       ;
       i = strlen(p_name);
+      a_hosts->serverList_val = (afs_int32 *)afs_osi_Alloc(j*sizeof(afs_int32));
+      a_hosts->serverList_len = j;
+      for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++)
+       a_hosts->serverList_val[j] = ntohl(tcell->cellHosts[j]->addr->sa_ip);
       afs_PutCell(tcell, READ_LOCK);
     }
 
-    t_name = (char *)rxi_Alloc(i+1);
+    t_name = (char *)afs_osi_Alloc(i+1);
     if (t_name == NULL) {
-        ReleaseReadLock(&afs_xcell);
+      afs_osi_Free(a_hosts->serverList_val, (j*sizeof(afs_int32)));
 #ifdef RX_ENABLE_LOCKS
        AFS_GUNLOCK();
 #endif /* RX_ENABLE_LOCKS */
@@ -1168,8 +1168,6 @@ int SRXAFSCB_GetCellServDB(
     if (p_name)
        memcpy(t_name, p_name, i);
 
-    ReleaseReadLock(&afs_xcell);
-
 #ifdef RX_ENABLE_LOCKS
     AFS_GUNLOCK();
 #endif /* RX_ENABLE_LOCKS */
@@ -1234,7 +1232,7 @@ int SRXAFSCB_GetLocalCell(
        plen = strlen(p_name);
     else
        plen = 0;
-    t_name = (char *)rxi_Alloc(plen+1);
+    t_name = (char *)afs_osi_Alloc(plen+1);
     if (t_name == NULL) {
         ReleaseReadLock(&afs_xcell);
 #ifdef RX_ENABLE_LOCKS
@@ -1340,7 +1338,7 @@ int SRXAFSCB_GetCacheConfig(
      * Currently only support version 1
      */
     allocsize = sizeof(cm_initparams_v1);
-    t_config = (afs_uint32 *)rxi_Alloc(allocsize);
+    t_config = (afs_uint32 *)afs_osi_Alloc(allocsize);
     if (t_config == NULL) {
 #ifdef RX_ENABLE_LOCKS
        AFS_GUNLOCK();
index a5e80cabee3688591c097903219474c7ffe1d712..3c05d4fefe31dbe87006cbbe0518979b0da823a7 100644 (file)
@@ -13,7 +13,7 @@
 #include <afsconfig.h>
 #include "../afs/param.h"
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_segments.c,v 1.1.1.6 2002/01/22 19:48:00 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_segments.c,v 1.1.1.7 2002/06/10 11:39:56 hartmans Exp $");
 
 #include "../afs/sysincludes.h" /*Standard vendor system headers*/
 #include "../afs/afsincludes.h" /*AFS-based standard headers*/
@@ -284,6 +284,8 @@ afs_StoreAllSegments(avc, areq, sync)
       if (j) {
        static afs_uint32 lp1 = 10000, lp2 = 10000;
        struct AFSStoreStatus InStatus;
+       struct AFSFetchStatus OutStatus;
+       int doProcessFS = 0;
        afs_uint32 base, bytes, nchunks;
        int nomore;
        unsigned int first;
@@ -475,7 +477,6 @@ afs_StoreAllSegments(avc, areq, sync)
                      * one which has the writing bit turned on. */
                }
                if (!code) {
-                   struct AFSFetchStatus OutStatus;
                    struct AFSVolSync tsync;
 #ifdef RX_ENABLE_LOCKS
                    AFS_GUNLOCK();
@@ -486,19 +487,7 @@ afs_StoreAllSegments(avc, areq, sync)
 #endif /* RX_ENABLE_LOCKS */
                    hadd32(newDV, 1);
                    XSTATS_END_TIME;
-      
-                   /* Now copy out return params */
-                   UpgradeSToWLock(&avc->lock,28);    /* keep out others for a while */
-                   if (!code) {  /* must wait til RPC completes to be sure of this info */
-                       afs_ProcessFS(avc, &OutStatus, areq);
-                       /* Keep last (max) size of file on server to see if
-                        * we need to call afs_StoreMini to extend the file.
-                        */
-                       if (!moredata)
-                           maxStoredLength = OutStatus.Length;
-
-                   }
-                   ConvertWToSLock(&avc->lock);
+                   if (!code) doProcessFS = 1; /* Flag to run afs_ProcessFS() later on */                  
                }
                if (tcall) {
 #ifdef RX_ENABLE_LOCKS
@@ -538,6 +527,19 @@ afs_StoreAllSegments(avc, areq, sync)
                lockedPutDCache(tdc);
            }
 
+           if (doProcessFS) {
+               /* Now copy out return params */
+               UpgradeSToWLock(&avc->lock,28);    /* keep out others for a while */
+               afs_ProcessFS(avc, &OutStatus, areq);
+               /* Keep last (max) size of file on server to see if
+                * we need to call afs_StoreMini to extend the file.
+                */
+               if (!moredata)
+                   maxStoredLength = OutStatus.Length;
+               ConvertWToSLock(&avc->lock);
+               doProcessFS = 0;
+           }
+
            if (code) {
                for (j++; j<=high; j++)
                    if ( dcList[j] )
index 14c42fbd7eb97983cddce1657c63795ba4717a46..197f68dcce84f862c82a8fc9f749f3d1144cf9ba 100644 (file)
@@ -268,7 +268,7 @@ struct vfspage;                     /* for vnode.h compiler warnings */
 #endif /* AFS_SUN5_ENV */
 
 #include "../rpc/types.h"
-#include "../rpc/xdr.h"
+#include "../rx/xdr.h"
 
 #ifdef AFS_AIX32_ENV
 #  include "net/spl.h"
@@ -363,7 +363,7 @@ struct vfspage;                     /* for vnode.h compiler warnings */
 #undef register
 #endif /* AFS_ALPHA_ENV */
 
-#include <rpc/xdr.h>
+#include <rx/xdr.h>
 #include <sys/proc.h>
 #include <sys/ioctl.h>
 
index f644cbfc2edd1f01dffd10abe2a71dbd87059b74..247fe25c2a99d5b725cc0a60707052798c887058 100644 (file)
@@ -55,7 +55,7 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/afsd/afsd.c,v 1.1.1.12 2002/01/22 19:52:07 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/afsd/afsd.c,v 1.1.1.13 2002/06/10 11:44:53 hartmans Exp $");
 
 #define VFS 1
 
@@ -1290,7 +1290,11 @@ mainproc(as, arock)
         * Cold shutdown is the default
         */
        printf("afsd: Shutting down all afs processes and afs state\n");
-       call_syscall(AFSOP_SHUTDOWN, 1);
+       code = call_syscall(AFSOP_SHUTDOWN, 1);
+       if (code) {
+           printf("afsd: AFS still mounted; Not shutting down\n");
+           exit(1);
+       }
        exit(0);
     }
     if (as->parms[21].items) {
index aae13084876217214e1599bca08534ce14b129c9..a0fce595546870e9a62b9687278de88ad1bee8df 100644 (file)
@@ -37,7 +37,7 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/des/crypt.c,v 1.1.1.5 2001/09/11 14:32:29 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/des/crypt.c,v 1.1.1.6 2002/06/10 11:45:53 hartmans Exp $");
 
 #ifdef AFS_NT40_ENV
 #include <windows.h>
@@ -88,7 +88,7 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/des/crypt.c,v 1.1.1.5 2001/09/11 14:32:
  * define "LONG_IS_32_BITS" only if sizeof(long)==4.
  * This avoids use of bit fields (your compiler may be sloppy with them).
  */
-#if !defined(cray)
+#if !defined(cray) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
 #define        LONG_IS_32_BITS
 #endif
 
@@ -249,13 +249,8 @@ typedef union {
        struct {
 #if defined(LONG_IS_32_BITS)
                /* long is often faster than a 32-bit bit field */
-#if defined(AFS_IA64_LINUX20_ENV)
-               int     i0;
-               int     i1;
-#else
                long    i0;
                long    i1;
-#endif
 #else
                long    i0: 32;
                long    i1: 32;
index 1ad93832cd4e7d4b562695fd7757dffab25a909e..3198e4fd87480234bbd9ca84be055134fe3d4dc3 100644 (file)
@@ -10,7 +10,7 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/dir/buffer.c,v 1.1.1.8 2002/05/10 23:58:41 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/dir/buffer.c,v 1.1.1.9 2002/06/10 11:45:57 hartmans Exp $");
 
 #include <stdlib.h>
 #include <lock.h>
@@ -132,8 +132,8 @@ char *DRead(fid,page)
     if ( tb = phTable[pHash(fid)] ) {  /* ASSMT HERE */
        if (bufmatch(tb)) {
            ObtainWriteLock(&tb->lock);
-           ReleaseWriteLock(&afs_bufferLock);
            tb->lockers++;
+           ReleaseWriteLock(&afs_bufferLock);
            tb->accesstime = ++timecounter;
            ReleaseWriteLock(&tb->lock);
            return tb->data;
@@ -144,8 +144,8 @@ char *DRead(fid,page)
            if (bufmatch(tb2)) {
              buf_Front(bufhead,tb,tb2);
              ObtainWriteLock(&tb2->lock);
-             ReleaseWriteLock(&afs_bufferLock);
              tb2->lockers++;
+             ReleaseWriteLock(&afs_bufferLock);
              tb2->accesstime = ++timecounter;
              ReleaseWriteLock(&tb2->lock);
              return tb2->data;
@@ -154,8 +154,8 @@ char *DRead(fid,page)
              if (bufmatch(tb)) {
                buf_Front(bufhead,tb2,tb);
                ObtainWriteLock(&tb->lock);
-               ReleaseWriteLock(&afs_bufferLock);
                tb->lockers++;
+               ReleaseWriteLock(&afs_bufferLock);
                tb->accesstime = ++timecounter;
                ReleaseWriteLock(&tb->lock);
                return tb->data;
@@ -175,8 +175,8 @@ char *DRead(fid,page)
     tb = newslot(fid, page, (tb ? tb : tb2));
     ios++;
     ObtainWriteLock(&tb->lock);
-    ReleaseWriteLock(&afs_bufferLock);
     tb->lockers++;
+    ReleaseWriteLock(&afs_bufferLock);
     if (ReallyRead(tb->fid,tb->page,tb->data)) {
        tb->lockers--;
         FidZap(tb->fid);       /* disaster */
@@ -396,8 +396,8 @@ char *DNew (fid,page)
     ObtainWriteLock(&afs_bufferLock);
     tb = newslot(fid,page,0);
     ObtainWriteLock(&tb->lock);
-    ReleaseWriteLock(&afs_bufferLock);
     tb->lockers++;
+    ReleaseWriteLock(&afs_bufferLock);
     ReleaseWriteLock(&tb->lock);
     return tb->data;
 }
index 31c39a212e77f8684361d17e7d5d392f78753132..8a5f354f1e030472c0b03327a6a0cb2e30b63cee 100644 (file)
@@ -14,7 +14,7 @@
 #include <afs/param.h>
 #endif
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/fsint/afsaux.c,v 1.1.1.5 2001/07/14 22:21:55 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/fsint/afsaux.c,v 1.1.1.6 2002/06/10 11:45:59 hartmans Exp $");
 
 #ifdef KERNEL
 #if defined(UKERNEL)
@@ -28,7 +28,7 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/fsint/afsaux.c,v 1.1.1.5 2001/07/14 22:
 #else
 #include "../h/types.h"
 #include "../rpc/types.h"
-#include "../rpc/xdr.h"
+#include "../rx/xdr.h"
 #endif
 #if !defined(AFS_ALPHA_ENV)
 #ifndef        XDR_GETINT32
@@ -38,9 +38,6 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/fsint/afsaux.c,v 1.1.1.5 2001/07/14 22:
 #define        XDR_PUTINT32    XDR_PUTLONG
 #endif
 #endif
-#ifndef AFS_LINUX22_ENV
-#include "../rpc/auth.h"
-#endif
 #endif /* defined(UKERNEL) */
 #include "../afsint/afsint.h"
 #else /* KERNEL */
index 549b5badf8cdef840b242ad4356d0461bd876727..76fd54c4e602d0e03dd6f440973d765c9bf38683 100644 (file)
@@ -45,7 +45,7 @@ typedef afs_int32 ViceDataType;
 %#define SymbolicLink 3 
 
 %#ifdef        KERNEL
-%#define       xdr_array(a,b,c,d,e,f)  xdr_arrayN(a,b,c,d,e,f)
+%#define       afs_xdr_array(a,b,c,d,e,f)      afs_xdr_arrayN(a,b,c,d,e,f)
 %#endif
 
 struct BD {
index c658b6dfe2c3aa8a1db4faad22f87db745c51954..5215be4ab44068a3a2ee7703581a3315c8f44efc 100644 (file)
@@ -136,7 +136,7 @@ struct interfaceAddr {              /* for multihomed clients */
 };
 
 const AFSMAXCELLHOSTS = 8;     /*Max VLDB servers per cell*/
-typedef afs_int32 serverList[AFSMAXCELLHOSTS];
+typedef afs_int32 serverList<AFSMAXCELLHOSTS>;
 
 typedef afs_uint32 cacheConfig<>;
 
index 0d7c3ab4e8b48357cdd03ee14674a2d053d78bd2..21d2e702fe54778d2a9c08ca9b376f96a037c54b 100644 (file)
@@ -37,10 +37,7 @@ AFS_OS_OBJS = \
        osi_misc.o \
        osi_sleep.o \
        osi_timeout.o \
-       osi_vm.o \
-       xdr.o \
-       xdr_array.o \
-       xdr_int64.o
+       osi_vm.o
 
 AFSNOIAUTHOBJS = \
        afs_call.o \
@@ -157,14 +154,6 @@ dest_libafs: $(DEST_LIBAFS) $(DEST_LIBAFSIAUTH)
 
 # Object build rules:
 # Common objects
-xdr.o: $(RX)/xdr.c
-       $(CRULE1)
-xdr_int64.o: $(RX)/xdr_int64.c
-       $(CRULE1)
-
-xdr_array.o: $(RX)/xdr_array.c
-       $(CRULE1)
-
 osi_assem.o:   ${AFS}/osi_assem.s
        ${AS} -o osi_assem.o ${AFS}/osi_assem.s
 osi_config.o: $(AFS)/osi_config.c
index 9b4080876b35553d6374764f9dd203cb28d8ab48..45b4a87cb0782530d0240791e85ef4bae0b2a3af 100644 (file)
@@ -1,5 +1,5 @@
 #/* Copyright (C) 1995, 1989 Transarc Corporation - All rights reserved */
-# $Header: /tmp/cvstemp/openafs/src/libafs/MakefileProto.DARWIN.in,v 1.1.1.4 2001/10/14 18:05:40 hartmans Exp $
+# $Header: /tmp/cvstemp/openafs/src/libafs/MakefileProto.DARWIN.in,v 1.1.1.5 2002/06/10 11:46:33 hartmans Exp $
 # 
 # MakefileProto for Digital Unix systems
 #
@@ -34,10 +34,7 @@ AFS_OS_OBJS = \
        osi_sleep.o \
        osi_vm.o \
        osi_vnodeops.o \
-       osi_module.o \
-       xdr.o \
-       xdr_array.o \
-       xdr_int64.o
+       osi_module.o
 
 
 #AFS_OS_NFSOBJS = osi_vfsops_nfs.o
@@ -136,9 +133,3 @@ osi_vnodeops.o: $(AFS)/osi_vnodeops.c
        $(CRULE1)
 osi_module.o: $(AFS)/osi_module.c
        $(CRULE1)
-xdr.o: $(RX)/xdr.c
-       $(CRULE1)
-xdr_array.o: $(RX)/xdr_array.c
-       $(CRULE1)
-xdr_int64.o: $(RX)/xdr_int64.c
-       $(CRULE1)
index ef84b2263657274b421cd949d747d98dba1e8649..8f74f1a161957ec4bcc387cdc7c4cd670802e106 100644 (file)
@@ -30,8 +30,7 @@ AFS_OS_OBJS = \
        osi_misc.o \
        osi_sleep.o \
        osi_vm.o \
-       osi_vnodeops.o \
-       xdr_int64.o
+       osi_vnodeops.o
 
 AFS_OS_NFSOBJS = \
        osi_vfsops_nfs.o
@@ -148,5 +147,3 @@ osi_vm.o: $(AFS)/osi_vm.c
        $(CRULE1)
 osi_vnodeops.o: $(AFS)/osi_vnodeops.c
        $(CRULE1)
-xdr_int64.o: $(RX)/xdr_int64.c
-       $(CRULE1)
index ab50ceb3c97e64cc0b37211c1ddd5644e33112d7..6562701d6f30cfb60ae2ad3bcb618eb072064b75 100644 (file)
@@ -36,8 +36,7 @@ AFS_OS_OBJS = \
        osi_misc.o \
        osi_sleep.o \
        osi_vnodeops.o \
-       osi_vm.o \
-       xdr_int64.o
+       osi_vm.o
 
 AFS_OS_NFSOBJS = \
        osi_vfsops_nfs.o
@@ -196,8 +195,6 @@ osi_vm.o: $(AFS)/osi_vm.c
        $(CRULE1)
 osi_vnodeops.o: $(AFS)/osi_vnodeops.c
        $(CRULE1)
-xdr_int64.o: $(RX)/xdr_int64.c
-       $(CRULE1)
 
 # This is a list of header files compiled with the -g option. It allows
 # examination of AFS structures in a dump.
index 1d9c6b1a8d0cdd891b199a56525759cfe3f2ac55..a3709806c2c3e6e8af200ec64b3847c2128ac3aa 100644 (file)
@@ -37,8 +37,7 @@ AFS_OS_OBJS = \
        osi_misc.o \
        osi_sleep.o \
        osi_vm.o \
-       osi_vnodeops.o \
-       xdr_int64.o
+       osi_vnodeops.o
 
 AFS_OS_NFSOBJS = \
        osi_vfsops_nfs.o
@@ -506,5 +505,3 @@ osi_vm.o: $(AFS)/osi_vm.c
        $(CRULE1)
 osi_vnodeops.o: $(AFS)/osi_vnodeops.c
        $(CRULE1)
-xdr_int64.o: $(RX)/xdr_int64.c
-       $(CRULE1)
index 31e172c9e0e265ee71898d1a2a0bbeca797ae51e..157b4439d0bdcb99ee6537e3f06909262bbfb44a 100644 (file)
@@ -30,8 +30,7 @@ AFS_OS_OBJS = \
        osi_misc.o \
        osi_sleep.o \
        osi_vm.o \
-       osi_vnodeops.o \
-       xdr_int64.o
+       osi_vnodeops.o
 
 AFS_OS_NFSOBJS = \
        osi_vfsops_nfs.o
@@ -148,5 +147,3 @@ osi_vm.o: $(AFS)/osi_vm.c
        $(CRULE1)
 osi_vnodeops.o: $(AFS)/osi_vnodeops.c
        $(CRULE1)
-xdr_int64.o: $(RX)/xdr_int64.c
-       $(CRULE1)
index afc4dbb5951bb5a1c3ba2ef4acc682c601439134..fac745683dfd9248616a5d630870aca744293103 100644 (file)
@@ -34,8 +34,7 @@ AFS_OS_OBJS = \
        osi_file.o \
        osi_sleep.o \
        osi_vm.o \
-       osi_vnodeops.o \
-       xdr_int64.o
+       osi_vnodeops.o
 
 AFS_OS_NFSOBJS = \
        osi_vfsops_nfs.o
@@ -198,5 +197,3 @@ osi_vm.o: $(AFS)/osi_vm.c
        $(CRULE1)
 osi_vnodeops.o: $(AFS)/osi_vnodeops.c
        $(CRULE1)
-xdr_int64.o: $(RX)/xdr_int64.c
-       $(CRULE1)
index 13cf96757719b9b475402f88dbfee822c14aac6b..cc6e73d4e414cbfe9e426279f84c27f53cec0bd0 100644 (file)
@@ -14,7 +14,7 @@
 #include <afsconfig.h>
 #include "../afs/param.h"
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx_kcommon.c,v 1.1.1.11 2002/05/11 00:01:27 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx_kcommon.c,v 1.1.1.12 2002/06/10 11:47:11 hartmans Exp $");
 
 #include "../rx/rx_kcommon.h"
 
@@ -998,7 +998,22 @@ int rxk_ReadPacket(osi_socket so, struct rx_packet *p, int *host, int *port)
  */
 int rxk_ListenerPid; /* Used to signal process to wakeup at shutdown */
 
+#ifdef AFS_SUN5_ENV
+/*
+ * Run the listener as a kernel process.
+ */
+void rxk_Listener(void)
+{
+    extern id_t syscid;
+    void rxk_ListenerProc(void);
+    if (newproc(rxk_ListenerProc, syscid, 59))
+       osi_Panic("rxk_Listener: failed to fork listener process!\n");
+}
+
+void rxk_ListenerProc(void)
+#else /* AFS_SUN5_ENV */
 void rxk_Listener(void)
+#endif /* AFS_SUN5_ENV */
 {
     struct rx_packet *rxp = NULL;
     int code;
@@ -1013,9 +1028,9 @@ void rxk_Listener(void)
 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
     rxk_ListenerPid = current_proc()->p_pid;
 #endif
-#if defined(RX_ENABLE_LOCKS)
+#if defined(RX_ENABLE_LOCKS) && !defined(AFS_SUN5_ENV)
     AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+#endif /* RX_ENABLE_LOCKS && !AFS_SUN5_ENV */
 
     while (afs_termState != AFSOP_STOP_RXK_LISTENER) {
        if (rxp) {
@@ -1047,6 +1062,14 @@ void rxk_Listener(void)
 #if defined(AFS_LINUX22_ENV) || defined(AFS_SUN5_ENV)
     afs_osi_Wakeup(&rxk_ListenerPid);
 #endif
+#ifdef AFS_SUN5_ENV
+    AFS_GUNLOCK();
+#ifdef HAVE_P_COREFILE
+    if (!curproc->p_corefile)  /* newproc doesn't set it, but exit frees it */
+       curproc->p_corefile = refstr_alloc("core");
+#endif
+    exit(CLD_EXITED, 0);
+#endif /* AFS_SUN5_ENV */
 }
 
 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
index 92b2bc33265d8ba97a6f6d84b6d7b075b6992a64..23d48adf1b85e0b76e64db3637a8539cf6ab0bfd 100644 (file)
@@ -90,9 +90,7 @@ struct coda_inode_info {};
 #include "../afs/afs_osi.h"
 #include "../rx/rx_kmutex.h"
 #include "../afs/lock.h"
-#ifndef AFS_LINUX22_ENV
-#include "../rpc/xdr.h"
-#endif
+#include "../rx/xdr.h"
 #include "../rx/rx.h"
 #include "../rx/rx_globals.h"
 #include "../afs/longc_procs.h"
index c74a8f0f72fb92918d0145529595f0aec539332d..68697450981e0079acf54bcbf1e1058cf5fea84e 100644 (file)
 void *afs_osi_Alloc();
 #define        osi_alloc               afs_osi_Alloc
 #define        osi_free                afs_osi_Free
+
+#ifndef UKERNEL
+#define xdr_void afs_xdr_void
+#define xdr_int afs_xdr_int
+#define xdr_u_int afs_xdr_u_int
+#define xdr_short afs_xdr_short
+#define xdr_u_short afs_xdr_u_short
+#define xdr_long afs_xdr_long
+#define xdr_u_long afs_xdr_u_long
+#define xdr_char afs_xdr_char
+#define xdr_u_char afs_xdr_u_char
+#define xdr_bool afs_xdr_bool
+#define xdr_enum afs_xdr_enum
+#define xdr_array afs_xdr_array
+#define xdr_arrayN afs_xdr_arrayN
+#define xdr_bytes afs_xdr_bytes
+#define xdr_opaque afs_xdr_opaque
+#define xdr_string afs_xdr_string
+#define xdr_union afs_xdr_union
+#define xdr_float afs_xdr_float
+#define xdr_double afs_xdr_double
+#define xdr_reference afs_xdr_reference
+#define xdr_wrapstring afs_xdr_wrapstring
+#define xdr_vector afs_xdr_vector
+#define xdr_int64 afs_xdr_int64
+#define xdr_uint64 afs_xdr_uint64
+#endif
 #endif
 #ifndef major          /* ouch! */
 #include <sys/types.h>
index 8c640e72511048cfd5b819c0f40fcba1a1280087..56682216dff6163250539cfa09baa091b2e5fa60 100644 (file)
@@ -18,7 +18,7 @@
 #endif
 #include <afsconfig.h>
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/rx/xdr_rx.c,v 1.1.1.4 2001/07/11 03:10:58 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/rx/xdr_rx.c,v 1.1.1.5 2002/06/10 11:47:16 hartmans Exp $");
 
 #ifdef KERNEL
 #ifndef UKERNEL
@@ -45,7 +45,7 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/rx/xdr_rx.c,v 1.1.1.4 2001/07/11 03:10:
 #define u_quad_t __u_quad_t
 #endif
 #endif
-#include "../rpc/xdr.h"
+#include "../rx/xdr.h"
 #include "../netinet/in.h"
 #else /* !UKERNEL */
 #include "../afs/sysincludes.h"
index 04ffaf4ed43d36e12fd1423f9a98d60af8f44940..d88b03581fec0621af75b732f10206f958d332e3 100644 (file)
@@ -36,7 +36,7 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/rxgen/rpc_main.c,v 1.1.1.9 2001/10/14 18:06:33 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/rxgen/rpc_main.c,v 1.1.1.10 2002/06/10 11:47:26 hartmans Exp $");
 
 #include <limits.h>
 #include <stdio.h>
@@ -436,14 +436,7 @@ c_output(infile, define, extend, outfile, append)
            f_print(fout, "#include \"../h/stat.h\"\n");
            f_print(fout, "#include \"../netinet/in.h\"\n");
            f_print(fout, "#include \"../h/time.h\"\n");
-           f_print(fout, "#ifndef AFS_LINUX22_ENV\n");
-           f_print(fout, "#include \"../rpc/types.h\"\n");
-           f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
-           f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
            f_print(fout, "#include \"../rx/xdr.h\"\n");
-           f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
-           f_print(fout, "#include \"../rpc/xdr.h\"\n");
-           f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
            f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
        } else {
            f_print(fout, "#include <rx/xdr.h>\n");
@@ -570,13 +563,7 @@ h_output(infile, define, extend, outfile, append)
        f_print(fout, "#define u_quad_t __u_quad_t\n");
        f_print(fout, "#endif\n");
        f_print(fout, "#endif\n");
-       f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
        f_print(fout, "#include \"../rx/xdr.h\"\n");
-       f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
-       f_print(fout, "extern bool_t xdr_int64();\n");
-       f_print(fout, "extern bool_t xdr_uint64();\n");
-       f_print(fout, "#include \"../rpc/xdr.h\"\n");
-       f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
        f_print(fout, "#endif /* XDR_GETLONG */\n");
        f_print(fout, "#endif   /* UKERNEL */\n");
        f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
@@ -752,11 +739,7 @@ int append;
            f_print(fout, "#include \"../netinet/in.h\"\n");
            f_print(fout, "#include \"../h/time.h\"\n");
            f_print(fout, "#include \"../rpc/types.h\"\n");
-           f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
            f_print(fout, "#include \"../rx/xdr.h\"\n");
-           f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
-           f_print(fout, "#include \"../rpc/xdr.h\"\n");
-           f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
            f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
            f_print(fout, "#include \"../afs/afs_osi.h\"\n");
            f_print(fout, "#include \"../rx/rx.h\"\n");
@@ -827,11 +810,7 @@ int append;
            f_print(fout, "#include \"../netinet/in.h\"\n");
            f_print(fout, "#include \"../h/time.h\"\n");
            f_print(fout, "#include \"../rpc/types.h\"\n");
-           f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
            f_print(fout, "#include \"../rx/xdr.h\"\n");
-           f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
-           f_print(fout, "#include \"../rpc/xdr.h\"\n");
-           f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
            f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
            f_print(fout, "#include \"../afs/afs_osi.h\"\n");
            f_print(fout, "#include \"../rx/rx.h\"\n");
index 6cb76f7fae79aec1a72b2fd54a13d7d724584838..23a926a6d33c41da72d5681f02e07d120859dca2 100644 (file)
@@ -18,7 +18,7 @@
 #include <afs/param.h>
 #endif
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/rxkad_client.c,v 1.1.1.7 2001/10/14 18:06:35 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/rxkad_client.c,v 1.1.1.8 2002/06/10 11:47:28 hartmans Exp $");
 
 #ifdef KERNEL
 #include "../afs/stds.h"
@@ -34,7 +34,7 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/rxkad_client.c,v 1.1.1.7 2001/10/
 #endif /* !UKERNEL */
 #ifndef AFS_LINUX22_ENV
 #include "../rpc/types.h"
-#include "../rpc/xdr.h"
+#include "../rx/xdr.h"
 #endif
 #include "../rx/rx.h"
 #else /* ! KERNEL */
index 7261e0af72d1ae0218e24964d51390b628373dd8..e5cb6884ebbf60f0ecfd17d760d61a9373d28b3d 100644 (file)
@@ -16,7 +16,7 @@
 #include <afs/param.h>
 #endif
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/rxkad_common.c,v 1.1.1.8 2002/05/11 00:01:51 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/rxkad_common.c,v 1.1.1.9 2002/06/10 11:47:28 hartmans Exp $");
 
 #ifdef KERNEL
 #ifndef UKERNEL
@@ -29,7 +29,7 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/rxkad_common.c,v 1.1.1.8 2002/05/
 #include "../h/time.h"
 #ifndef AFS_LINUX22_ENV
 #include "../rpc/types.h"
-#include "../rpc/xdr.h"
+#include "../rx/xdr.h"
 #endif /* AFS_LINUX22_ENV */
 #else /* !UKERNEL */
 #include "../afs/sysincludes.h"
index 174691f291e604be64443f8c8d3269411b8ef5e2..7d95c7a81218261011babd39324b482d3846c9a7 100644 (file)
@@ -29,7 +29,7 @@ INCFILES =\
 $(DESTDIR)\include\afs\dirent.h: dirent_nt.h
        $(COPY) $** $@
 
-$(DESTDIR)\include\afs\dirpath.h: dirpath.hin
+$(DESTDIR)\include\afs\dirpath.h: dirpath_nt.h
        $(COPY) $** $@
 
 LIBFILE = $(DESTDIR)\lib\afs\afsutil.lib
index d6f97e89559617ff0c34968c5b3cd23dc3afb4f7..6133ae29b93bd77f85c8ed863382e2f811da90cd 100644 (file)
@@ -10,7 +10,7 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/viced/host.c,v 1.1.1.9 2002/05/11 00:03:28 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/viced/host.c,v 1.1.1.10 2002/06/10 11:48:32 hartmans Exp $");
 
 #include <stdio.h>
 #include <errno.h>
@@ -534,12 +534,15 @@ void h_flushhostcps(hostaddr, hport)
     register afs_uint32  hostaddr, hport;  /* net byte order */
 {
     register struct host *host;
+    int held;
     
     H_LOCK
-    host = h_Lookup_r(hostaddr, hport);
+    host = h_Lookup_r(hostaddr, hport, &held);
     if (host) {
       host->hcpsfailed = 1;
     }
+    if (!held)
+      h_Release_r(host);
     H_UNLOCK
 
 return;
@@ -635,18 +638,21 @@ struct host *h_Alloc_r(r_con)
 
 
 /* Lookup a host given an IP address and UDP port number. */
-struct host *h_Lookup(hostaddr, hport)
+struct host *h_Lookup(hostaddr, hport, heldp)
     afs_uint32 hostaddr, hport;     /* network byte order */
+    int *heldp;
 {
     struct host *retVal;
     H_LOCK
-    retVal = h_Lookup_r(hostaddr, hport);
+    retVal = h_Lookup_r(hostaddr, hport, heldp);
     H_UNLOCK
     return retVal;
 }
 
-struct host *h_Lookup_r(hostaddr, hport)
+/* Note: host should be released by caller if 0 == *heldp and non-null */
+struct host *h_Lookup_r(hostaddr, hport, heldp)
     afs_uint32 hostaddr, hport;     /* network byte order */
+    int *heldp;
 {
     register afs_int32 now;
     register struct host *host=0;
@@ -654,17 +660,30 @@ struct host *h_Lookup_r(hostaddr, hport)
     register index = h_HashIndex(hostaddr);
     extern int hostaclRefresh;
 
+restart:
     for (chain=hostHashTable[index]; chain; chain=chain->next) {
        host = chain->hostPtr;
        assert(host);
         if (!(host->hostFlags & HOSTDELETED) && chain->addr == hostaddr
            && host->port == hport) {
+           *heldp = h_Held_r(host);
+           if (!*heldp)
+               h_Hold_r(host);
+           h_Lock_r(host);
+           if (host->hostFlags & HOSTDELETED) {
+               h_Unlock_r(host);
+               if (!*heldp)
+                   h_Release_r(host);
+               goto restart;
+           }
+           h_Unlock_r(host);
             now = FT_ApproxTime();             /* always evaluate "now" */
            if (host->hcpsfailed || (host->cpsCall+hostaclRefresh < now )) {
                /*
-                * Every hostaclRefresh period (def 2 hrs) get the new membership list for the host.
-                * Note this could be the first time that the host is added to a group.
-                * Also here we also retry on previous legitimate hcps failures
+                * Every hostaclRefresh period (def 2 hrs) get the new
+                * membership list for the host.  Note this could be the
+                * first time that the host is added to a group.  Also
+                * here we also retry on previous legitimate hcps failures.
                 */
                h_gethostcps_r(host,now);
            }
@@ -947,14 +966,12 @@ struct host *h_GetHost_r(tcon)
 retry:
     code = 0;
     identP = (struct Identity *)rx_GetSpecific(tcon, rxcon_ident_key);
-    host = h_Lookup_r(haddr, hport);
+    host = h_Lookup_r(haddr, hport, &held);
     if (host && !identP && !(host->Console&1)) {
        /* This is a new connection, and we already have a host
         * structure for this address. Verify that the identity
         * of the caller matches the identity in the host structure.
         */
-       if (!(held = h_Held_r(host)))
-               h_Hold_r(host);
        h_Lock_r(host);
        if ( !(host->hostFlags & ALTADDR) )
        {
@@ -970,7 +987,7 @@ retry:
        code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf);
        H_LOCK
        if ( code == RXGEN_OPCODE ) {
-               identP = (struct Identity *)malloc(1);
+               identP = (struct Identity *)malloc(sizeof(struct Identity));
                identP->valid = 0;
                rx_SetSpecific(tcon, rxcon_ident_key, identP);
                /* The host on this connection was unable to respond to 
@@ -1016,8 +1033,6 @@ retry:
        host->hostFlags |= ALTADDR;
        h_Unlock_r(host);
     } else if (host) {
-       if (!(held = h_Held_r(host)))
-               h_Hold_r(host);
        if ( ! (host->hostFlags & ALTADDR) ) 
        {
                /* another thread is doing the initialisation */
@@ -1057,7 +1072,7 @@ retry:
                code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf);
                H_LOCK
                if ( code == RXGEN_OPCODE ) {
-                   identP = (struct Identity *)malloc(1);
+                 identP = (struct Identity *)malloc(sizeof(struct Identity));
                    identP->valid = 0;
                    rx_SetSpecific(tcon, rxcon_ident_key, identP);
                    ViceLog(25,
index 6b54cfbe607c556a7c3e7713e0eb2fd57e4f206e..9c175a57b1e7841c6ce7b46753fa930c5697aab1 100644 (file)
@@ -15,7 +15,7 @@ statindex 15
 %#include      "vl_opcodes.h"  /* directly to other places */
 
 %#ifdef KERNEL
-%#define       xdr_array(a,b,c,d,e,f)  xdr_arrayN(a,b,c,d,e,f)
+%#define       afs_xdr_array(a,b,c,d,e,f)      afs_xdr_arrayN(a,b,c,d,e,f)
 %#include "../afs/longc_procs.h"
 %#endif
 
index 69733637f59aab6bd4c462fcbdc0ad61c6516296..a7a8b6f078e41e7e367f2eeb24fb9919253cb8ff 100644 (file)
@@ -14,7 +14,7 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID("$Header: /tmp/cvstemp/openafs/src/vol/ihandle.c,v 1.1.1.6 2002/05/11 00:03:40 hartmans Exp $");
+RCSID("$Header: /tmp/cvstemp/openafs/src/vol/ihandle.c,v 1.1.1.7 2002/06/10 11:48:24 hartmans Exp $");
 
 #include <stdio.h>
 #include <sys/types.h>
@@ -259,10 +259,6 @@ FdHandle_t *ih_open(IHandle_t *ihP)
 
     IH_LOCK
 
-    if (!ih_Inited) {
-       ih_Initialize();
-    }
-
     /* Do we already have an open file handle for this Inode? */
     for (fdP = ihP->ih_fdtail ; fdP != NULL ; fdP = fdP->fd_ihprev) {
        if (fdP->fd_status != FD_HANDLE_INUSE) {
@@ -298,7 +294,7 @@ FdHandle_t *ih_open(IHandle_t *ihP)
        assert(fdP->fd_status == FD_HANDLE_OPEN);
        DLL_DELETE(fdP, fdLruHead, fdLruTail, fd_next, fd_prev);
        DLL_DELETE(fdP, fdP->fd_ih->ih_fdhead, fdP->fd_ih->ih_fdtail,
-                  fd_ihnext, fd_ihprev);
+            fd_ihnext, fd_ihprev);
        closeFd = fdP->fd_fd;
     } else {
        if (fdAvailHead == NULL) {
@@ -313,6 +309,9 @@ FdHandle_t *ih_open(IHandle_t *ihP)
     fdP->fd_status = FD_HANDLE_INUSE;
     fdP->fd_fd = fd;
     fdP->fd_ih = ihP;
+
+    ihP->ih_refcnt++;
+
     /* Add this handle to the Inode's list of open descriptors */
     DLL_INSERT_TAIL(fdP, ihP->ih_fdhead, ihP->ih_fdtail, fd_ihnext, fd_ihprev);
 
@@ -323,7 +322,6 @@ FdHandle_t *ih_open(IHandle_t *ihP)
        fdInUseCount -= 1;
     }
 
-    ihP->ih_refcnt++;
     IH_UNLOCK
     return fdP;
 }
@@ -340,41 +338,21 @@ int fd_close(FdHandle_t *fdP)
        return 0;
 
     IH_LOCK
+
     assert(ih_Inited);
     assert(fdInUseCount > 0);
     assert(fdP->fd_status == FD_HANDLE_INUSE);
 
     ihP = fdP->fd_ih;
 
-    /* If a previous attempt to close  ( ih_reallyclose() )
-     * all fd handles failed, then the IH_REALLY_CLOSED flag is set in
-     * the Inode handle so we call fd_reallyclose
+    /* Call fd_reallyclose to really close the unused file handles if
+     * the previous attempt to close (ih_reallyclose()) all file handles
+     * failed (this is determined by checking the ihandle for the flag
+     * IH_REALLY_CLOSED) or we have too many open files.
      */
-
-    if ( ihP->ih_flags & IH_REALLY_CLOSED ) {
-       IH_UNLOCK
-       return (fd_reallyclose(fdP));
-    }
-
-    /* If we have too many open files then close the descriptor. If we
-     * hold the last reference to the Inode handle then wait and let
-     * ih_release do the work.  */
-    if (fdInUseCount > fdCacheSize && ihP->ih_refcnt > 1) {
-       assert(fdInUseCount > 0);
-       closeFd = fdP->fd_fd;
-       DLL_DELETE(fdP, fdP->fd_ih->ih_fdhead, fdP->fd_ih->ih_fdtail,
-                  fd_ihnext, fd_ihprev);
-       DLL_INSERT_TAIL(fdP, fdAvailHead, fdAvailTail, fd_next, fd_prev);
-       fdP->fd_status = FD_HANDLE_AVAIL;
-       fdP->fd_ih = NULL;
-       fdP->fd_fd = INVALID_FD;
-       ihP->ih_refcnt--;
+    if (ihP->ih_flags & IH_REALLY_CLOSED || fdInUseCount > fdCacheSize) {
        IH_UNLOCK
-       OS_CLOSE(closeFd);
-       IH_LOCK
-       fdInUseCount -= 1;
-       IH_UNLOCK
-       return 0;
+       return fd_reallyclose(fdP);
     }
 
     /* Put this descriptor back into the cache */
@@ -382,7 +360,8 @@ int fd_close(FdHandle_t *fdP)
     DLL_INSERT_TAIL(fdP, fdLruHead, fdLruTail, fd_next, fd_prev);
 
     /* If this is not the only reference to the Inode then we can decrement
-     * the reference count, otherwise we need to call ih_release. */
+     * the reference count, otherwise we need to call ih_release.
+     */
     if (ihP->ih_refcnt > 1) {
        ihP->ih_refcnt--;
        IH_UNLOCK
@@ -395,7 +374,8 @@ int fd_close(FdHandle_t *fdP)
 }
 
 /*
- * Return a file descriptor handle to the cache
+ * Actually close the file descriptor handle and return it to
+ * the free list.
  */
 int fd_reallyclose(FdHandle_t *fdP)
 {
@@ -406,6 +386,7 @@ int fd_reallyclose(FdHandle_t *fdP)
        return 0;
 
     IH_LOCK
+
     assert(ih_Inited);
     assert(fdInUseCount > 0);
     assert(fdP->fd_status == FD_HANDLE_INUSE);
@@ -413,15 +394,25 @@ int fd_reallyclose(FdHandle_t *fdP)
     ihP = fdP->fd_ih;
     closeFd = fdP->fd_fd;
 
-    DLL_DELETE(fdP, fdP->fd_ih->ih_fdhead, fdP->fd_ih->ih_fdtail,
-              fd_ihnext, fd_ihprev);
+    DLL_DELETE(fdP, ihP->ih_fdhead, ihP->ih_fdtail, fd_ihnext, fd_ihprev);
     DLL_INSERT_TAIL(fdP, fdAvailHead, fdAvailTail, fd_next, fd_prev);
+
     fdP->fd_status = FD_HANDLE_AVAIL;
     fdP->fd_ih = NULL;
     fdP->fd_fd = INVALID_FD;
+
+    /* All the file descriptor handles have been closed; reset
+     * the IH_REALLY_CLOSED flag indicating that ih_reallyclose
+     * has completed its job.
+     */
+    if (!ihP->ih_fdhead) {
+        ihP->ih_flags &= ~IH_REALLY_CLOSED;
+    }
+
     IH_UNLOCK
     OS_CLOSE(closeFd);
     IH_LOCK
+
     fdInUseCount -= 1;
 
     /* If this is not the only reference to the Inode then we can decrement
@@ -433,6 +424,7 @@ int fd_reallyclose(FdHandle_t *fdP)
        IH_UNLOCK
        ih_release(ihP);
     }
+
     return 0;
 }
 
@@ -658,163 +650,136 @@ int stream_close(StreamHandle_t *streamP, int reallyClose)
     return retval;
 }
 
-/* Close all cached file descriptors for this inode. */
-int ih_reallyclose(IHandle_t *ihP)
+/* Close all unused file descriptors associated with the inode
+ * handle. Called with IH_LOCK held. May drop and reacquire
+ * IH_LOCK. Sets the IH_REALLY_CLOSED flag in the inode handle
+ * if it fails to close all file handles.
+ */
+static int ih_fdclose(IHandle_t *ihP)
 {
-    int closeCount;
-    FdHandle_t *fdP;
-    FdHandle_t *head, *tail;
-
-    if (!ihP)
-       return 0;
-
-    IH_LOCK
+    int closeCount, closedAll;
+    FdHandle_t *fdP, *head, *tail, *next;
 
     assert(ihP->ih_refcnt > 0);
 
+    closedAll = 1;
+    DLL_INIT_LIST(head, tail);
+    ihP->ih_flags &= ~IH_REALLY_CLOSED;
+
     /*
      * Remove the file descriptors for this Inode from the LRU queue
-     * and put them on a temporary queue so we drop the lock before
-     * we close the files.
+     * and the IHandle queue and put them on a temporary queue so we
+     * can drop the lock before we close the files.
      */
-    DLL_INIT_LIST(head, tail);
-    for (fdP = ihP->ih_fdhead ; fdP != NULL ; fdP = fdP->fd_ihnext) {
-       if (fdP->fd_status == FD_HANDLE_OPEN) {
-           assert(fdP->fd_ih == ihP);
-           DLL_DELETE(fdP, fdLruHead, fdLruTail, fd_next, fd_prev);
-           DLL_INSERT_TAIL(fdP, head, tail, fd_next, fd_prev);
-       } else {
-           ihP->ih_flags |= IH_REALLY_CLOSED;
-       }
-    }
-    
-    /*
-     * If we found any file descriptors in use, then we dont zero out
-     * fdhead and fdtail, since ih_reallyclose() will be called again on this
-     * Inode handle
+    for (fdP = ihP->ih_fdhead; fdP != NULL; fdP = next) {
+        next = fdP->fd_ihnext;
+        assert(fdP->fd_ih == ihP);
+        assert(fdP->fd_status == FD_HANDLE_OPEN ||
+               fdP->fd_status == FD_HANDLE_INUSE);
+        if (fdP->fd_status == FD_HANDLE_OPEN) {
+            DLL_DELETE(fdP, ihP->ih_fdhead, ihP->ih_fdtail,
+                fd_ihnext, fd_ihprev);
+            DLL_DELETE(fdP, fdLruHead, fdLruTail, fd_next, fd_prev);
+            DLL_INSERT_TAIL(fdP, head, tail, fd_next, fd_prev);
+        } else {
+            closedAll = 0;
+            ihP->ih_flags |= IH_REALLY_CLOSED;
+        }
+    }
+
+    /* If the ihandle reference count is 1, we should have
+     * closed all file descriptors.
      */
-
-    if ( ! (ihP->ih_flags & IH_REALLY_CLOSED) )
-       DLL_INIT_LIST(ihP->ih_fdhead, ihP->ih_fdtail);
+    if (ihP->ih_refcnt == 1 || closedAll) {
+        assert(closedAll);
+        assert(!ihP->ih_fdhead);
+        assert(!ihP->ih_fdtail);
+    }
 
     if (head == NULL) {
-       IH_UNLOCK
-       return 0;
+        return 0;       /* No file descriptors closed */
     }
 
+    IH_UNLOCK
+
     /*
      * Close the file descriptors
      */
     closeCount = 0;
-    for (fdP = head ; fdP != NULL ; fdP = fdP->fd_ihnext) {
-       IH_UNLOCK
-       OS_CLOSE(fdP->fd_fd);
-       IH_LOCK
-       assert(fdInUseCount > 0);
-       fdInUseCount -= 1;
-       fdP->fd_status = FD_HANDLE_AVAIL;
-       fdP->fd_fd = INVALID_FD;
-       fdP->fd_ih = NULL;
-       closeCount++;
+    for (fdP = head; fdP != NULL; fdP = fdP->fd_next) {
+        OS_CLOSE(fdP->fd_fd);
+        fdP->fd_status = FD_HANDLE_AVAIL;
+        fdP->fd_fd = INVALID_FD;
+        fdP->fd_ih = NULL;
+        closeCount++;
     }
 
+    IH_LOCK
+
+    assert(fdInUseCount >= closeCount);
+    fdInUseCount -= closeCount;
+
     /*
      * Append the temporary queue to the list of available descriptors
      */
     if (fdAvailHead == NULL) {
-       fdAvailHead = head;
-       fdAvailTail = tail;
+        fdAvailHead = head;
+        fdAvailTail = tail;
     } else {
-       fdAvailTail->fd_next = head;
-       head->fd_prev = fdAvailTail;
-       fdAvailTail = tail;
+        fdAvailTail->fd_next = head;
+        head->fd_prev = fdAvailTail;
+        fdAvailTail = tail;
     }
+
+    return 0;
+}
+
+/* Close all cached file descriptors for this inode. */
+int ih_reallyclose(IHandle_t *ihP)
+{
+    if (!ihP)
+        return 0;
+
+    IH_LOCK
+
+    assert(ihP->ih_refcnt > 0);
+    ih_fdclose(ihP);
+
     IH_UNLOCK
 
     return 0;
 }
 
 /* Release an Inode handle. All cached file descriptors for this
- * inode are closed when the last reference to this handle is released */
+ * inode are closed when the last reference to this handle is released
+ */
 int ih_release(IHandle_t *ihP)
 {
-    int closeCount;
-    FdHandle_t *fdP;
-    FdHandle_t *head, *tail;
     int ihash;
 
     if (!ihP)
-       return 0;
+        return 0;
 
     IH_LOCK
 
-    /**
-      * If the IH_REALLY_CLOSED flag is set then clear it here before adding
-      * the Inode handle to the available queue
-      */
-    if ( ihP->ih_flags & IH_REALLY_CLOSED )
-       ihP->ih_flags &= ~IH_REALLY_CLOSED;
+    assert(ihP->ih_refcnt > 0);
 
-    ihP->ih_refcnt--;
-    if (ihP->ih_refcnt > 0) {
-       IH_UNLOCK
-       return 0;
+    if (ihP->ih_refcnt > 1) {
+        ihP->ih_refcnt--;
+        IH_UNLOCK
+        return 0;
     }
 
-    assert(ihP->ih_refcnt == 0);
-
     ihash = IH_HASH(ihP->ih_dev, ihP->ih_vid, ihP->ih_ino);
     DLL_DELETE(ihP, ihashTable[ihash].ihash_head,
-              ihashTable[ihash].ihash_tail, ih_next, ih_prev);
-
-    /*
-     * Remove the file descriptors for this Inode from the LRU queue
-     * and put them on a temporary queue so we drop the lock before
-     * we close the files.
-     */
-    DLL_INIT_LIST(head, tail);
-    for (fdP = ihP->ih_fdhead ; fdP != NULL ; fdP = fdP->fd_ihnext) {
-       assert(fdP->fd_status == FD_HANDLE_OPEN);
-       assert(fdP->fd_ih == ihP);
-       DLL_DELETE(fdP, fdLruHead, fdLruTail, fd_next, fd_prev);
-       DLL_INSERT_TAIL(fdP, head, tail, fd_next, fd_prev);
-    }
-    DLL_INIT_LIST(ihP->ih_fdhead, ihP->ih_fdtail);
+        ihashTable[ihash].ihash_tail, ih_next, ih_prev);
 
-    if (head == NULL) {
-       DLL_INSERT_TAIL(ihP, ihAvailHead, ihAvailTail, ih_next, ih_prev);
-       IH_UNLOCK
-       return 0;
-    }
+    ih_fdclose(ihP);
 
-    /*
-     * Close the file descriptors
-     */
-    closeCount = 0;
-    for (fdP = head ; fdP != NULL ; fdP = fdP->fd_ihnext) {
-       IH_UNLOCK
-       OS_CLOSE(fdP->fd_fd);
-       IH_LOCK
-       assert(fdInUseCount > 0);
-       fdInUseCount -= 1;
-       fdP->fd_status = FD_HANDLE_AVAIL;
-       fdP->fd_fd = INVALID_FD;
-       fdP->fd_ih = NULL;
-       closeCount++;
-    }
+    ihP->ih_refcnt--;
 
-    /*
-     * Append the temporary queue to the list of available descriptors
-     */
-    if (fdAvailHead == NULL) {
-       fdAvailHead = head;
-       fdAvailTail = tail;
-    } else {
-       fdAvailTail->fd_next = head;
-       head->fd_prev = fdAvailTail;
-       fdAvailTail = tail;
-    }
     DLL_INSERT_TAIL(ihP, ihAvailHead, ihAvailTail, ih_next, ih_prev);
+
     IH_UNLOCK
 
     return 0;