-/* $Id: disk.cc,v 1.10 1996/04/15 22:51:38 wessels Exp $ */
+/* $Id: disk.cc,v 1.11 1996/04/17 17:15:23 wessels Exp $ */
/* DEBUG: Section 6 disk: disk I/O routines */
/* table for FILE variable, write lock and queue. Indexed by fd. */
FileEntry *file_table;
-static int disk_initialized = 0;
extern int getMaxFD();
extern void fatal_dump _PARAMS((char *));
{
int fd, max_fd = getMaxFD();
- if (disk_initialized)
- return 0;
-
file_table = (FileEntry *) xmalloc(sizeof(FileEntry) * max_fd);
memset(file_table, '\0', sizeof(FileEntry) * max_fd);
file_table[fd].write_pending = NO_WRT_PENDING;
file_table[fd].write_q = file_table[fd].write_q_tail = NULL;
}
- disk_initialized = 1;
return 0;
}
FD_ENTRY *conn;
int fd;
- /* lazy initialization */
- if (!disk_initialized)
- disk_init();
-
/* Open file */
if ((fd = open(path, mode | O_NDELAY, 0644)) < 0) {
debug(6, 0, "file_open: error opening file %s: %s\n",
{
FD_ENTRY *conn;
- /* lazy initialization */
- if (!disk_initialized)
- disk_init();
-
/* update fdstat */
fdstat_open(fd, File);
* close it */
/* save it for later */
- if ((file_table[fd].open_stat == OPEN) &&
- (file_table[fd].write_daemon == NOT_PRESENT) &&
- (file_table[fd].write_pending == NO_WRT_PENDING)) {
+ if (file_table[fd].open_stat == NOT_OPEN) {
+ debug(6, 3, "file_close: FD %d is not OPEN\n", fd);
+ } else if (file_table[fd].write_daemon == PRESENT) {
+ debug(6, 3, "file_close: FD %d has a write daemon PRESENT\n", fd);
+ } else if (file_table[fd].write_pending == WRT_PENDING) {
+ debug(6, 3, "file_close: FD %d has a write PENDING\n", fd);
+ } else {
file_table[fd].open_stat = NOT_OPEN;
file_table[fd].write_lock = UNLOCK;
file_table[fd].write_daemon = NOT_PRESENT;
comm_set_fd_lifetime(fd, -1); /* invalidate the lifetime */
close(fd);
return DISK_OK;
- } else {
- /* refused to close file if there is a daemon running */
- /* have pending flag set */
- file_table[fd].close_request = REQUEST;
- return DISK_ERROR;
}
+
+ /* refused to close file if there is a daemon running */
+ /* have pending flag set */
+ file_table[fd].close_request = REQUEST;
+ return DISK_ERROR;
}