Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2a7476de8a3f11dc2f22b686632570cea1acae75
Ticket: 1593707fffffffffffffffffffffffffffffffff
win32 error during simultaneous file open for read
User & Date: melbardis on 2006-11-09 19:35:00
Changes

  1. assignee changed to: "vincentdarley"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    If threads in a multi threaded application (or simply 
    multiple copies of a tclsh) try to open the same file 
    for reading, there appears to be a window of 
    opportunity for windows to return an error, typically 
    a ERROR_SHARING_VIOLATION error.
    
    Additionally (in another of my applications non-tcl) 
    i found that is a thread closes a file and another 
    thread trys to delete the file, the same window can 
    apply.
    
    I have modfied win/tclWinChan.c (8.54a, though same 
    code seems to exist everywhere...) as follows:
    
        /*
         * Now we get to create the file.
         */
        {
            //EPM - windows can screwup when opening same 
    file at same time
            int retry = 5;
            int err;
            while (retry--) {
                handle = (*tclWinProcs->createFileProc)
    (nativeName, accessMode,
                                                        
    shareMode, NULL, createMode, flags, (HANDLE) NULL);
                if (handle != INVALID_HANDLE_VALUE) {
                    break;
                }
                err = GetLastError();
                if (err == ERROR_FILE_NOT_FOUND) {
                        // File removed by external 
    circumstances.
                        break;
                }
                Sleep(100);
                //printf("retry... %d\n", retry);
            }
        }
    
    
    if the retry message is uncommented, then the retry 
    was output occasionally when running the test code, 
    with a retry value of 4
    
    note: my machine is a dual-core pentium 2.8 gig
    
    
    
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "melbardis"
  10. subsystem changed to: "37. File System"
  11. title changed to: "win32 error during simultaneous file open for read"
  12. type changed to: "Bug"