Ticket #108: winunlink.patch

File winunlink.patch, 1.1 KB (added by Richard Boulton, 17 years ago)

Crude patch to work around problem

  • backends/flint/flint_table.cc

     
    2323#include <config.h>
    2424
    2525#include "safeerrno.h"
     26#include "safewindows.h"
    2627
    2728// Define to use "dangerous" mode - in this mode we write modified btree
    2829// blocks back in place.  This is somewhat faster (especially once we're
     
    130131
    131132static void sys_unlink(const string &filename)
    132133{
    133     if (unlink(filename) == -1) {
     134    while (unlink(filename) == -1) {
     135#if defined __CYGWIN__ || defined __WIN32__
     136        if (errno == EACCES) {
     137
     138            /* Windows fails with EACCES if the file is currently open for
     139             * reading.  We need to try again in this case.  It would be better
     140             * if we could distinguish this from permission denied, so we don't
     141             * go into an infinite loop in this situation. */
     142
     143            Sleep(100); /* Sleep() takes a number of milliseconds to sleep as
     144                           it's parameter. */
     145            continue;
     146        }
     147#endif
    134148        string message = "Failed to unlink ";
    135149        message += filename;
    136150        message += ": ";