[issue1820] Windows misbehavior

GrayNM mercurial-bugs at selenic.com
Thu Sep 3 09:08:24 UTC 2009


New submission from GrayNM <_gray_nm_ at bk.ru>:

Yesterday I got fail while updating my working dir.
I've downloaded changes from remote repository successfully and tried to
apply them. That was a big update, almost 6000 files.
Error message was "abort: No such file or directory:
E:\Work\Gray\Projects\Global\contrib\.hg\merge/state" but file was present
in file system.
OS: WinXP SP3, TortoiseHG 0.8.1.
Experiment with Fedora 11 shows that linux version works correct.

Trace shows that error occurs in osutil:posixfile() routine.
After some investigation I've found that CreateFile in very rare cases
returns ERROR_USER_MAPPED_FILE. I think that is because system still not
released file when trying to open it again.

I've added ability to retry open operation like this:

another_try:
	handle = CreateFile(name, access,
			    FILE_SHARE_READ | FILE_SHARE_WRITE |
			    FILE_SHARE_DELETE,
			    NULL,
			    creation,
			    FILE_ATTRIBUTE_NORMAL,
			    0);

	if (handle == INVALID_HANDLE_VALUE) {
		ierr=GetLastError();
		if((ierr==ERROR_USER_MAPPED_FILE)&&(retrycnt<5))
		{
			++retrycnt;
			Sleep(200);
			goto another_try;
		}
		PyErr_SetFromWindowsErrWithFilename(ierr, name);
		goto bail;
	}

After that update was ok. 200ms sleep I got just to be sure. I think it can
be much less.

----------
messages: 10453
nosy: GrayNM
priority: urgent
status: unread
title: Windows misbehavior

____________________________________________________
Mercurial issue tracker <mercurial-bugs at selenic.com>
<http://mercurial.selenic.com/bts/issue1820>
____________________________________________________



More information about the Mercurial-devel mailing list