Artifacts Associated With Ticket 1593707fff
Ticket change [2a7476de8a] (rid 118575) by melbardis on 2006-11-09 19:35:00:
- assignee initialized to: "vincentdarley"
- cmimetype initialized to: "text/plain"
- comment initialized 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 - foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "melbardis"
- subsystem initialized to: "37. File System"
- title initialized to: "win32 error during simultaneous file open for read"
- type initialized to: "Bug"
Ticket change [9211d5dbd1] (rid 120722) by melbardis on 2006-11-10 02:35:00:
- icomment:
File Added - 202137: ct.tcl
- login: "melbardis"
- mimetype: "text/plain"
- username: "melbardis"
- icomment:
Add attachment "ct.tcl" [8b16f23bc7] (rid 127500) by melbardis on 2006-11-10 02:35:00.
Add attachment "tclWinChan.c" [64effa4d58] (rid 92862) by melbardis on 2006-11-10 02:35:53.
Ticket change [bd74cb11de] (rid 101907) by melbardis on 2006-11-10 02:35:53:
- icomment:
File Added - 202139: tclWinChan.c
- login: "melbardis"
- mimetype: "text/plain"
- username: "melbardis"
- icomment:
Ticket change [ce4a5520f5] (rid 96031) by melbardis on 2007-03-21 20:12:39:
- priority changed to: "7 High"
Ticket change [587c218cc0] (rid 117813) by melbardis on 2007-07-19 04:38:20:
- icomment:
Logged In: YES user_id=788816 Originator: YES no response when filed under the previous category!
- login: "melbardis"
- mimetype: "text/plain"
- priority changed to: "8"
- subsystem changed to: "49. Threading"
- username: "melbardis"
- icomment:
Ticket change [be1ff782f5] (rid 102022) by georgeps on 2007-12-15 05:29:30:
- icomment:
Logged In: YES user_id=585068 Originator: NO After reading MSDN I'm not sure this is a bug that is fixable in Tcl, without a hack that really wouldn't be appropriate. To quote from MSDN: "When a process attempts to open a file that has already been opened in sharing mode, the system compares the requested access and sharing modes to those specified when the file was opened. If you specify an access mode that conflicts with the sharing mode specified in the previous open call, CreateFile fails with a sharing violation (ERROR_SHARING_VIOLATION)." I think this means you just can't do some things in Windows that you want to do, unless you remove the FILE_SHARE_* flags from the CreateFile call. However, I just noticed that NativeStat() in the win tree uses "FILE_SHARE_READ | FILE_SHARE_WRITE" (used to detect permissions it seems) with CreateFile. There could be a race between the stat in one thread, and an open in another. So even though you only want one handle open, the stat is causing the open to fail in some cases. This isn't good...
- login: "georgeps"
- mimetype: "text/plain"
- username: "georgeps"
- icomment: