Message10453

Author GrayNM
Recipients
Date 2009-09-03.09:08:24
Content
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.
History
Date User Action Args
2009-09-03 09:08:24GrayNMsetmessageid: <1251968904.51.0.219652269114.issue1820@selenic.com>
2009-09-03 09:08:24GrayNMlinkissue1820 messages
2009-09-03 09:08:24GrayNMcreate