--------------------- PatchSet 4595 Date: 2002/07/28 16:25:33 Author: serassio Branch: nt-2_5 Tag: (none) Log: Imported awin32 changes from nt branch Members: src/fs/awin32/aiops.c:1.1.62.6->1.1.62.7 src/fs/awin32/async_io.c:1.1.62.2->1.1.62.3 src/fs/awin32/store_dir_aufs.c:1.1.62.8->1.1.62.9 src/fs/awin32/store_io_aufs.c:1.1.62.7->1.1.62.8 Index: squid/src/fs/awin32/aiops.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/awin32/Attic/aiops.c,v retrieving revision 1.1.62.6 retrieving revision 1.1.62.7 diff -u -r1.1.62.6 -r1.1.62.7 --- squid/src/fs/awin32/aiops.c 26 Jul 2002 13:39:58 -0000 1.1.62.6 +++ squid/src/fs/awin32/aiops.c 28 Jul 2002 16:25:33 -0000 1.1.62.7 @@ -1,5 +1,5 @@ /* - * $Id: aiops.c,v 1.1.62.6 2002/07/26 13:39:58 serassio Exp $ + * $Id: aiops.c,v 1.1.62.7 2002/07/28 16:25:33 serassio Exp $ * * DEBUG: section 43 AIOPS * AUTHOR: Stewart Forster @@ -746,7 +746,11 @@ { lseek(requestp->fd, requestp->offset, requestp->whence); #ifdef _SQUID_MSWIN_ - requestp->ret = _read(requestp->fd, requestp->tmpbufp, requestp->buflen); + if (!ReadFile((HANDLE)_get_osfhandle(requestp->fd), requestp->tmpbufp, + requestp->buflen, (LPDWORD)&requestp->ret, NULL)) { + _dosmaperr(GetLastError()); + requestp->ret = -1; + } #else requestp->ret = read(requestp->fd, requestp->tmpbufp, requestp->buflen); #endif @@ -781,7 +785,11 @@ squidaio_do_write(squidaio_request_t * requestp) { #ifdef _SQUID_MSWIN_ - requestp->ret = _write(requestp->fd, requestp->tmpbufp, requestp->buflen); + if (!WriteFile((HANDLE)_get_osfhandle(requestp->fd), requestp->tmpbufp, + requestp->buflen, (LPDWORD)&requestp->ret, NULL)) { + _dosmaperr(GetLastError()); + requestp->ret = -1; + } #else requestp->ret = write(requestp->fd, requestp->tmpbufp, requestp->buflen); #endif @@ -810,7 +818,10 @@ static void squidaio_do_close(squidaio_request_t * requestp) { - requestp->ret = close(requestp->fd); + if((requestp->ret = close(requestp->fd)) < 0) { + debug(43, 0) ("squidaio_do_close: FD %d, errno %d\n", requestp->fd, errno); + close(requestp->fd); + } requestp->err = errno; } Index: squid/src/fs/awin32/async_io.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/awin32/Attic/async_io.c,v retrieving revision 1.1.62.2 retrieving revision 1.1.62.3 diff -u -r1.1.62.2 -r1.1.62.3 --- squid/src/fs/awin32/async_io.c 12 May 2002 17:12:09 -0000 1.1.62.2 +++ squid/src/fs/awin32/async_io.c 28 Jul 2002 16:25:34 -0000 1.1.62.3 @@ -1,6 +1,6 @@ /* - * $Id: async_io.c,v 1.1.62.2 2002/05/12 17:12:09 serassio Exp $ + * $Id: async_io.c,v 1.1.62.3 2002/07/28 16:25:34 serassio Exp $ * * DEBUG: section 32 Asynchronous Disk I/O * AUTHOR: Pete Bentley @@ -331,6 +331,7 @@ aioStats(StoreEntry * sentry) { storeAppendPrintf(sentry, "ASYNC IO Counters:\n"); + storeAppendPrintf(sentry, "Operation\t# Requests\n"); storeAppendPrintf(sentry, "open\t%d\n", squidaio_counts.open); storeAppendPrintf(sentry, "close\t%d\n", squidaio_counts.close); storeAppendPrintf(sentry, "cancel\t%d\n", squidaio_counts.cancel); Index: squid/src/fs/awin32/store_dir_aufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/awin32/Attic/store_dir_aufs.c,v retrieving revision 1.1.62.8 retrieving revision 1.1.62.9 diff -u -r1.1.62.8 -r1.1.62.9 --- squid/src/fs/awin32/store_dir_aufs.c 26 Jul 2002 13:39:59 -0000 1.1.62.8 +++ squid/src/fs/awin32/store_dir_aufs.c 28 Jul 2002 16:25:34 -0000 1.1.62.9 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.c,v 1.1.62.8 2002/07/26 13:39:59 serassio Exp $ + * $Id: store_dir_aufs.c,v 1.1.62.9 2002/07/28 16:25:34 serassio Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -211,12 +211,12 @@ getCurrentTime(); if (0 == stat(path, &st)) { if (S_ISDIR(st.st_mode)) { - debug(20, should_exist ? 3 : 1) ("%s exists\n", path); + debug(47, should_exist ? 3 : 1) ("%s exists\n", path); } else { fatalf("Swap directory %s is not a directory.", path); } } else if (0 == mkdir(path, 0755)) { - debug(20, should_exist ? 1 : 3) ("%s created\n", path); + debug(47, should_exist ? 1 : 3) ("%s created\n", path); created = 1; } else { fatalf("Failed to make swap directory %s: %s", @@ -230,11 +230,11 @@ { struct stat sb; if (stat(path, &sb) < 0) { - debug(20, 0) ("%s: %s\n", path, xstrerror()); + debug(47, 0) ("%s: %s\n", path, xstrerror()); return -1; } if (S_ISDIR(sb.st_mode) == 0) { - debug(20, 0) ("%s is not a directory\n", path); + debug(47, 0) ("%s is not a directory\n", path); return -1; } return 0; @@ -325,7 +325,7 @@ debug(50, 1) ("%s: %s\n", path, xstrerror()); fatal("storeAufsDirOpenSwapLog: Failed to open swap log."); } - debug(47, 3) ("Cache Dir #%d log opened on FD %d\n", sd->index, fd); + debug(50, 3) ("Cache Dir #%d log opened on FD %d\n", sd->index, fd); aioinfo->swaplog_fd = fd; if (0 == n_asyncufs_dirs) assert(NULL == asyncufs_dir_index); @@ -387,12 +387,12 @@ tlv *tlv_list; tlv *t; assert(rb != NULL); - debug(20, 3) ("storeAufsDirRebuildFromDirectory: DIR #%d\n", rb->sd->index); + debug(47, 3) ("storeAufsDirRebuildFromDirectory: DIR #%d\n", rb->sd->index); for (count = 0; count < rb->speed; count++) { assert(fd == -1); fd = storeAufsDirGetNextFile(rb, &filn, &size); if (fd == -2) { - debug(20, 1) ("Done scanning %s swaplog (%d entries)\n", + debug(47, 1) ("Done scanning %s swaplog (%d entries)\n", rb->sd->path, rb->n_read); store_dirs_rebuilding--; storeAufsDirCloseTmpSwapLog(rb->sd); @@ -405,7 +405,7 @@ assert(fd > -1); /* lets get file stats here */ if (fstat(fd, &sb) < 0) { - debug(20, 1) ("storeAufsDirRebuildFromDirectory: fstat(FD %d): %s\n", + debug(47, 1) ("storeAufsDirRebuildFromDirectory: fstat(FD %d): %s\n", fd, xstrerror()); file_close(fd); store_open_disk_fd--; @@ -413,12 +413,12 @@ continue; } if ((++rb->counts.scancount & 0xFFFF) == 0) - debug(20, 3) (" %s %7d files opened so far.\n", + debug(47, 3) (" %s %7d files opened so far.\n", rb->sd->path, rb->counts.scancount); - debug(20, 9) ("file_in: fd=%d %08X\n", fd, filn); + debug(47, 9) ("file_in: fd=%d %08X\n", fd, filn); statCounter.syscalls.disk.reads++; if (FD_READ_METHOD(fd, hdr_buf, SM_PAGE_SIZE) < 0) { - debug(20, 1) ("storeAufsDirRebuildFromDirectory: read(FD %d): %s\n", + debug(47, 1) ("storeAufsDirRebuildFromDirectory: read(FD %d): %s\n", fd, xstrerror()); file_close(fd); store_open_disk_fd--; @@ -435,12 +435,12 @@ #endif tlv_list = storeSwapMetaUnpack(hdr_buf, &swap_hdr_len); if (tlv_list == NULL) { - debug(20, 1) ("storeAufsDirRebuildFromDirectory: failed to get meta data\n"); + debug(47, 1) ("storeAufsDirRebuildFromDirectory: failed to get meta data\n"); /* XXX shouldn't this be a call to storeAufsUnlink ? */ storeAufsDirUnlinkFile(SD, filn); continue; } - debug(20, 3) ("storeAufsDirRebuildFromDirectory: successful swap meta unpacking\n"); + debug(47, 3) ("storeAufsDirRebuildFromDirectory: successful swap meta unpacking\n"); memset(key, '\0', MD5_DIGEST_CHARS); memset(&tmpe, '\0', sizeof(StoreEntry)); for (t = tlv_list; t; t = t->next) { @@ -460,7 +460,7 @@ storeSwapTLVFree(tlv_list); tlv_list = NULL; if (storeKeyNull(key)) { - debug(20, 1) ("storeAufsDirRebuildFromDirectory: NULL key\n"); + debug(47, 1) ("storeAufsDirRebuildFromDirectory: NULL key\n"); storeAufsDirUnlinkFile(SD, filn); continue; } @@ -471,7 +471,7 @@ } else if (tmpe.swap_file_sz == sb.st_size - swap_hdr_len) { tmpe.swap_file_sz = (size_t) sb.st_size; } else if (tmpe.swap_file_sz != sb.st_size) { - debug(20, 1) ("storeAufsDirRebuildFromDirectory: SIZE MISMATCH %ld!=%ld\n", + debug(47, 1) ("storeAufsDirRebuildFromDirectory: SIZE MISMATCH %ld!=%ld\n", (long int) tmpe.swap_file_sz, (long int) sb.st_size); storeAufsDirUnlinkFile(SD, filn); continue; @@ -526,7 +526,7 @@ /* load a number of objects per invocation */ for (count = 0; count < rb->speed; count++) { if (fread(&s, ss, 1, rb->log) != 1) { - debug(20, 1) ("Done reading %s swaplog (%d entries)\n", + debug(47, 1) ("Done reading %s swaplog (%d entries)\n", rb->sd->path, rb->n_read); fclose(rb->log); rb->log = NULL; @@ -550,7 +550,7 @@ * to mask it off. */ s.swap_filen &= 0x00FFFFFF; - debug(20, 3) ("storeAufsDirRebuildFromSwapLog: %s %s %08X\n", + debug(47, 3) ("storeAufsDirRebuildFromSwapLog: %s %s %08X\n", swap_log_op_str[(int) s.op], storeKeyText(s.key), s.swap_filen); @@ -581,7 +581,7 @@ } else { x = log(++rb->counts.bad_log_op) / log(10.0); if (0.0 == x - (double) (int) x) - debug(20, 1) ("WARNING: %d invalid swap log entries found\n", + debug(47, 1) ("WARNING: %d invalid swap log entries found\n", rb->counts.bad_log_op); rb->counts.invalid++; continue; @@ -622,7 +622,7 @@ storeAufsDirUnrefObj(SD, e); } else { debug_trap("storeAufsDirRebuildFromSwapLog: bad condition"); - debug(20, 1) ("\tSee %s:%d\n", __FILE__, __LINE__); + debug(47, 1) ("\tSee %s:%d\n", __FILE__, __LINE__); } continue; } else if (used) { @@ -631,7 +631,7 @@ * point. If the log is dirty, the filesize check should have * caught this. If the log is clean, there should never be a * newer entry. */ - debug(20, 1) ("WARNING: newer swaplog entry for dirno %d, fileno %08X\n", + debug(47, 1) ("WARNING: newer swaplog entry for dirno %d, fileno %08X\n", SD->index, s.swap_filen); /* I'm tempted to remove the swapfile here just to be safe, * but there is a bad race condition in the NOVM version if @@ -694,11 +694,10 @@ int fd = -1; int used = 0; int dirs_opened = 0; - debug(20, 3) ("storeAufsDirGetNextFile: flag=%d, %d: /%02X/%02X\n", + debug(47, 3) ("storeAufsDirGetNextFile: flag=%d, %d: /%02X/%02X\n", rb->flags.init, rb->sd->index, - rb->curlvl1, - rb->curlvl2); + rb->curlvl1, rb->curlvl2); if (rb->done) return -2; while (fd < 0 && rb->done == 0) { @@ -714,45 +713,46 @@ if (0 == rb->in_dir) { /* we need to read in a new directory */ snprintf(rb->fullpath, SQUID_MAXPATHLEN, "%s/%02X/%02X", rb->sd->path, - rb->curlvl1, rb->curlvl2); + rb->curlvl1, + rb->curlvl2); if (dirs_opened) return -1; rb->td = opendir(rb->fullpath); dirs_opened++; if (rb->td == NULL) { - debug(50, 1) ("storeAufsDirGetNextFile: opendir: %s: %s\n", + debug(47, 1) ("storeAufsDirGetNextFile: opendir: %s: %s\n", rb->fullpath, xstrerror()); } else { rb->entry = readdir(rb->td); /* skip . and .. */ rb->entry = readdir(rb->td); if (rb->entry == NULL && errno == ENOENT) - debug(20, 1) ("storeAufsDirGetNextFile: directory does not exist!.\n"); - debug(20, 3) ("storeAufsDirGetNextFile: Directory %s\n", rb->fullpath); + debug(47, 1) ("storeAufsDirGetNextFile: directory does not exist!.\n"); + debug(47, 3) ("storeAufsDirGetNextFile: Directory %s\n", rb->fullpath); } } if (rb->td != NULL && (rb->entry = readdir(rb->td)) != NULL) { rb->in_dir++; if (sscanf(rb->entry->d_name, "%x", &rb->fn) != 1) { - debug(20, 3) ("storeAufsDirGetNextFile: invalid %s\n", + debug(47, 3) ("storeAufsDirGetNextFile: invalid %s\n", rb->entry->d_name); continue; } if (!storeAufsFilenoBelongsHere(rb->fn, rb->sd->index, rb->curlvl1, rb->curlvl2)) { - debug(20, 3) ("storeAufsDirGetNextFile: %08X does not belong in %d/%d/%d\n", + debug(47, 3) ("storeAufsDirGetNextFile: %08X does not belong in %d/%d/%d\n", rb->fn, rb->sd->index, rb->curlvl1, rb->curlvl2); continue; } used = storeAufsDirMapBitTest(SD, rb->fn); if (used) { - debug(20, 3) ("storeAufsDirGetNextFile: Locked, continuing with next.\n"); + debug(47, 3) ("storeAufsDirGetNextFile: Locked, continuing with next.\n"); continue; } snprintf(rb->fullfilename, SQUID_MAXPATHLEN, "%s/%s", rb->fullpath, rb->entry->d_name); - debug(20, 3) ("storeAufsDirGetNextFile: Opening %s\n", rb->fullfilename); + debug(47, 3) ("storeAufsDirGetNextFile: Opening %s\n", rb->fullfilename); fd = file_open(rb->fullfilename, O_RDONLY | O_BINARY); if (fd < 0) - debug(50, 1) ("storeAufsDirGetNextFile: %s: %s\n", rb->fullfilename, xstrerror()); + debug(47, 1) ("storeAufsDirGetNextFile: %s: %s\n", rb->fullfilename, xstrerror()); else store_open_disk_fd++; continue; @@ -788,7 +788,7 @@ int clean) { StoreEntry *e = NULL; - debug(20, 5) ("storeAufsAddDiskRestore: %s, fileno=%08X\n", storeKeyText(key), file_number); + debug(47, 5) ("storeAufsAddDiskRestore: %s, fileno=%08X\n", storeKeyText(key), file_number); /* if you call this you'd better be sure file_number is not * already in use! */ e = new_StoreEntry(STORE_ENTRY_WITHOUT_MEMOBJ, NULL, NULL); @@ -848,7 +848,7 @@ } if (!clean) rb->flags.need_to_validate = 1; - debug(20, 1) ("Rebuilding storage in %s (%s)\n", + debug(47, 1) ("Rebuilding storage in %s (%s)\n", sd->path, clean ? "CLEAN" : "DIRTY"); store_dirs_rebuilding++; eventAdd("storeRebuild", func, rb, 0.0, 1); @@ -969,7 +969,7 @@ state->outbuf_offset = 0; state->walker = sd->repl->WalkInit(sd->repl); unlink(state->cln); - debug(20, 3) ("storeDirWriteCleanLogs: opened %s, FD %d\n", + debug(47, 3) ("storeDirWriteCleanLogs: opened %s, FD %d\n", state->new, state->fd); #if HAVE_FCHMOD if (stat(state->cur, &sb) == 0) @@ -1020,7 +1020,7 @@ if (FD_WRITE_METHOD(state->fd, state->outbuf, state->outbuf_offset) < 0) { debug(50, 0) ("storeDirWriteCleanLogs: %s: write: %s\n", state->new, xstrerror()); - debug(20, 0) ("storeDirWriteCleanLogs: Current swap logfile not replaced.\n"); + debug(50, 0) ("storeDirWriteCleanLogs: Current swap logfile not replaced.\n"); file_close(state->fd); state->fd = -1; unlink(state->new); @@ -1046,7 +1046,7 @@ if (FD_WRITE_METHOD(state->fd, state->outbuf, state->outbuf_offset) < 0) { debug(50, 0) ("storeDirWriteCleanLogs: %s: write: %s\n", state->new, xstrerror()); - debug(20, 0) ("storeDirWriteCleanLogs: Current swap logfile " + debug(50, 0) ("storeDirWriteCleanLogs: Current swap logfile " "not replaced.\n"); file_close(state->fd); state->fd = -1; @@ -1325,8 +1325,7 @@ * This is kinda cheap, but so we need this priority hack? */ } - debug(20, 3) ("storeMaintainSwapSpace: f=%f, max_scan=%d, max_remove=%d\n", - f, max_scan, max_remove); + debug(47, 3) ("storeMaintainSwapSpace: f=%f, max_scan=%d, max_remove=%d\n", f, max_scan, max_remove); walker = SD->repl->PurgeInit(SD->repl, max_scan); while (1) { if (SD->cur_size < SD->low_size) @@ -1340,7 +1339,7 @@ storeRelease(e); } walker->Done(walker); - debug(20, (removed ? 2 : 3)) ("storeUfsDirMaintain: %s removed %d/%d f=%.03f max_scan=%d\n", + debug(47, (removed ? 2 : 3)) ("storeUfsDirMaintain: %s removed %d/%d f=%.03f max_scan=%d\n", SD->path, removed, max_remove, f, max_scan); } @@ -1359,7 +1358,7 @@ #if OLD_UNUSED_CODE if (storeAufsDirExpiredReferenceAge(SD) < 300) { - debug(20, 3) ("storeAufsDirCheckObj: NO: LRU Age = %d\n", + debug(47, 3) ("storeAufsDirCheckObj: NO: LRU Age = %d\n", storeAufsDirExpiredReferenceAge(SD)); /* store_check_cachable_hist.no.lru_age_too_low++; */ return -1; @@ -1429,7 +1428,7 @@ void storeAufsDirReplAdd(SwapDir * SD, StoreEntry * e) { - debug(20, 4) ("storeAufsDirReplAdd: added node %p to dir %d\n", e, + debug(47, 4) ("storeAufsDirReplAdd: added node %p to dir %d\n", e, SD->index); SD->repl->Add(SD->repl, e, &e->repl); } @@ -1439,7 +1438,7 @@ storeAufsDirReplRemove(StoreEntry * e) { SwapDir *SD = INDEXSD(e->swap_dirn); - debug(20, 4) ("storeAufsDirReplRemove: remove node %p from dir %d\n", e, + debug(47, 4) ("storeAufsDirReplRemove: remove node %p from dir %d\n", e, SD->index); SD->repl->Remove(SD->repl, e, &e->repl); } @@ -1589,19 +1588,19 @@ { struct stat sb; if (stat(storeAufsDirFullPath(sd, e->swap_filen, NULL), &sb) < 0) { - debug(20, 0) ("storeAufsCleanupDoubleCheck: MISSING SWAP FILE\n"); - debug(20, 0) ("storeAufsCleanupDoubleCheck: FILENO %08X\n", e->swap_filen); - debug(20, 0) ("storeAufsCleanupDoubleCheck: PATH %s\n", + debug(47, 0) ("storeAufsCleanupDoubleCheck: MISSING SWAP FILE\n"); + debug(47, 0) ("storeAufsCleanupDoubleCheck: FILENO %08X\n", e->swap_filen); + debug(47, 0) ("storeAufsCleanupDoubleCheck: PATH %s\n", storeAufsDirFullPath(sd, e->swap_filen, NULL)); storeEntryDump(e, 0); return -1; } if (e->swap_file_sz != sb.st_size) { - debug(20, 0) ("storeAufsCleanupDoubleCheck: SIZE MISMATCH\n"); - debug(20, 0) ("storeAufsCleanupDoubleCheck: FILENO %08X\n", e->swap_filen); - debug(20, 0) ("storeAufsCleanupDoubleCheck: PATH %s\n", + debug(47, 0) ("storeAufsCleanupDoubleCheck: SIZE MISMATCH\n"); + debug(47, 0) ("storeAufsCleanupDoubleCheck: FILENO %08X\n", e->swap_filen); + debug(47, 0) ("storeAufsCleanupDoubleCheck: PATH %s\n", storeAufsDirFullPath(sd, e->swap_filen, NULL)); - debug(20, 0) ("storeAufsCleanupDoubleCheck: ENTRY SIZE: %ld, FILE SIZE: %ld\n", + debug(47, 0) ("storeAufsCleanupDoubleCheck: ENTRY SIZE: %ld, FILE SIZE: %ld\n", (long int) e->swap_file_sz, (long int) sb.st_size); storeEntryDump(e, 0); return -1; Index: squid/src/fs/awin32/store_io_aufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/awin32/Attic/store_io_aufs.c,v retrieving revision 1.1.62.7 retrieving revision 1.1.62.8 diff -u -r1.1.62.7 -r1.1.62.8 --- squid/src/fs/awin32/store_io_aufs.c 26 Jul 2002 13:39:59 -0000 1.1.62.7 +++ squid/src/fs/awin32/store_io_aufs.c 28 Jul 2002 16:25:34 -0000 1.1.62.8 @@ -1,6 +1,6 @@ /* - * $Id: store_io_aufs.c,v 1.1.62.7 2002/07/26 13:39:59 serassio Exp $ + * $Id: store_io_aufs.c,v 1.1.62.8 2002/07/28 16:25:34 serassio Exp $ * * DEBUG: section 79 Storage Manager awin32 Interface * AUTHOR: Robert Collins @@ -144,7 +144,7 @@ ((squidaiostate_t *) (sio->fsstate))->flags.opening = 1; sio->swap_filen = filn; sio->swap_dirn = dirn; - sio->mode = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY; + sio->mode = O_WRONLY; sio->callback = callback; sio->callback_data = callback_data; sio->e = (StoreEntry *) e;