fdP[i].fd_fd = INVALID_FD;
fdP[i].fd_ihnext = NULL;
fdP[i].fd_ihprev = NULL;
+ fdP[i].fd_needs_rclose = 0;
DLL_INSERT_TAIL(&fdP[i], fdAvailHead, fdAvailTail, fd_next, fd_prev);
}
}
fdP->fd_status = FD_HANDLE_AVAIL;
fdP->fd_ih = NULL;
fdP->fd_fd = INVALID_FD;
+ fdP->fd_needs_rclose = 0;
IH_UNLOCK;
OS_CLOSE(closeFd);
goto ih_open_retry;
fdP->fd_status = FD_HANDLE_INUSE;
fdP->fd_fd = fd;
fdP->fd_ih = ihP;
+ fdP->fd_needs_rclose = 0;
fdP->fd_refcnt++;
ihP->ih_refcnt++;
* 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 || fdInUseCount > fdCacheSize) {
+ if (ihP->ih_flags & IH_REALLY_CLOSED || fdInUseCount > fdCacheSize ||
+ fdP->fd_needs_rclose) {
+
IH_UNLOCK;
return fd_reallyclose(fdP);
}
fdP->fd_refcnt = 0;
fdP->fd_ih = NULL;
fdP->fd_fd = INVALID_FD;
+ fdP->fd_needs_rclose = 0;
+ } else {
+ fdP->fd_needs_rclose = 1;
}
/* All the file descriptor handles have been closed; reset
fdP->fd_refcnt = 0;
fdP->fd_fd = INVALID_FD;
fdP->fd_ih = NULL;
+ fdP->fd_needs_rclose = 0;
closeCount++;
}
typedef struct FdHandle_s {
int fd_status; /* status flags */
int fd_refcnt; /* refcnt */
+ int fd_needs_rclose; /* do we need to fd_reallyclose? */
FD_t fd_fd; /* file descriptor */
struct IHandle_s *fd_ih; /* Pointer to Inode handle */
struct FdHandle_s *fd_next; /* LRU/Avail list pointers */